Repository navigation
Daemon: tell a resting bot when a background command no wait collected ends - #625
Conversation
…d ends
A bot that started a command with background=true and ended its turn
never heard how it ended unless it called wait. Now the daemon tells it,
once the bot rests: at the end of the turn that was running when the
command ended, or at once when it ends while the bot rests. It submits
one steer from origin `background` whose words are JSON naming each
handle and how it ended, without the output, which wait still reads:
{"finished":{"proc:7":{"exit_code":0,"success":true,"wall_time_ms":5012}}}
Schema 77: processes.told holds the turn that told it (0 for one the
bot saw end, and for everything that ended before the upgrade). A
command a wait delivered is never told, nor a terminal whose end a
write_stdin returned. Commands a restart or the pull cord ended are
told once the daemon is back. Nothing is said mid-turn, so no running
command is lifted and no parked wait is woken. No protocol bump.
Sonny shows the turn as from a background command, and the lookout
treats it as a trigger's fire: only how it ends is news to a lead.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHSmyxToLa26Je2pfo
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b3322f1c8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- `quiet_background` (setting and `--quiet-background`, protocol 46): a bot whose client collects results itself is never told. A daemon default must be one a caller can change per bot. - The note is not held to the pending-submission bounds: the commands that ended bound it, and a refusal left an idle bot untold. - Finding what to tell reads the partial index from the processes side (INDEXED BY processes_untold, CROSS JOIN turns), never a bot's history; a unit test checks the plan. - A terminal whose start failed is its end, and the call said so: it is never told later. - Retention keeps the turns whose commands a note still to run tells of, so the wait the note invites finds their results. - Wording: "at rest" becomes "no turn of yours is running", in the shell description and the docs. - sonny/FEATURES.md row for the note in Sonny. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGHSmyxToLa26Je2pfo
The shell description keeps #621's day-long background cap and adds the note's sentence after "collect its result later with wait.". Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGHSmyxToLa26Je2pfo
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a55781a1d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…t's context The terminal's end is now marked seen in the same store op that records its tool result, so a crash between the two can't tell the bot twice. A note of many ended commands splits into turns of at most an eighth of the bot's context, and a long detail is cut at 96 bytes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGHSmyxToLa26Je2pfo
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2de01982d8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The sentence telling a bot its background command's end comes as a message is cut from about 230 bytes to about 150: every request of every bot with shell carries it. A paced-compaction test pinned how many copies followed the retry, which depends on the tools' own bytes; it now pins the paced copy and its retry only. The restart test in test_wait now lets Dave hear of the fresh command's end before its next submit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGHSmyxToLa26Je2pfo
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c9e6153ce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The note's query now reads only the fields that say how each command ended, never its output, and at most as many as could fit its room. The note and the marks of the commands it tells commit together under a savepoint, also at startup where no store job's transaction holds them. Retention keeps a turn whose ended commands no note has told yet, so a batch left for the next note still finds its results. Records the matched Perf screen. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGHSmyxToLa26Je2pfo
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89705bfdaf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…s at its batch processes gains bot, written from the command's turn, and processes_untold indexes (bot, id). A note's query reads the bot's untold commands in order from the index and stops at its LIMIT: no join to turns, no sort, and no other bot's commands passed over. A test counts the query's VM steps with 10 and 10,000 untold commands per bot. Retention's check for untold commands goes through processes_turn. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGHSmyxToLa26Je2pfo
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGG5PKzf3A9NDuvu9Xu
Why
This is the third idea from DeepSeek Harness's super-agent design, which George approved on 11-01. Today, when a bot runs
shellwithbackground=trueand then rests, the command's end goes nowhere. The result waits in the store until something callswaiton the handle. A lead that started a 20-minute build and ended its turn never finds out the build failed. Claude Code tells its model when a background shell ends. Codex leaves it to the model to poll. With #621 letting background commands run for up to a day, the gap gets wider.What changes (the concrete edits)
Store, schema 76 → 77; protocol 45 → 46 (
src/store/db.rs,client/src/lib.rs). This takes schema 77, which project memory had reserved, and protocol 46 for the new bot setting.processesgainstold INTEGER. It holds the turn that told the bot, or0when there is nothing to tell. The migration setstold = 0on every command that had already ended, so an upgrade tells nobody about old work.processesgainsbot TEXT, whichprocess_startwrites from the command's turn. The migration fills it for commands still running, the only ones whose end can still be told.processes_untold ON processes(bot,id) WHERE told IS NULL AND delivered IS NULL AND status<>'running'.Database::tell_finished(bot):quiet_backgroundhas its ended commands markedtold = 0and is never told.UNTOLD:processes INDEXED BY processes_untold WHERE bot=?1 … ORDER BY id LIMIT ?2). It never walks a bot's history or other bots' commands. It reads only the fields that say how each command ended, never the output, and at most as many as the note has room for. A unit test checks the plan (no turns, no sort) and counts VM steps, which are the same with 10 or 10,000 untold commands.delivery: steer,origin: "background", request idbackground-<first id>. The words are JSON only, for example{"finished":{"proc:7":{"exit_code":0,"success":true,"wall_time_ms":5012}}}. The fields are those ofended_as:exit_code,success,timed_out,signal,wall_time_ms, anderror/detail. No output is included;waiton the handle reads it.context_bytes, and always at least one entry. A longdetailis cut at 96 bytes. Commands that don't fit stay untold, and the note's ownfinish()tells the next batch.told = <turn>.toldmarks commit together under a savepoint, at startup too.--max-processescaps those.tell_finishedruns afterfinish()commits, for a command that ended while a turn was running. It runs afterprocess_finish, for a command that ends while no turn of the bot's is running. It also runs atopen, for commands that a restart or the pull cord ended.Database::saw_end(id)setstold = 0on a terminal whose end the bot already saw in awrite_stdinor start result.toldturn queued, ready or running), and a turn whose ended commands no note has told yet. That way the wait the note invites finds the results.quiet_background(CLI--quiet-background), off by default. A client that collects results itself sets it. src/AGENTS.md requires a daemon default to be changeable per bot.pub const BACKGROUND_ORIGIN = "background", exported fromsrc/store.rs.Server
src/server/turn.rs:collect()callstell_finishedinside the existingprocess_finishstore op. When the told turn is ready, it callshandles.turn_ready().seen()helper finds the terminal whose output carriesexit_code.saw_endruns inside the sametool_finishop that records the result, so the two commit together. This covers the start, a poll,write_stdin, and the parked poll's resume. A terminal whose start failed is marked seen too.src/server/handles.rs: aready: Notifywithturn_ready()andreadied().src/server/mod.rs: one moreselect!arm,() = service.handles.readied() => service.ready_hint = true, so the run loop dispatches the told turn.Tool text (
src/tools.rs, shell description). After "collect its result later with wait." it adds:It is about 150 bytes, kept short because every request of every bot with shell carries it.
Sonny
sonny/src/transcript.rsshows the turn as "From a background command".sonny/src/lookout/mod.rsauthor()treats originbackgroundlike a trigger's fire, so only how the turn ends is news to a lead.sonny/FEATURES.md: a new "Background command ends" row.Docs:
docs/RUST_PROTOTYPE.md(Deferred tool results, and the settings table),docs/CLI.md,docs/NEXT.mditem 39 ("done in part"), anddocs/DAEMON_MEASUREMENTS.md. Getting the result in the call's place mid-turn stays an open item.Why it is built this way
waitthat is about to collect the result anyway. Claude Code accepts that interruption, but we don't need it, because a turn that wants the result sooner already haswait.toldis set in the same transaction that queues the turn. A command collected bywait, or a terminal whose end the bot saw, is never told.Coordination with #621
#621 raises the background
timeout_mscap to a day and edits the same shell description insrc/tools.rs. The two changes fit together: a day-long build's end now reaches its bot. This branch has merged main and carries #621's text with this sentence added.Daemon fast and light
tell_finishedruns inside store jobs that already exist (finish,process_finish). It is one indexed read of a partial index that is empty in the common case, and it stops at its batch.saw_endadds no store op. It is one more UPDATE inside the existingtool_finishop, and only when a terminal's end is seen.Notifyarm. Nothing new is kept per bot in memory.Tests
cargo test --workspaceandcargo clippy --workspace --all-targets -D warningsare clean.tests/store_contract.rs:a_background_command_no_wait_collected_is_told_once_its_bot_restscovers a command told once at the turn's end, one told at once while the bot rests (a failure is told the same way), and waited or seen commands never told.a_bot_whose_client_collects_results_itself_is_never_told,submissions_filling_the_pending_bounds_hold_back_no_note,retention_keeps_what_a_note_still_to_run_tells_of,notes_of_many_ended_commands_each_fit_the_bots_context,retention_keeps_ended_commands_a_later_note_is_still_to_tell.schema_76_tells_no_bot_of_commands_that_ended_beforecovers the upgrade: a command that ended before is never told, and one the restart lost is told asprocess_lost.tests/store_payloads.rs: the reopen test now runs the told turn before pruning.AGENT_TEST_RUNTIME=1):test_a_background_command_no_wait_collected_is_told_once_the_bot_rests. It checks the steer frombackground, the JSON with exit code 3 and no stdout, thatwaitstill readsdone\n, and that there is exactly one extra turn.tests/test_wait.py: the restart test lets Dave hear about the fresh command's end before his next submit.tests/test_compaction.py: the paced-copy test pinned how many copies came after the retry, a number that depends on the tools' own bytes. It now pins only the paced copy and its retry.psutilis missing for two bench imports, andbwrapis missing for one trigger start test, twotest_servedtests and threetest_acptests.🤖 Generated with Claude Code