Skip to content

Retire agent run-and-resume for Project Actions in favour of background waits #824

Open

Description

@lastobelus

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-use at 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.md keeps the Action guidance until default-on. One PR flips the default, swaps the guidance, and drops the parent-mediated Action rules for children.

Steps

Break tests

  1. A marked wait holds the thread in Working and wakes it with the exit code.
  2. A delegated Codex child waits, and its parent gets exactly one result.
  3. A wait longer than 30 minutes survives the idle session release.
  4. The server restarts during a wait.
  5. Stop during a wait, including a Stop that fails.
  6. A user message arrives during the wait, and the command finishes during that turn.
  7. Archive and automatic settlement during a wait.
  8. A made-up id, a mark after the command exited, and two commands with one marked.
  9. 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

  1. 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.
  2. Cost: fewer raw tokens per task than the Action baseline.
  3. Break tests: all nine pass on Codex and Claude.
  4. Upstream: the port is re-checked against upstream's head at that time (Converge the imported Codex background-wait hold with upstream #823).
  5. 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.

Activity

  1. added
    enhancement
    important
    on Nov 22, 2026
  2. lastobelus commented on Nov 22, 2026

    @lastobelus
    OwnerAuthor

    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 awaited command task and status waiting, 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 foreground sleep 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-luna sessions the instruction sentence was delivered but the agent could not find t3_background_wait, including when told to search for it. The tool is hidden from threads whose provider does not declare supportsBackgroundWait, and the Codex adapter does not declare it with the flag on. The thread went to completed with 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.

  3. lastobelus commented on Nov 22, 2026

    @lastobelus
    OwnerAuthor

    Break-test results, Nov 22 PT (dev instance, flag on, draft PR head efba1f0, Codex on gpt-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.

    # Test Codex Notes
    1 Marked wait holds and wakes with the exit code pass Status waiting, task awaited, one wake.
    2 Delegated child, parent gets exactly one result fail The parent receives the child's interim "I'm waiting" message as the completed task result and is never told the exit code. Claude passes. Fix in progress.
    3 Wait longer than 30 minutes running
    4 Server restart during a wait not stuck The command dies with the old server. The thread resumes by itself and reruns the command. Same on Claude.
    5 Stop during a wait unexpected t3_thread_interrupt returns no_active_run and the thread stays waiting. Same on Claude. The Stop button in the client was not tested.
    6 User message during a wait pass Reply, hold kept, result delivered once.
    7 Archive, and explicit settle, during a wait pass Archive with stop ends the command. Settle drops the hold and the thread is not woken later. Automatic settlement could not be triggered on demand.
    8 Made-up id; finished command's id; two commands with one marked pass Bad ids return invalid_request and do not hold. With two commands, the thread holds on the marked one and the unmarked one wakes it separately.
    9 Never-exiting command cleared with waiting=false pass Hold clears; the process keeps running, as documented.

    Agents 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).

  4. lastobelus commented on Nov 23, 2026

    @lastobelus
    OwnerAuthor

    Break-test update, Nov 22 PT (draft PR head 6b3e6e6)

    • Test 2, delegated Codex child: now passes live. The parent stayed waiting for 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.
    • Test 3, wait longer than 30 minutes: passes on Codex. A 36-minute marked wait held past the 30-minute idle release and woke once with the result.
    • Claude's 30-minute background default is real inside LastCode. The same 36-minute command, started as a Claude background command with the default timeout, was killed at 30 minutes (step 897 of 1080) and the agent was woken with a killed status. 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.

  5. lastobelus commented on Nov 23, 2026

    @lastobelus
    OwnerAuthor

    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 on gpt-6-luna, Claude on Haiku.

    Check Result
    Codex, 4-minute wrapped command, 3 samples Ended the turn within 40 seconds, server-marked wait, one wake. 3 model requests each; the same command unwrapped took 9.
    Codex, fast wrapped command Result in the same call, 2 requests.
    Codex, 36-minute wrapped command Held the whole time, one wake with the result.
    Claude, 4-minute and 36-minute wrapped commands Ran in the foreground and blocked inside one turn; the 36-minute run finished normally, past the old 30-minute limit.
    Claude, wrapped command with a 20-second foreground timeout Moved to the background, the wrapper's instruction line was in the tool result, server-marked wait without the agent calling the tool, one wake.
    Delegated Codex child given only "run the wrapper and report" Parent received exactly one result, with the exit code.
    Command that merely prints the wrapper's name Not marked.
    Server restart during a wrapped command, both providers The command died, the thread reran the wrapper, the rerun was marked again, and it finished. Nothing stuck.

    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).

  6. 55 remaining items

  7. lastobelus commented on Nov 29, 2026

    @lastobelus
    OwnerAuthor

    Body-review fixes merged; soak starts with the next installed build.

  8. lastobelus commented on Nov 29, 2026

    @lastobelus
    OwnerAuthor

    Soak started: Nov 29 2026, 1:30 PM PT.

    • Checkpoint v0.1.14-nightly.20261129.5425 is 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 to 96e964745ffdceaea116c6ec9ffb2a05e063f360.
    • No machine sets lastcodeBackgroundWaitEnabled, so each runs the default: on. Agent sessions started on this build no longer list the Action launch tools.
    • The seven days end Dec 6 2026, 1:30 PM PT, provided the setting stays on and no agent has to fall back to launching an Action.
    • The Claude wording check starts now, as real threads on this build. Its result will be posted here.
  9. lastobelus commented on Nov 29, 2026

    @lastobelus
    OwnerAuthor

    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.

    What was tested Haiku 5.5 Opus 5.5
    Current AGENTS.md and wrapper, six wrapper cases 17 of 18 18 of 18
    Checkout whose AGENTS.md still says to launch the saved Action 3 of 3 1 of 3
    Wrapper forced into the background (run_in_background) 3 of 3 end the turn at once 3 of 3 correct, each after an extra t3_background_wait

    Holds 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.md tells 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 with run_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-run reports 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 one t3_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.

  10. lastobelus commented on Nov 29, 2026

    @lastobelus
    OwnerAuthor

    Two follow-ups from the Claude check are merged (Nov 29 2026 PT).

    Soak unchanged: started Nov 29, 1:30 PM PT; ends Dec 6, 1:30 PM PT.

  11. lastobelus commented on Nov 30, 2026

    @lastobelus
    OwnerAuthor

    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_request still owns PR-event delivery and the delegated task continuation. The rollout-guidance cleanup for that path is being handled separately.

  12. lastobelus commented on Dec 1, 2026

    @lastobelus
    OwnerAuthor

    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.

    Case Model Nov 29 Dec 1
    Wrapper forced into the background (wait-checkpoint) Opus 3 of 3 right result, all 3 with a redundant ToolSearch + t3_background_wait 3 of 3 pass, no extra call
    Haiku 3 of 3 pass 3 of 3 pass
    Checkout whose AGENTS.md still says "launch the saved Action" (prepare) Opus 1 of 3 1 of 3
    Haiku 3 of 3 3 of 3

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementimportant

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions