Skip to content

fix(exec): explain what a running background result proves and warn against unpolled promises - #120414

Closed
martinfrancois wants to merge 1 commit into
openclaw:mainfrom
martinfrancois:fix/exec-running-state-wording
Closed

martinfrancois wants to merge 1 commit into
openclaw:mainfrom
martinfrancois:fix/exec-running-state-wording

Conversation

@martinfrancois

@martinfrancois martinfrancois commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

On 2026-04-27 I asked my OpenClaw agent over Telegram to fix two failing evals in one of my repositories. It handed the work to a coding agent running in the background, and six seconds after the exec tool reported the session as running it told me the work had started and promised to report back. It never did, twice. The exchange, condensed (times UTC):

13:13  me     Can you use the good-oss-citizen tile to get the two failing evals to 100%?

13:14  agent  I set up a fresh worktree and I'm handing the implementation to a
              coding agent now.

13:15:14 exec Command still running (session crisp-breeze, pid 3469063).
              Use process (list/poll/log/write/kill/clear/remove) for follow-up.

13:15:20 agent Started. Worktree, branch, and session are set up.
              I'll report back when it has a commit and gate results, or if it blocks.

13:23  (the coding agent finishes with a local commit; the agent is woken with the
        completion event but that turn is told user delivery is disabled, so I am
        not notified)

13:26  me     Is it still going

13:26  agent  No, the coding agent finished and exited cleanly. There is already a
              local commit. I'm not calling it done yet because I still need to verify.

13:26  (no tool call and no message follow; the agent is idle until my next question)

13:27  me     I'm confused, are you still doing something

13:27  agent  Sorry, yes, that was confusing. The coding agent is no longer running.
              I'm doing the final verification myself now.

13:27  (it amends the commit and starts the gates as another background command)

13:27:55 exec Command still running (session mild-rook, pid 3477273).
              Use process (list/poll/log/write/kill/clear/remove) for follow-up.

13:27:55 agent Yes, but only final verification now. Gates are running now.
              I'll report DONE/BLOCKED when those gates finish.

13:28  (the gates finish; the agent is woken again and again told that user
        delivery is disabled; it writes a "successfully completed" message inside
        that turn, and I am not notified)

13:33  me     Are the gates still running.

13:33  agent  No. Gates finished successfully.

13:33  me     Why didn't you notify me then?

13:33  agent  Because the completion event explicitly said "user delivery is disabled"
              and told me to handle it internally. I should have stayed quiet there.
              But after that, I also failed to proactively send a normal concise DONE
              update once I confirmed the gates had finished. That's on me. I made
              you ask twice.

What the transcript shows

  • A running result means a process was spawned and was alive when the result was written. "Started." was true.
  • What the agent could not know from that result: whether the command was making progress, was waiting for input, or had since exited or failed.
  • The harm was not a false start. It was a promise to report back that could not be kept, twice.
  • When a background command finishes, the agent is woken with a completion event by default (tools.exec.notifyOnExit, background process docs), but that turn may not be allowed to message the user. That is decided when the turn runs, from the heartbeat delivery route and visibility settings (heartbeat docs, "Delivery behavior"). On 2026-04-27 the agent was woken both times and told both times that delivery was disabled.
  • At the moment the running result is written, the exec tool knows whether a completion event will be queued, but not whether that later turn will be allowed to message the user.

That leaves two ways to stop an agent from promising a report it cannot deliver:

  1. Tell the agent, in the running result itself, what "running" does and does not mean, and that the completion turn may not be allowed to reach the user, so a promise of updates has to be backed by the agent polling the session to the end and reporting itself.
  2. Resolve at exec time whether the completion turn will be allowed to deliver, and put that answer into the result.

This PR takes the first. It is one sentence group in one producer, it is true in every configuration, and it needs no knowledge of delivery routing inside the exec tool. The second would couple the exec tool to heartbeat delivery resolution and still could not promise delivery, because the route can change before the command exits.

Why This Change Was Made

The shared running result from createExecTool currently reads:

Command still running (session ..., pid ...). Use process (...) for follow-up.

#161780 (merged 2026-10-02) split the follow-up route into three notification modes. This PR adds the same first sentences to all three, then folds the delivery caveat into each mode's own wake wording:

Command still running (session ..., pid ...). Running means the process was started and was alive when this result was written; it says nothing about progress, waiting for input, or a later exit or failure. Do not report progress from this result alone. <mode-specific follow-up>

With completion waking on every exit (notifyOnExitEmptySuccess=true, the default for chat channels), the follow-up reads:

Completion will wake this conversation automatically. The completion turn may not be allowed to message the user, so if only waiting remains, report that the job is running without promising to report back and end this turn; do not keep polling. Use process (...) for follow-up.

With silent empty successes (notifyOnExitEmptySuccess=false):

Use process (...) for follow-up. Completion wakes this conversation on output or failure; empty successful jobs are silent (tools.exec.notifyOnExitEmptySuccess=false). Arrange continuation or collect the result before ending the turn if empty success matters. The completion turn may not be allowed to message the user, so do not promise the user updates unless you poll this session until it finishes and report the outcome yourself.

With tools.exec.notifyOnExit=false:

Use process (...) for follow-up. Automatic completion wake is disabled (tools.exec.notifyOnExit=false). If the task needs this result, use poll with a timeout to collect it before ending the turn, unless another continuation is already arranged. Without a completion wake, do not promise the user updates unless you poll this session until it finishes and report the outcome yourself.

Each clause is checked against the code. "The completion turn may not be allowed to message the user" holds whenever a wake is queued: buildExecEventPrompt in src/infra/heartbeat-events-filter.ts still tells the completion turn "user delivery is disabled for this run" when canRelayToUser is false, and heartbeat-runner-execution.ts computes that at wake time from heartbeat visibility (showAlerts) and the delivery route. In the every-exit mode #161780 tells the agent to end the turn and stop polling, so that mode drops the promise outright ("without promising to report back") instead of offering polling as the way to back one. The other two modes already ask the agent to collect the result when it matters, so the promise rule there keeps the poll-to-the-end condition. The "what running proves" sentences name no tool and sit before the follow-up, so the trailing follow-up sentence stays adapter-owned:

  • base exec uses process
  • sandbox exec uses sandbox_process
  • Gateway exec uses gateway_process when exposed
  • Gateway exec without process follow-up tells the model to rerun in the foreground
  • remote-node exec says background follow-up is unavailable and to wait for completion

Overlap with #158884 and #161780

#158884 (merged 2026-09-26) appends a no-wake warning to the follow-up route when notifyOnExit=false. The previous head of this PR chose its own wake clause by notifyOnExit and left that warning alone.

#161780 (merged 2026-10-02) then made the follow-up conditional on notifyOnExitEmptySuccess as well. Stacked on the previous head, the every-exit mode would have said "you may be woken with a completion event ... do not promise the user updates unless you poll this session until it finishes" and, a sentence later, "Completion will wake this conversation automatically ... end this turn; do not keep polling". Those pull in opposite directions.

This head removes the separate wake clause. The delivery caveat and the promise rule now live inside each of #161780's three branches and agree with that branch's instruction, so they also reach the structured details.followUp. The "what running proves" sentences stay in the visible text only, before the follow-up. #161780's own sentences are unchanged except for the inserted caveat in the every-exit branch, where "report that the job is running" gains "without promising to report back".

On current main, qa-lab's mock provider regex still matches only the pre-#161780 running text, which no mode emits any more. This PR's regex matches the caution followed by any single-line follow-up that contains the Use process (...) route, so it covers all three modes.

How I expect this to help, and what it cannot do

