Repository navigation
Open
Labels
Description
Goal
Agents wait on long commands with t3_background_wait instead of run_project_action_and_resume. The thread stays in Working while the command runs and is woken once with the result.
The scripts the Actions wrap stay. Saved Project Actions stay as a user feature. Only the agent-facing run-and-resume path is retired, and only if the comparison below favours it.
Why
- Standing context: the Action guidance and tools cost roughly 1,500 to 2,000 tokens on every model request in every thread. The background-wait guidance costs roughly 80 to 180.
- Own checkout: a delegated child runs the command in its own checkout, so the parent no longer has to launch Actions on its behalf.
- Who is affected: in 30 days of one environment's use, agents launched 1,388 Action runs, 84% of them from Codex threads. Codex has no background-wait hold today, which is why the work starts with the Codex port.
Decisions
- Flag: one environment-owned LastCode server setting, default off, read at a single seam. It gates the Codex hold and its instruction text.
- Server marking: the server marks commands started through the wrapper as awaited, so reliability does not depend on the agent calling the tool.
- One wrapper for the five LastCode scripts (prepare dependencies, prepare checkpoint dependencies, quick CI, wait for checkpoint, build local package). A fast finish returns in the same call. A slower one prints an "end your turn" line after about 20 seconds.
- Claude background limit: raised from the 30-minute default to the 2-hour maximum under the flag.
- Comparison: reliability through
evals/mcp-tool-useat 20 samples per case per model; cost through instrumented development runs, with raw tokens as the primary number and standing tokens across all turns included. Cases are built on Claude first; the decision uses the Codex numbers. Cheapest model first, then each higher effort. - Guidance:
AGENTS.mdkeeps the Action guidance until default-on. One PR flips the default, swaps the guidance, and drops the parent-mediated Action rules for children.
Steps
- Import the upstream Codex port: https://redirect.github.com/lastobelus/lastCode/pull/791 (merged Nov 22 PT)
- Flag in the same PR:
lastcodeBackgroundWaitEnabled, default off - Convergence tracking: Converge the imported Codex background-wait hold with upstream #823, plus a drift check in the checkpoint flow
- Wrapper and server marking:
./scripts/lc-run, merged in feat(lastcode): wait for wrapped commands in the background #831 (hold regression from fix(codex): port explicit background waits #791 fixed in fix(codex): preserve background waits when a turn ends #832) - Claude background limit under the flag (merged in feat(lastcode): wait for wrapped commands in the background #831; also raises the foreground default)
- Eval: six cases (the five scripts plus a standing-watch stand-in)
- Break tests in a development instance with the flag on (list below; results in the comments)
- Default-on PR, once the criteria below hold
Break tests
- A marked wait holds the thread in Working and wakes it with the exit code.
- A delegated Codex child waits, and its parent gets exactly one result.
- A wait longer than 30 minutes survives the idle session release.
- The server restarts during a wait.
- Stop during a wait, including a Stop that fails.
- A user message arrives during the wait, and the command finishes during that turn.
- Archive and automatic settlement during a wait.
- A made-up id, a mark after the command exited, and two commands with one marked.
- A command that never exits, cleared with
waiting=false.
Still unverified, and settled by the first test runs: whether a foreground Claude command moves to the background when it passes its timeout, and whether a waiting Codex session is exempt from the 30-minute idle release.
Default-on criteria
- Reliability: on the six eval cases, the wait is used correctly at least as often as the Action baseline, with zero polls after the "end your turn" line, on every model and effort tested.
- Cost: fewer raw tokens per task than the Action baseline.
- Break tests: all nine pass on Codex and Claude.
- Upstream: the port is re-checked against upstream's head at that time (Converge the imported Codex background-wait hold with upstream #823).
- Soak: seven days of real use with the flag on, with no thread stuck in Working and none finished early.
Follow-ups after default-on
These must not be dropped.
- Delete the run-and-resume code in one PR, after 14 days in which usage data shows no agent-launched Action in any project: the three MCP tools,
apps/server/src/actionResume, the guidance sections, and the child-ownership rollout code. - Migrate other projects' saved Actions that agents still launch, before the deletion.
- Close the Action phases of Delegated tasks finish before resumable Action continuations complete #482 when the deletion lands. Acceptance work on them stops now; the pull-request watch phase is unaffected.
- Review the open Action bugs when the deletion lands, and close those it makes moot: fix: resumable Actions ignore project script overrides #219, Eligible resumable Action fails to launch without actionable diagnostics #404, Resumable Project Action times out waiting for shell readiness despite prompt output #628, bug(actions): notify waiting threads when a resumable Action loses its process #681, Preserve diagnostics when a resumable Action fails without captured output #739.
- Multi-stage flows: decide whether the wrapper should carry staged scripts that tell the agent to call again. Parked until the wrapper exists.
- Child supervision: Orchestrators poll delegated children instead of waiting for their result #822. Separate, not gating.
Activity
feat(lastcode): make Codex background waits opt-in
lastobelus commentedon Nov 22, 2026
Break-test notes, Nov 22 PT (dev instance, flag on, draft PR head
9d769af)Claude, foreground timeout: settled. A foreground Bash command that passes its tool timeout is moved to the background and the tool result gives its task ID. On Haiku the agent then marked it with
t3_background_wait; the thread showed an awaitedcommandtask and statuswaiting, and it was woken once with exit code 3. So on Claude the wrapper can be started as an ordinary foreground command and does not have to be launched in the background from the start. Note that Claude Code refuses a bare foregroundsleep N, and Haiku declined a disguised one, so test commands must look like real work.Codex, tool not reachable: open, fix in progress. In four real
gpt-6-lunasessions the instruction sentence was delivered but the agent could not findt3_background_wait, including when told to search for it. The tool is hidden from threads whose provider does not declaresupportsBackgroundWait, and the Codex adapter does not declare it with the flag on. The thread went tocompletedwith an unawaited task and was woken by the ordinary background-command continuation, so the hold never engaged. The mcp-tool-use eval did not catch this because its harness lists the tool directly.Still to measure after the fix: whether Codex finds the tool from the instruction sentence alone, given that it is one of Codex's deferred tools.
fix(lastcode): expose opted-in Codex background waits
lastobelus commentedon Nov 22, 2026
Break-test results, Nov 22 PT (dev instance, flag on, draft PR head
efba1f0, Codex ongpt-6-luna, Claude on Haiku as reference)The visibility gap from the earlier note is fixed: the tool is now listed to Codex threads when the flag is on.
waiting, taskawaited, one wake.t3_thread_interruptreturnsno_active_runand the thread stayswaiting. Same on Claude. The Stop button in the client was not tested.invalid_requestand do not hold. With two commands, the thread holds on the marked one and the unmarked one wakes it separately.waiting=falseAgents do not mark the wait on their own. With the instruction sentence in place, Codex Luna handled a four-minute command by polling every 30 seconds in 3 of 3 runs: 9 model requests of about 35,000 input tokens each, in one turn, and no call to the tool. When the prompt named the tool, it used it correctly every time. This supports doing the marking on the server and having the wrapper tell the agent to end its turn.
Design inputs for the wrapper: a restart reruns the command, so wrapped commands must be safe to run twice; and a command of about a minute is cheapest left in the foreground (3 requests, one turn).
feat(lastcode): make Codex background waits opt-in
fix(lastcode): expose opted-in Codex background waits
lastobelus commentedon Nov 23, 2026
Break-test update, Nov 22 PT (draft PR head
6b3e6e6)waitingfor the length of the child's command and received exactly one completed result, carrying the exit code. The cause was that the wake turn belonged to no delegated task; the fix is a separate commit.killedstatus. This confirms the need to raise the limit under the flag.All nine break tests have now run on Codex. Open observations, same on Claude and so not defects of the port: the agent-facing interrupt tool does not stop a waiting thread, and a server restart reruns the command.
fix(codex): deliver awaited command results to the delegated task
refactor(lastcode): share the background-wait setting across providers
lastobelus commentedon Nov 23, 2026
Wrapper and server marking: live results, Nov 22 PT
Branch
lastcode/background-wait-script-wrapper(no pull request yet), flag on, dev instance. Agents were told only "Run./scripts/lc-run ...and tell me the result", against a stand-in with the same command line and output shape. Codex ongpt-6-luna, Claude on Haiku.Open design point: Claude's foreground default. Claude has no separate setting for the background limit; the limit follows the foreground default once that exceeds 30 minutes. Raising it to two hours means every ordinary foreground command on Claude can now block a turn for up to two hours where it used to be moved to the background after two minutes. Wrapped commands benefit (one turn, no wake); a hung unrelated command does not.
Not live-tested: the flag-off path (covered by unit tests), Cursor and OpenCode (manual marking only, outside this rollout), and the real scripts behind the wrapper (the stand-in exercised the interface, not the work).
feat(lastcode): make Codex background waits opt-in
fix(lastcode): expose opted-in Codex background waits
fix(codex): deliver awaited command results to the delegated task
55 remaining items
fix(lastcode): keep background-wait guidance within the context budget
fix(lastcode): align background-wait guidance and flag results lost o…
lastobelus commentedon Nov 29, 2026
Body-review fixes merged; soak starts with the next installed build.
96e964745ffdceaea116c6ec9ffb2a05e063f360on Nov 28 2026, 6:26 PM PT. It closes the review of the eight landed PRs as one body: 19 of 28 findings fixed, two fixed in part, the rest recorded in the previous comment.lastcodeBackgroundWaitEnabledtakes its default (on) as soon as a build that contains the default-on change is installed. That install is the soak start, and the seven days count from it. The start time will be recorded here.lastobelus commentedon Nov 29, 2026
Soak started: Nov 29 2026, 1:30 PM PT.
v0.1.14-nightly.20261129.5425is installed on every machine in use (first install at 1:25 PM PT, last at 1:30 PM PT). It carries the default-on change and the body-review fixes from fix(lastcode): align background-wait guidance and flag results lost on restart #884; the wrapper, the instruction text and the restart recovery in that tag are identical to96e964745ffdceaea116c6ec9ffb2a05e063f360.lastcodeBackgroundWaitEnabled, so each runs the default: on. Agent sessions started on this build no longer list the Action launch tools.lastobelus commentedon Nov 29, 2026
Claude check of the changed wording: 48 real Claude threads on the installed build (checkpoint
v0.1.14-nightly.20261129.5425, setting on by default, Nov 29 2026 PT). Haiku 5.5 and Opus 5.5 at medium effort, three samples per case, each a fresh thread in a temporary project. This covers the wording from the re-port, default-on and #884, which had been evaluated on Codex only.AGENTS.mdand wrapper, six wrapper casesAGENTS.mdstill says to launch the saved Actionrun_in_background)t3_background_waitHolds up. No polling in any of the 48. Results were correct in 45. Token cost of the six wrapper cases is in line with the earlier 20-sample baseline. The single Haiku miss is the known Quick CI pattern (it reran the check to capture output; the baseline had 16 of 18 there).
Gap 1: an old checkout stalls a delegated Opus child. The old
AGENTS.mdtells a delegated child to hand a Project Action to its parent and not to run the script itself. The build's notice ("Ignore project instructions to launch Actions. Run the command (or./scripts/lc-run) in the shell.") lost to that rule in two of three Opus samples: the agent ran nothing and asked its parent to launch the Action withrun_project_action_and_resume, which no thread can do on this build. One of the two looked for the tool, found it missing, and still handed off. Haiku ran the script directly every time. Effect: a stall the parent has to notice and resolve by running the command; no wrong result. It affects only child threads in checkouts cut before the guidance changed.Gap 2: the registered-wake sentence cannot apply to an explicitly backgrounded command. At these durations Claude runs the wrapper in the foreground (as it did in the baseline), so the sentence "If
lc-runreports a registered wake, end the turn" is not exercised in normal use. When the shell tool is told to background the command, it returns before any output, so the agent has not seen the wrapper's message when it decides what to do. Opus then follows the general rule and marks the task by hand (one tool lookup plus onet3_background_wait); Haiku ends the turn. Both get the right result from the completion wake. The extra call is harmless overhead. A backgrounded wait costs about three times the tokens of the same wait in the foreground on Claude (roughly 350k against 135k on Haiku, 480k against 135k on Opus), because the result arrives in a second turn.Not covered: other efforts, Sonnet, commands longer than the shell limit, and restart during a wait.
fix(lastcode): spell out the wrapper wait boundary
fix(lastcode): require literal wrapper arguments in wait guidance
test(lastcode): require Claude to end the wrapper turn immediately
fix(lastcode): make the manual wait instruction explicit
fix(lastcode): clarify disabled Action fallback and Claude wrapper wa…
test(evals): bring the background-wait comparison harness onto main (#…
lastobelus commentedon Nov 29, 2026
Two follow-ups from the Claude check are merged (Nov 29 2026 PT).
lc-runcommand, even before any output. Neither string has been tested on a live model yet: the installed build still serves the old text. The two failed cases will be re-run as real Claude threads once a build with fix(lastcode): clarify disabled Action fallback and Claude wrapper waits #904 is installed, and the result posted here.evals/background-wait/, on main, repaired to run there. The evidence for criteria 1 and 2 and the Claude check can now be re-run from main.Soak unchanged: started Nov 29, 1:30 PM PT; ends Dec 6, 1:30 PM PT.
lastobelus commentedon Nov 30, 2026
The background-wait replacement is default-on and the migration remains in its recorded soak. This issue stays open for the seven-day soak (scheduled to end December 6, 2026 at 1:30 PM PT if the criteria continue to hold), the two live Claude retests on a build with the wording fixes, and the separate 14-day no-launch evidence before deleting the agent run-and-resume path. Keep the planned Action bug review with that deletion.
Delegated PR-watch ownership is separate. Shell background waits replace agent-launched Actions.
watch_pull_requeststill owns PR-event delivery and the delegated task continuation. The rollout-guidance cleanup for that path is being handled separately.fix(agents): use live capability for delegated PR watches (#913)
lastobelus commentedon Dec 1, 2026
Claude re-check of the wording fix (Dec 1 2026, PT)
The build that serves the wording from #904 is installed, so the two cases that misbehaved on Nov 29 were re-run: 12 real Claude threads in temporary projects, 3 per case on Opus 5.5 and Haiku 5.5 at medium effort, same prompts, fixtures and rubrics as Nov 29. Harness:
evals/background-wait/on main.wait-checkpoint)t3_background_waitprepare)Background wait: fixed. Opus now ends the turn right after the shell backgrounds the wrapper, citing the new sentence, and reports the delivered result in the next turn. Mean raw tokens for that case on Opus fell from about 481k to about 344k, level with Haiku. No polls in any sample.
Old-checkout notice: not fixed on Opus. The new notice ("No agent can launch Project Actions, even your parent. Run the Action's shell command in this checkout.") is served, and one Haiku sample paraphrased it while running the command. Two of three Opus samples still followed the old AGENTS.md rule that a delegated child hands resumable Actions to its parent: they ran nothing, returned a handoff request, and never mentioned the notice in their reasoning. One of the two also searched for the launch tools, found none, and still handed off. The passing Opus sample checked its own thread, decided it was not a delegated child, and then ran
./scripts/lc-run prepare.So the failure is specific to: Opus, as a thread started by another agent, in a checkout whose AGENTS.md predates the switch. Its cost is one round trip to the parent, not a lost result. It does not occur with the current AGENTS.md (Nov 29: 18 of 18 on Opus across the six cases).
Not covered, as before: other effort levels, Sonnet, commands longer than the shell limit, and a restart during a wait.