You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Keep requests for a session that takes them with basecamp connect next - #1063
A connector session sometimes never hears a request it should get
(card).
The basecamp-connect skill watches the connector's stdout with a Claude Code
Monitor armed persistent: true. Claude Code no longer has persistent, so
every watch now expires and has to be re-armed. A re-armed watch replays the
whole output file, and the session has to remember which requests it already
handled. The usual fix, a grep -v skip list, holds the newest request back
until the next one arrives, because the grep Claude Code's Bash runs is an
embedded ugrep whose -v waits for the following line. Today's skill sends
these sessions to --orchestrator instead.
This replaces #902, a skill-side watcher, with the connector keeping requests
until a session takes them.
What changes
Connector (opt-in).basecamp connect -P <p> --session-queue keeps each
trusted request in its ledger as session_pending, instead of printing its
request line. Stdout prints {"type":"queued","event_id":N,"recording_id":M}
in place of the request line; the intake and verdict lines continue as before.
Three commands read and close the queue over a socket in the profile's state
directory:
basecamp connect next [--wait] [--except <ids>] prints every eligible
request line, byte for byte the line plain basecamp connect prints for the
same record. --wait blocks until there is one. Reading writes nothing.
basecamp connect pending [<id>] shows what is waiting, and what is
withheld and why.
basecamp connect ack <id> closes a request the session has taken on.
A request is handed over only while the running connector would still hand
it over:
no hold, and not tagged for review by one
served projects readable
served, inside --project, or a Ping the run hears
its own people still stand where they did when it was admitted: the
performer, the requester and the author whose words were trusted. That
covers whether each is the operator, allowlisted, an allowed agent or in
the Ping, plus the trust mode, whether the project is served, and the one
setting the trigger turns on. It's recorded with each verdict.
So someone removed from a Ping or the allowlist since is not answered. Adding
a colleague, changing an agent cap or serving another project holds nothing
back. A withheld request becomes eligible
again by itself when the condition clears, and stays until it is acked or
discarded (discard now accepts one).
Without the flag, nothing changes: the stdout bytes, status and the runner
are as before. The flag is refused with --shadow and with anything that
starts the runner.
Skill. basecamp-connect checks basecamp connect --help for --session-queue.
With it, the session:
starts the connector with the flag
runs one background basecamp connect next --wait, whose exit wakes it
checks each request with pending <id> before acting on it
acks right after a worker launches, or after its own reply or refusal
after a compaction, or in a new session, settles anything unacked with pending
if the connector dies, runs doctor and starts it again once in the same
mode
if a crashed session left its queue connector running, asks the person
whether another session still works from it, and otherwise takes it over
A request waiting on the person, such as a repo choice, stays unacked.
Without the flag (an older CLI), the skill does exactly what it does today:
the Monitor flow where the Monitor takes persistent, otherwise --orchestrator. Restarts keep the mode the session started in.
Hooks and the runner. The compaction notice names the waiter only when
this session's own connector started with the queue. Every other session gets
today's text, byte for byte. The orchestrator's mapping says the queue
commands are not its to run.
Compatibility
CLI
Skill
Result
older
older
unchanged
this
older
unchanged (the queue is off without the flag)
older
this
today's flow (Monitor, or --orchestrator)
this
this
the session queue
Other starts say what waits. A start without --session-queue never
hands these requests over, so it logs how many wait for a session.
Migration 17. This is ledger migration 17. A basecamp older than this
refuses a ledger this one has opened, as it refuses any newer schema.
After upgrading, basecamp connect status asks for the connector to start
once before it reads the ledger, as it does after every migration.
Exit codes.next and pending exit 0 when they answer, 1 on a usage
error, 11 when no connector for the profile runs the queue, 12 when the
connector stopped before answering, and 130/143 on a signal.
Known limits
A pre-existing gap stays. If the connector crashes while acknowledging
a burst of requests, and restarts more than a minute after the request was
made, that request is dropped. Every mode already has this gap, and the
queue doesn't widen it.
No membership re-check. Removing a person from a Basecamp project while
their request waits does not withhold it. Revoking them in connect.json
does.
One acting session per profile. Delivery to the session is
at-least-once. The skill settles a repeat against its workers or the reply
thread, and asks the person when it can't tell.
Verification
bin/ci green.
Real binaries, against an isolated local bc3 (this branch and main side
by side): 23 of 24 checks pass. The 24th is status on a ledger an older
build wrote, which refuses until the connector starts once, as main does
after every migration; it passes after that start. next --wait returned
1.18 to 2.21 s after the mention was created (median 1.33 s, 10 of 10).
Live Claude Code sessions (2.1.332, interactive), running the skill
against local bc3:
Case
Result
Idle 75 min with the waiter armed, then /compact, then the connector killed
4 of 4 requests started a turn within 0.011 s of being queued; each was replied to once and acked
Claude Code killed right after the waiter woke it, before any tool call
3 of 3 settled by a fresh session with pending: replied to once, acked
This skill with main's CLI
3 of 3 took today's route; the queue was never used
Main's skill with this CLI
3 of 3 behaved as main does; the compaction notice was main's, byte for byte
Those runs found three gaps, now fixed in the skill: it asked before
restarting a killed connector; it had no path for a connector a crashed
session left running; and one session stopped its connector with a
pattern match that also stopped other sessions' connectors. A second live
run (on 99ccc7b) checked each fix, 2 of 2 each: a killed connector was
restarted without asking, a crashed session's connector was taken over
after one question with no second connector started, and a stop left a
look-alike connector running. Since then, after review, a takeover stops
the left-behind connector and starts the session's own, so the session
can stop it later; that step was not run live.
--orchestrator, live against local bc3, this branch beside main:
Claude workers: 2 of 2 requests answered once on each build; the second request on the thread went to the same worker.
Codex worker: 1 of 1 answered once.
Connector killed after the handoff and restarted: the request was repeated and answered once, on both builds.
Output lines, runner state and ledger outcomes matched; the orchestrator never ran the queue commands.
Skill eval cases were added; their graders were checked against
hand-written traces (8 of 8 correct pass, 54 of 54 wrong fail). The model
run is this PR's Skill Evals job.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Active issues cause repeated loading of all queued request payloads, leave Monitor-free sessions without an authentication-recovery wake-up, and allow adopted connectors to remain running after intake is reported stopped.
Adds an opt-in, ledger-backed session queue so coding-agent sessions can retrieve connector requests when ready, rather than relying on continuous stdout monitoring.
Changes:
Adds --session-queue and the next, pending, and ack commands, with policy checks and durable request storage.
Updates the skill, compaction hook, status, console, and runner guidance while preserving older-CLI behavior.
Adds migration, command, compatibility, and skill-evaluation coverage.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
File
Description
skills/basecamp-connect/SKILL.md
Documents queue delivery, recovery, and legacy fallback.
skill-evals/run
Adds session-tool mocks and forbidden-sequence grading.
Declined: per-row reads in the queue check. The queue holds none or a few rows, and a second, eligibility-only read path would have to stay in step with the one next hands out.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
A malformed or unreadable connect.json prevents queue commands from reaching the running connector, blocking pending from reporting projects_unreadable and next --wait from waiting for file repair.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Malformed connect.json prevents queue state reporting and waiting
internal/commands/connect_session_queue.go:218
If connect.json becomes malformed or unreadable while the queue connector is running, loadConnectProfile returns a usage error before the socket is contacted. Consequently, a fresh pending cannot report projects_unreadable, and a newly armed next --wait cannot remain waiting for the file to be repaired, even though the running queue implements both behaviors. Resolve the existing profile's state identity without requiring a usable policy file (as loadConnectProfileForReport does, with a known-state check), and let the running connector decide eligibility.
🤖 Copilot's review of 30afa1e found one previously missed issue, in its review body: a malformed connect.json stopped next, pending and ack before they reached the running connector. Fixed in 3e744e8. The commands now find the connector through the profile's state directory and report the file's error only when no connector answers. The new test TestTheSessionQueuesCommandsReachTheConnectorPastABrokenConnectJSON fails without the fix.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The durable ledger migration and crash/restart session recovery warrant human validation because the revised abandoned-connector shutdown/start takeover sequence has not been exercised live.
The runner's socket is held to two rules: a directory only this user can
enter, and a socket file only this user can open. A second socket in the
connector's state directory should meet the same rules without copying
them, so runner.Listen and runner.Dial export what Runner.Run and Call
already did. Neither the runner's behavior nor Call's ErrNotRunning
changes.
Started with --session-queue, the connector keeps each trusted request in
its ledger as session_pending instead of printing its request line, and
stdout says only {"type":"queued","event_id":N,"recording_id":M}. A
session reads the requests when it is ready for them:
basecamp connect next [--wait] [--except <ids>] the request lines
basecamp connect pending [<id>] what is withheld, and why
basecamp connect ack <id> close one it took on
next prints, byte for byte, the line plain basecamp connect prints for the
same record, the acknowledgement boost included. Taking a line writes
nothing: a lost line is taken again, two readers get the same one, and the
ack is what closes it (discarded/handed_off, as a printed request is). A
kept request survives any number of restarts, and no plain or runner start
touches it.
next and pending go over a socket in the state directory, because only
the running connector can say what it would hand over now: nothing under
the hold, nothing a hold tagged for review, nothing while connect.json's
served projects cannot be read, nothing outside the served projects, the
run's --project or the Pings it hears, and nothing admitted under another
policy than the one it runs with. Every verdict now records
admission.Policy.Fingerprint of the policy it was made under, so someone
taken out of a Ping since is not answered. ack writes the ledger directly,
as discard does, which now also accepts a kept request.
The flag is per start, never kept, and refused with --shadow or with any
flag that starts the runner. next and pending exit 11 when no connector
runs the queue and 12 when it stopped before answering. Status and the
console show whether the queue is on, how many requests wait and are
withheld, and how old the oldest is.
This is ledger migration 17. A basecamp older than this refuses a ledger
this one has migrated, as it refuses any newer schema.
A request kept for a session was withheld as policy_changed whenever any
part of connect.json changed, so serving one more project, or editing
another project's Campfires, froze every request waiting. Its fingerprint
now covers the trust settings and the request's own project or Ping entry:
the rules its verdict turned on. Taking someone out of the Ping, off the
allowlist, or a Campfire out of the project's listening still withholds it.
… where the queue never ran
From the first code review of the session queue:
- status (styled and --json) says nothing of the queue for a profile
whose connector does not run it and that has nothing kept: no
session_queue object, no session_pending in the Queues line. Status's
SessionQueue is now nil until a request is kept or a connector answers.
- status and the console ask the running connector for counts alone (a
new "counts" call: pending, withheld, oldest kept) instead of every
request line. A call that times out or fails other than by nobody
listening is shown as unknown, never as off.
- runner.Dial says nobody listens only for a missing socket or one that
refuses the call; any other failure is returned as it is, so next and
pending exit 11 only when no connector runs. The runner's Call still
reads every failure to connect as no runner.
- The connector's stop cuts short a request still being read, so a caller
that sent half of one does not hold up the stop and the lock; a wait
read whole is still told the connector stopped.
- next with an argument is the usage error (exit 1) its help promises.
- A policy whose served projects are unknown withholds every request, as
a failed read of them does.
- The queue's read checks rows.Err before using the ids it read.
- The console's Working now says a queue connector keeps requests for
basecamp connect next; connect's help says the queued line replaces the
request line and that stdout's other lines continue.
- Tests: the request line pinned to the bytes origin/main writes, on
stdout and from next; two waits blocked on an empty queue both given
one request; process exit codes in the BATS suite.
A Claude Code session now starts the connector with --session-queue and
waits on a background `basecamp connect next --wait`, whose exit wakes it,
instead of a Monitor on stdout: Claude Code's monitors expire now, and a
re-armed one replays the file. Each request is checked with `pending
<id>` before it is acted on, acked right after its subagent starts (or
after the session's own refusal), and held in --except while the person
picks a repo. After a compaction, or in a new session, the session
settles what `pending` lists before it waits again.
The plugin can be newer than the CLI. When `basecamp connect --help`
doesn't list --session-queue, the skill keeps main's flow unchanged, in a
section of its own: the persistent Monitor, or --orchestrator without
one, and it tells the person once that an upgrade brings the queue.
- The compaction hook gives the queue's instructions only to a session
whose transcript started a --session-queue connector that answers the
queue's socket now (1s). Every other session, an older skill's
included, gets main's notice byte for byte, which a test pins.
- The runner's mapping tells the orchestrator the waiter, pending, ack,
--except and the compaction step are not its own: it never acks.
- The per-request steps still end inside the compaction cut (13,947 of
14,000 characters): the terminal rule moved, unchanged, into Rules
without exceptions, and the token-retry guidance into When the
connector stops.
- Skill drift: next, pending, ack and their flags are baselined, hidden
with the rest of connect.
- Six eval cases: arming the waiter, acking after dispatch, holding on a
repo choice, settling after a compaction, and both older-CLI paths.
…om the connector's own start line
Settles the phase 2 review of the basecamp-connect skill's switch to the
session queue: each mode's per-request rules inside the compaction cut, ids
held until their ack lands, parked work rechecked on resume and after a
restart, the waiter armed only once the connector runs, only the current
waiter's exit acted on, reconcile evidence read where reply_to points,
discard named with its profile, and main's discard refusal restored.
The compaction hook now gives the queue text only when this session's own
background connector task logged connector: running with session_queue=true
and has not ended, never from a command line. The skill evals can see
background Bash, Monitor and Agent calls, and reject an order.
…and stop only your own
The live sessions asked before restarting a killed connector, had no path
when a crashed session's queue connector still held the profile, and one
stopped its connector with a pattern that also stopped other sessions'.
A session that took over a crashed session's connector could not stop it,
and the compaction notice did not know it ran the queue; it now stops that
connector and starts its own. With the queue, a token retry is waited out
with a one-shot background wait, not a monitor that may expire.
The queue's commands refused before calling the connector, so pending could
not say what the running connector withholds and a waiter could not wait
out the repair. They now reach it by the profile's state, and say the
file's error only when no connector answers.
A request kept for a session was withheld whenever anything in the trust
section or its project's entry changed, so adding a colleague to the
allowlist or changing an agent cap held back every request waiting. The
fingerprint now covers only the people the verdict rested on (performer,
requester, and the author whose words it trusted), whether each is the
operator, an allowlisted operator, an allowed agent or in the Ping, the
trust mode, whether the project is served, and the one setting the
trigger turns on. Those people are kept with the verdict, in the same
unreleased migration, so the queue checks the same people later.
A start without --session-queue now says how many requests wait for a
session, since no other start hands them over.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The queue-recovery rule can discard unfinished requests based on progress-only replies, and the hook rejects valid profile names, omitting pending-request reconciliation instructions after compaction.
…read any profile setup accepts
A helper posts an interim reply on long work, so a reply from the agent
does not by itself mean a request was settled. After a compaction the
skill now acks only on the result or a refusal, and asks the person
otherwise. The compaction hook's start-line match now takes every profile
name setup accepts, including one starting with _ or -.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The revised takeover path sends SIGINT and starts a replacement before reconciliation but remains untested live, requiring human validation of shutdown ownership and pending-request recovery.
…ter evals
Retention now clears the people a verdict rested on, as it clears the
requester. Status and the start's warning share one queue-depth query,
and status cleans the probe error before printing it. The console asks
the queue for its counts with a short timeout, so a socket that holds
but never answers cannot stall each refresh.
The migration test now carries a record admitted before the upgrade and
hands it off after. The ack test decodes its JSON. The skill evals reject
a mixed --except list, a background setup, and a document listing without
--all; read the thread and boost lists rather than show; ask for the
reply's content; and the runner refuses a repeated session tool and no
longer fails every case on an empty reject_sequence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commandsCLI command implementationsdocsoutputOutput formatting and presentationskillsAgent skillstestsTests (unit and e2e)
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Drafted by Claude Code for review.
Why
A connector session sometimes never hears a request it should get
(card).
The basecamp-connect skill watches the connector's stdout with a Claude Code
Monitor armed
persistent: true. Claude Code no longer haspersistent, soevery watch now expires and has to be re-armed. A re-armed watch replays the
whole output file, and the session has to remember which requests it already
handled. The usual fix, a
grep -vskip list, holds the newest request backuntil the next one arrives, because the
grepClaude Code's Bash runs is anembedded ugrep whose
-vwaits for the following line. Today's skill sendsthese sessions to
--orchestratorinstead.This replaces #902, a skill-side watcher, with the connector keeping requests
until a session takes them.
What changes
Connector (opt-in).
basecamp connect -P <p> --session-queuekeeps eachtrusted request in its ledger as
session_pending, instead of printing itsrequest line. Stdout prints
{"type":"queued","event_id":N,"recording_id":M}in place of the request line; the intake and verdict lines continue as before.
Three commands read and close the queue over a socket in the profile's state
directory:
basecamp connect next [--wait] [--except <ids>]prints every eligiblerequest line, byte for byte the line plain
basecamp connectprints for thesame record.
--waitblocks until there is one. Reading writes nothing.basecamp connect pending [<id>]shows what is waiting, and what iswithheld and why.
basecamp connect ack <id>closes a request the session has taken on.A request is handed over only while the running connector would still hand
it over:
--project, or a Ping the run hearsperformer, the requester and the author whose words were trusted. That
covers whether each is the operator, allowlisted, an allowed agent or in
the Ping, plus the trust mode, whether the project is served, and the one
setting the trigger turns on. It's recorded with each verdict.
So someone removed from a Ping or the allowlist since is not answered. Adding
a colleague, changing an agent cap or serving another project holds nothing
back. A withheld request becomes eligible
again by itself when the condition clears, and stays until it is acked or
discarded (
discardnow accepts one).Without the flag, nothing changes: the stdout bytes,
statusand the runnerare as before. The flag is refused with
--shadowand with anything thatstarts the runner.
Skill. basecamp-connect checks
basecamp connect --helpfor--session-queue.With it, the session:
basecamp connect next --wait, whose exit wakes itpending <id>before acting on itpendingmode
whether another session still works from it, and otherwise takes it over
A request waiting on the person, such as a repo choice, stays unacked.
Without the flag (an older CLI), the skill does exactly what it does today:
the Monitor flow where the Monitor takes
persistent, otherwise--orchestrator. Restarts keep the mode the session started in.Hooks and the runner. The compaction notice names the waiter only when
this session's own connector started with the queue. Every other session gets
today's text, byte for byte. The orchestrator's mapping says the queue
commands are not its to run.
Compatibility
--orchestrator)--session-queueneverhands these requests over, so it logs how many wait for a session.
refuses a ledger this one has opened, as it refuses any newer schema.
After upgrading,
basecamp connect statusasks for the connector to startonce before it reads the ledger, as it does after every migration.
nextandpendingexit 0 when they answer, 1 on a usageerror, 11 when no connector for the profile runs the queue, 12 when the
connector stopped before answering, and 130/143 on a signal.
Known limits
a burst of requests, and restarts more than a minute after the request was
made, that request is dropped. Every mode already has this gap, and the
queue doesn't widen it.
their request waits does not withhold it. Revoking them in
connect.jsondoes.
at-least-once. The skill settles a repeat against its workers or the reply
thread, and asks the person when it can't tell.
Verification
bin/cigreen.Real binaries, against an isolated local bc3 (this branch and main side
by side): 23 of 24 checks pass. The 24th is
statuson a ledger an olderbuild wrote, which refuses until the connector starts once, as main does
after every migration; it passes after that start.
next --waitreturned1.18 to 2.21 s after the mention was created (median 1.33 s, 10 of 10).
Live Claude Code sessions (2.1.332, interactive), running the skill
against local bc3:
/compact, then the connector killedpending: replied to once, ackedThose runs found three gaps, now fixed in the skill: it asked before
restarting a killed connector; it had no path for a connector a crashed
session left running; and one session stopped its connector with a
pattern match that also stopped other sessions' connectors. A second live
run (on 99ccc7b) checked each fix, 2 of 2 each: a killed connector was
restarted without asking, a crashed session's connector was taken over
after one question with no second connector started, and a stop left a
look-alike connector running. Since then, after review, a takeover stops
the left-behind connector and starts the session's own, so the session
can stop it later; that step was not run live.
--orchestrator, live against local bc3, this branch beside main:Skill eval cases were added; their graders were checked against
hand-written traces (8 of 8 correct pass, 54 of 54 wrong fail). The model
run is this PR's Skill Evals job.