This is an instruction in a tool result. A model can ignore it, and I could not make a model reproduce the original failure in a replay, so I cannot show a before/after in behavior, only in what the model is told. What I can say:

  • On 2026-04-27 the agent read "Command still running" over Telegram and answered "Started. I'll report back". On current main that is the every-exit mode, which now tells the agent to report that the job is running and end the turn. The new text adds, at that exact point, that it must not promise to report back. In the other modes an agent that follows it has two honest moves: keep polling in the same turn and report when done, which is delivered because it is a reply to the user; or say "launched, ask me or I'll check", which makes no promise it cannot keep. Either avoids the wait I had.
  • The misleading input is gone. Today's text reads as confirmation; the new text states the constraint where the decision is made.
  • On the same day, 4 of the 64 background commands with a recorded exit in that session ended with a non-zero code, so a "started" relayed from a running result is wrong often enough to matter.

What it does not do: it does not make the agent keep a promise, and it does not change why the completion turns were silenced. That is the delivery-routing topic linked above and is out of scope here.

User Impact

There is no API, field, or control-flow change. The "what running proves" sentences appear only in the visible text of the status: running exec result. The delivery caveat and promise rule are part of the mode-specific follow-up, so they appear in that text and in the structured details.followUp string, next to the wake wording they qualify. Subsequent process results are unchanged.

Real Behavior Proof

I reran the behavior proof against exact head 0eac408a0ac213770c0147d82bbb09aa5fb34468, rebased onto upstream main at 1a331439952556d653b14973fe294e158d1106bd.

The harness is a tsx script that imports createExecTool, createProcessTool, and waitForExecScope from the checked-out src/ and runs them unmodified. It spawns a real OS child with background: true, immediately reads its log, and then polls its terminal outcome. It uses no exec or process mocks.

The child waits 500 ms before printing WORK_STARTED and exiting with code 7.

The recording below is one asciinema 3.2.1 session from the earlier head d85e6cac, before #158884 landed: it runs the same harness twice, first in a checkout of upstream main at that head's base commit 8adb6ebf5f, then in the PR checkout. git log shows the head before each run. On the base commit the running result has no caution while the immediate log is already empty and the child later exits 7; on the PR head the same result carries the caution before the unchanged follow-up sentence. The host I used for this revision has no asciinema or agg, so the recording was not redone; the transcripts further down are from the current head and show the wording that replaced the recorded one. Final frame of the rendered recording:

Before/after terminal recording: on main the running result reads Command still running, Use process for follow-up; on the PR head the same result adds the new text. Both runs show an empty immediate log, then WORK_STARTED and exit code 7

Redacted stdout transcripts of the same harness on the current head, one per notification mode. The harness now reads notifyOnExit and notifyOnExitEmptySuccess from the environment; everything else is unchanged.

Every-exit mode (the default for chat channels):

head: 0eac408a0ac213770c0147d82bbb09aa5fb34468
node: v24.20.0
notifyOnExit: true notifyOnExitEmptySuccess: true
exec: Command still running (session <session-id>, pid <pid>). Running means the process was started and was alive when this result was written; it says nothing about progress, waiting for input, or a later exit or failure. Do not report progress from this result alone. Completion will wake this conversation automatically. The completion turn may not be allowed to message the user, so if only waiting remains, report that the job is running without promising to report back and end this turn; do not keep polling. Use process (list/poll/log/write/send-keys/submit/paste/kill/clear/remove) for follow-up.
immediate-log: (no output yet)
immediate-status: running
terminal-output:
WORK_STARTED

Process exited with code 7.
terminal-status: completed
terminal-exit-code: 7

Silent empty success:

head: 0eac408a0ac213770c0147d82bbb09aa5fb34468
node: v24.20.0
notifyOnExit: true notifyOnExitEmptySuccess: false
exec: Command still running (session <session-id>, pid <pid>). Running means the process was started and was alive when this result was written; it says nothing about progress, waiting for input, or a later exit or failure. Do not report progress from this result alone. Use process (list/poll/log/write/send-keys/submit/paste/kill/clear/remove) for follow-up. Completion wakes this conversation on output or failure; empty successful jobs are silent (tools.exec.notifyOnExitEmptySuccess=false). Arrange continuation or collect the result before ending the turn if empty success matters. The completion turn may not be allowed to message the user, so do not promise the user updates unless you poll this session until it finishes and report the outcome yourself.
immediate-log: (no output yet)
immediate-status: running
terminal-output:
WORK_STARTED

Process exited with code 7.
terminal-status: completed
terminal-exit-code: 7

Wake disabled, with #158884's sentence also repeated by the log result:

head: 0eac408a0ac213770c0147d82bbb09aa5fb34468
node: v24.20.0
notifyOnExit: false notifyOnExitEmptySuccess: false
exec: Command still running (session <session-id>, pid <pid>). Running means the process was started and was alive when this result was written; it says nothing about progress, waiting for input, or a later exit or failure. Do not report progress from this result alone. Use process (list/poll/log/write/send-keys/submit/paste/kill/clear/remove) for follow-up. Automatic completion wake is disabled (tools.exec.notifyOnExit=false). If the task needs this result, use poll with a timeout to collect it before ending the turn, unless another continuation is already arranged. Without a completion wake, do not promise the user updates unless you poll this session until it finishes and report the outcome yourself.
immediate-log: (no output yet)

Automatic completion wake is disabled (tools.exec.notifyOnExit=false). If the task needs this result, use poll with a timeout to collect it before ending the turn, unless another continuation is already arranged.
immediate-status: running
terminal-output:
WORK_STARTED

Process exited with code 7.
terminal-status: completed
terminal-exit-code: 7

This demonstrates the boundary on the current PR head: session liveness is visible before any evidence that the command reached its work, it says nothing about eventual success, and the delivery caveat matches the configured notification mode.

On this same head:

  • bash-tools.exec-background-followup.test.ts drives a real createExecTool background process in each of the three notification modes on the file's current seeded-session harness. It asserts the visible text carries the running caution right before the structured follow-up, that the delivery caveat appears exactly when a wake is queued, that the every-exit mode drops the promise and the other two keep the poll-to-the-end rule, and that only the disabled mode carries fix: warn agents when background commands cannot wake them #158884's sentence. With bash-tools.exec-run.ts reset to main, 3 of its 10 cases fail. The elapsed-yield-window path is no longer driven separately: main removed that coverage in test(gateway, state, plugins): remove low-value tests (batch d009) #166762, and both start paths build the running result from the same per-run follow-up text.
  • A case in dynamic-tool-build.sandbox.test.ts asserts the complete model-visible sandbox output. The existing node_exec case in dynamic-tool-build.test.ts asserts the complete remote-node output.
  • qa-lab's mock OpenAI provider parses the running text to drive its progress scenarios. server.progress.test.ts uses the every-exit text as RUNNING_OUTPUT and server.tool-routing.test.ts uses the silent-empty-success text, so both shapes (route last, route first) are parsed. With the regex reset to main, 6 of the 32 cases in those two files fail.
  • Focused run on this head: 132 tests across the five touched test files pass.
  • node scripts/check-changed.mjs --base upstream/main on this head: 38 of 41 lanes pass (format, lint, typecheck of core and extensions and both test sets, the mock factory ratchet, the other ratchets). The three that fail are main's own at 6e4883fc: the max-lines suppression ratchet names three ui/src/pages files this PR never touches, the core tsgo graph boundary counts 723 core test roots against an advisory 720 (this head adds no test file), and the dead export scan lists four files, none of them touched here. The first two were also verified to fail identically on a pristine checkout of the earlier base a4182c6c.
  • Exact-head GitHub CI passed on this head: run 39196328499, with openclaw/ci-gate, dependency review and security review all green.

Codex App-Server Contract Review

I inspected the direct sibling Codex source required by AGENTS.md, pinned to the version the rebased plugin declares: @openai/codex 0.162.0, tag rust-v0.162.0, commit c1382380de69521303b416720a52f42d51af6248.

On the OpenClaw side, the patch preserves the exact trailing Use process (...) literal. The sandbox projection rewrites only that suffix to sandbox_process in shell-dynamic-tools.ts. The node alias and the Gateway projection in the same file replace the same suffix with their available or unavailable next step, the Gateway one through the shared projection in exec-tool-target-pinning.ts.

Evidence

  • git diff --check and oxfmt --check pass on the tree.
  • node scripts/check-changed.mjs --base upstream/main on this head: every lane passes except three that are main's own (details above).
  • The core real-process test owns the exec result.
  • The Codex sandbox rewrite case and the existing node_exec case own the complete adapter output.
  • The qa-lab mock provider is the one consumer that parses the running text; its regex and fixture are updated in the same commit.
  • Production changes: three string constants, the three follow-up branches, and one template line in bash-tools.exec-run.ts; one regex in qa-lab's mock-openai-tool-routing.ts; one note in docs/tools/exec.md.
  • CHANGELOG.md remains untouched.
  • The previous head da456ec3 passed exact-head CI (run 36861733565). This head is rebased onto 1a331439 to take in fix: let long Claude shell jobs release chat turns #161780; the rebase conflicted in bash-tools.exec-run.ts and its test, resolved as described above.
  • This head is rebased onto 6e4883fc (fix: keep test compiler caches out of workspace synchronization #176802); earlier rebases in this series went onto a4182c6c (refactor(ui): align page resources with Solid lifetimes #176397), 3307a081 (refactor(test): keep TLS parser coverage in its shared owner #176780) and 6ec77340 (refactor: remove redundant private freezes and checks #176838), each one picking up a main-side fix for a test this PR does not touch. main moved the follow-up text into the run body with fix: report manual collection when exec wake capture fails #169645 so it reads the per-run wake capture state; the wording change moved with it and the three branches are otherwise unchanged. main rewrote the follow-up test file around a seeded session store and removed the old route test in test(gateway, state, plugins): remove low-value tests (batch d009) #166762, so the three-mode assertions now run on that harness. dynamic-tool-build.sandbox.test.ts did not exist at the previous base; the sandbox case moved there and the sibling file is gone.
  • Earlier heads of this PR carried a shorter caution ("Running means only that the session is alive, not that the command's work started or succeeded; do not report progress based on this result alone."). It was replaced because it read as denying that a process had started, which is not what the running result means, and because it said nothing about the promise that caused the harm in the transcript.

AI Disclosure

This pull request is AI-assisted. Claude prepared the original change and tests. Hermes prepared an earlier exact-head behavior proof and dependency inspection. Codex prepared an earlier rebase, review fix, and cross-surface test refresh. Claude prepared the earlier rebase onto main, the qa-lab consumer update, the sibling test file, the Codex 0.154.0 and 0.162.0 source inspections, the recorded before/after proof, the transcript excerpt from my own OpenClaw session logs, the reconciliations with #158884 and #161780, the rebases onto a4182c6c, 3307a081, 6ec77340 and 6e4883fc with the test port, the three-mode test, the docs note, the rerun transcripts, and this description. The author remains responsible for the submitted change.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Aug 8, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 0eac408a0ac213770c0147d82bbb09aa5fb34468, but the PR head is now 7c16cc2abf757c477b046c00346160269285ff86. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (26 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-30T17:55:03.563Z sha fdb786a87c97989d68119811b26ee68f582c4192 :: blocked before merge. :: [P2] Describe liveness at the time it was observed | [P3] Use the shared temporary-directory helper in the new test
  • reviewed 2026-09-30T18:05:14.946Z sha fdb786a87c97989d68119811b26ee68f582c4192 :: needs changes before merge. :: [P2] Describe liveness at the time it was observed | [P3] Use the shared temporary-directory helper in the new test
  • reviewed 2026-10-01T11:15:22.793Z sha 127d906839ca89fd1fc280b17c0378fd7223886c :: needs changes before merge. :: [P2] Describe liveness at the time it was observed
  • reviewed 2026-10-01T11:47:48.061Z sha 127d906839ca89fd1fc280b17c0378fd7223886c :: blocked before merge. :: [P2] Describe liveness at the time it was observed
  • reviewed 2026-10-01T12:34:54.473Z sha da456ec3ec8f62d14010142fc4dedf3ff99befdc :: needs changes before merge. :: [P2] Describe liveness at the time it was observed
  • reviewed 2026-10-01T13:03:55.567Z sha da456ec3ec8f62d14010142fc4dedf3ff99befdc :: needs changes before merge. :: [P2] Describe liveness at the time it was observed
  • reviewed 2026-10-03T00:58:38.964Z sha 0eac408a0ac213770c0147d82bbb09aa5fb34468 :: blocked before merge. :: [P2] Describe liveness at the time it was observed | [P3] Reuse deferred processes for notification-mode coverage
  • reviewed 2026-10-17T21:14:15.052Z sha 0eac408a0ac213770c0147d82bbb09aa5fb34468 :: needs real behavior proof before merge. :: [P2] Describe liveness at the handoff observation | [P3] Reuse deferred processes for added notification cases

@martinfrancois
martinfrancois force-pushed the fix/exec-running-state-wording branch from 36c7ca7 to f1e040d Compare August 9, 2026 23:48
@martinfrancois

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@martinfrancois

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 9, 2026
@martinfrancois
martinfrancois force-pushed the fix/exec-running-state-wording branch from f1e040d to d0f918a Compare August 10, 2026 00:22
@martinfrancois

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@martinfrancois

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 10, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 30, 2026
@martinfrancois
martinfrancois force-pushed the fix/exec-running-state-wording branch from fdb786a to 127d906 Compare October 1, 2026 11:03
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M and removed size: S labels Oct 1, 2026
@martinfrancois

martinfrancois commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Reconciled on da456ec. The caution now keeps the part that holds in every configuration (what running proves, do not report progress from it) plus the promise rule, and picks its wake clause by the same notifyOnExit value #158884 reads. With wake enabled it still says "you may be woken with a completion event, but that turn may not be allowed to message the user". With wake disabled it says "No completion event will wake you, so do not promise the user updates unless you poll this session until it finishes and report the outcome yourself", and #158884's sentence and structured followUp follow unchanged. A disabled-wake result no longer claims both.

The enabled-case text is byte-identical to the previous head, so the qa-lab regex and the alias routes needed no edits. The follow-up test now covers both settings on both background paths. Rebased onto current main, past #162050 and #162133, which fixed the two unrelated shards that were red on the previous head, and past the docs note #158884 added. Details are in the description under "Overlap with #158884".

@martinfrancois
martinfrancois marked this pull request as draft October 1, 2026 11:40
@martinfrancois
martinfrancois marked this pull request as ready for review October 1, 2026 11:40
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@martinfrancois
martinfrancois force-pushed the fix/exec-running-state-wording branch from 127d906 to da456ec Compare October 1, 2026 12:26
@VACInc

VACInc commented Oct 2, 2026

Copy link
Copy Markdown
Member

#161780 has merged into main and overlaps the shared exec follow-up wording. Its guidance is conditional: when completion notifications include empty successes, the agent can end the turn rather than keep polling; silent-success and notifications-disabled cases retain explicit collection guidance. It does not add this PR's explanation of what a running result proves or its broader delivery/promise cautions and coverage. Please reconcile the overlapping wording with those notification branches rather than treating this PR as superseded. Keeping this PR open.

@martinfrancois
martinfrancois force-pushed the fix/exec-running-state-wording branch from da456ec to 0eac408 Compare October 3, 2026 00:49
@martinfrancois

Copy link
Copy Markdown
Contributor Author

@VACInc Reconciled on 0eac408a0ac, rebased onto main with #161780 in.

The overlap was worse than duplicated wording. In the every-exit mode (the chat-channel default, so that is where my original Telegram case lands now), the previous head said "do not promise the user updates unless you poll this session until it finishes", and right after that #161780 says "end this turn; do not keep polling". Those two contradict each other.

This head drops my separate wake clause and puts the delivery caveat inside each of #161780's branches, worded to agree with that branch:

  • Every exit wakes: "Completion will wake this conversation automatically. The completion turn may not be allowed to message the user, so if only waiting remains, report that the job is running without promising to report back and end this turn; do not keep polling." Your end-the-turn guidance stays. The only addition is that the agent must not promise to report back.
  • Silent empty success: your sentences unchanged, then "The completion turn may not be allowed to message the user, so do not promise the user updates unless you poll this session until it finishes and report the outcome yourself."
  • Wake disabled: fix: warn agents when background commands cannot wake them #158884's sentence unchanged, then "Without a completion wake, do not promise the user updates unless you poll this session until it finishes and report the outcome yourself."

The caveat still holds after #161780. buildExecEventPrompt still tells the completion turn "user delivery is disabled for this run" whenever canRelayToUser is false, and the heartbeat runner decides that at wake time from showAlerts and the delivery route. The two sentences about what a running result proves stay in front of the follow-up in all three modes. The caveat now belongs to the branch, so it also reaches details.followUp.

I also found that on main, qa-lab's mock provider regex still expects Use process (...) for follow-up. directly after the pid and at the very end of the text, and none of the three modes produces that text any more. This PR's regex accepts the caution followed by any single-line follow-up that contains the route. The two fixtures cover both orders: route last (every exit) and route first (silent empty success).

The background-followup test now runs both start paths in all three modes. With bash-tools.exec-run.ts reset to main, 6 of its 10 cases fail. Focused tests (178), check-changed, and the real-process proof were rerun on this head, and the description has a transcript for each mode.

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 17, 2026
@martinfrancois

Copy link
Copy Markdown
Contributor Author

Rebased onto main at a4182c6c (#176397), head is now 14947e19. Four files conflicted.

  • bash-tools.exec-run.ts: fix: report manual collection when exec wake capture fails #169645 moved the follow-up text from tool creation into the run body so it reads run.session.notifyOnExit, the per-run wake capture state. The three branches keep this PR's wording; only their location changed.
  • bash-tools.exec-background-followup.test.ts: main rebuilt this file around a seeded session store and removed the old route test in test(gateway, state, plugins): remove low-value tests (batch d009) #166762. The three-mode assertions now run on that harness, one case per notification mode. With bash-tools.exec-run.ts reset to main, those 3 cases fail and the other 7 pass.
  • dynamic-tool-build.test.ts and server.progress.test.ts: main moved the surrounding cases; the two string literals are the only change again.

The sibling file dynamic-tool-build.background-followup.test.ts is gone. main now has dynamic-tool-build.sandbox.test.ts, which did not exist at the previous base, so the sandbox rewrite case lives there.

@openai/codex is pinned to 0.162.0 on this base. I reread the four Codex source spots at rust-v0.162.0 (c1382380): InputText { text } is still accepted as a dynamic-tool content item, the app server still submits it unchanged, core still maps it into the function-tool output without rewriting, and the round-trip test still asserts the exact text reaches function_call_output. The description links point at the new lines.

Verification on this head: 132 tests across the five touched test files pass. check-changed --base upstream/main passes every lane except the max-lines suppression ratchet, the core tsgo graph boundary, and the dead export scan. All three fail with identical output on a pristine checkout of a4182c6c: the ratchet names three ui/src/pages files this PR does not touch, the boundary counts 723 core test roots against an advisory 720 and this head adds no test file, and the dead-export list is the same 30 files on both trees, none touched here.

@martinfrancois

martinfrancois commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

CI on 14947e19 failed in one shard, checks-node-changed-5, on a single test this PR does not touch: src/agents/code-mode.bridge.host-denial.test.ts > "does not resurrect cancellation-ignoring work across awaited preparation", with expected 1 to be +0 from the activeCount wait.

That failure is main's own. It reproduces locally on this head, on a pristine a4182c6c, and on the current tip ad8ea30c. A git bisect over the 178 commits between 36e277d7 (passes) and a4182c6c names 440c86f2, #176403 "prevent premature nested tool completion", as the first bad commit. The changed-set CI on that PR planned seven src/agents test files, none of them code-mode.bridge.host-denial.test.ts, so the regression was never run before merge. This PR's CI ran it because the exec tool change pulls its consumers into the shard.

main's own CI shows the same failure: the push run for 4812f059, which contains 440c86f2, fails it in checks-node-compact-small-6.

I found no open issue or PR for it. Nothing on this branch changes for it; a rerun on a later main will pass once the test or the completion handling is fixed upstream.

@martinfrancois

Copy link
Copy Markdown
Contributor Author

Pushed 5ad606b6, the same change rebased onto main at 3307a081 (#176780). This base includes #176658, which fixes the Code Mode host-denial test that failed the previous run; that test passes on this base, together with the five touched test files (154 tests). The production diff against main is byte-identical to 14947e19. A rerun of the old run would have reused its pinned merge commit, so a new head was the only way to get CI onto the fixed main.

@martinfrancois

Copy link
Copy Markdown
Contributor Author

CI on 5ad606b6 failed in check-test-types only, on one type error in a file this PR does not touch: extensions/codex/src/app-server/native-subagent-monitor.parent-retention.test.ts:37 passes completionDeliveryRetryDelaysMs, which MonitorOptions on main no longer declares (#176686 removed it after #175246 added the test). That is main's own breakage; every other job on this run passed, including the Code Mode shard that failed last time. Upstream already has a fix open: #176834 "restore Codex parent-retention test checks", which reproduces the same TS2353 on a main-side run.

Nothing on this branch changes for it. Once #176834 lands, a rebase and push will give this PR a green run.

@martinfrancois

Copy link
Copy Markdown
Contributor Author

Pushed 14aa4baf, the same change rebased onto main at 6ec77340 (#176838), which includes #176834. The extension test typecheck is clean on this base, and the five touched test files plus the two main-side tests that failed the earlier runs pass (155 tests). The production diff against main is byte-identical to 5ad606b6.

@martinfrancois

Copy link
Copy Markdown
Contributor Author

CI on 14aa4baf failed in checks-fast-baseline-ratchets only. The failing check is mock-exports: it flags test/scripts/ci-node-test-plan.test.ts:3297, a vi.doMock of scripts/lib/ci-test-timings.mts that spreads a captured object instead of importOriginal. This PR does not touch that file; main added the site in #157806 and the pin commit before it. The same check fails locally on this head with --base upstream/main, where the base is main itself, so it is not growth from this branch. The max-lines and env-var budget lines in that job are warnings on main's own files. Every other job on this run passed, including the extension type check and the Code Mode shard that failed the two earlier runs.

I found no upstream PR for the mock-exports site yet. Nothing on this branch changes for it.

@martinfrancois

Copy link
Copy Markdown
Contributor Author

Pushed 7c16cc2a, the same change rebased onto main at 6e4883fc (#176802), which includes the main-side fix for the mock-exports site (b791dd06). On this base the mock factory ratchet passes, the extension test typecheck is clean, and the five touched test files plus the Code Mode shard pass (154 tests). The production diff against main is byte-identical to 14aa4baf.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @martinfrancois for documenting the missed updates and following this through. I checked current main at ce5feeaaa5bee693e6a8949d00e0a8b3646c0e95: the running result already provides mode-specific next steps in both its visible text and structured followUp (#161780, #169645). It tells the agent to await automatic completion, arrange continuation or collect the result when empty success is silent, or poll before ending the turn when wakes are disabled. #177940 also explains that wakes occur only after exit and new output does not start another turn.

Closing this wording expansion because the additional prompt text has no reproduced model-behavior fix on current main, as the replay limitation in the description acknowledges, and it does not repair the delivery-routing failure. The original transcript remains useful evidence for a targeted delivery-routing reproduction. Thank you for the careful report and validation.

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

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex extensions: qa-lab P2 Normal backlog priority with limited blast radius. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants