Repository navigation
fix(exec): explain what a running background result proves and warn against unpolled promises - #120414
fix(exec): explain what a running background result proves and warn against unpolled promises#120414martinfrancois wants to merge 1 commit into
Conversation
|
Codex review: stale review; fresh review needed. Summary Next step Review history (26 earlier review cycles; latest 8 shown)
|
36c7ca7 to
f1e040d
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
f1e040d to
d0f918a
Compare
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
fdb786a to
127d906
Compare
|
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 The enabled-case text is byte-identical to the previous head, so the |
|
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. |
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
127d906 to
da456ec
Compare
|
#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. |
da456ec to
0eac408
Compare
|
@VACInc Reconciled on 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:
The caveat still holds after #161780. I also found that on The background-followup test now runs both start paths in all three modes. With |
|
Rebased onto
The sibling file
Verification on this head: 132 tests across the five touched test files pass. |
|
CI on That failure is
I found no open issue or PR for it. Nothing on this branch changes for it; a rerun on a later |
|
Pushed |
|
CI on Nothing on this branch changes for it. Once #176834 lands, a rebase and push will give this PR a green run. |
|
Pushed |
|
CI on I found no upstream PR for the mock-exports site yet. Nothing on this branch changes for it. |
…gainst unpolled promises
|
Pushed |
|
Thanks @martinfrancois for documenting the missed updates and following this through. I checked current main at 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. |
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):
What the transcript shows
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.That leaves two ways to stop an agent from promising a report it cannot deliver:
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
createExecToolcurrently reads:#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:
With completion waking on every exit (
notifyOnExitEmptySuccess=true, the default for chat channels), the follow-up reads:With silent empty successes (
notifyOnExitEmptySuccess=false):With
tools.exec.notifyOnExit=false:Each clause is checked against the code. "The completion turn may not be allowed to message the user" holds whenever a wake is queued:
buildExecEventPromptinsrc/infra/heartbeat-events-filter.tsstill tells the completion turn "user delivery is disabled for this run" whencanRelayToUseris false, andheartbeat-runner-execution.tscomputes 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:processsandbox_processgateway_processwhen exposedOverlap 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 bynotifyOnExitand left that warning alone.#161780 (merged 2026-10-02) then made the follow-up conditional on
notifyOnExitEmptySuccessas 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 theUse 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:
mainthat 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.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: runningexec result. The delivery caveat and promise rule are part of the mode-specific follow-up, so they appear in that text and in the structureddetails.followUpstring, 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 upstreammainat1a331439952556d653b14973fe294e158d1106bd.The harness is a
tsxscript that importscreateExecTool,createProcessTool, andwaitForExecScopefrom the checked-outsrc/and runs them unmodified. It spawns a real OS child withbackground: 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_STARTEDand 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 upstreammainat that head's base commit8adb6ebf5f, then in the PR checkout.git logshows 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:Redacted stdout transcripts of the same harness on the current head, one per notification mode. The harness now reads
notifyOnExitandnotifyOnExitEmptySuccessfrom the environment; everything else is unchanged.Every-exit mode (the default for chat channels):
Silent empty success:
Wake disabled, with #158884's sentence also repeated by the
logresult: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.tsdrives a realcreateExecToolbackground 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. Withbash-tools.exec-run.tsreset tomain, 3 of its 10 cases fail. The elapsed-yield-window path is no longer driven separately:mainremoved 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.dynamic-tool-build.sandbox.test.tsasserts the complete model-visible sandbox output. The existingnode_execcase indynamic-tool-build.test.tsasserts the complete remote-node output.qa-lab's mock OpenAI provider parses the running text to drive its progress scenarios.server.progress.test.tsuses the every-exit text asRUNNING_OUTPUTandserver.tool-routing.test.tsuses the silent-empty-success text, so both shapes (route last, route first) are parsed. With the regex reset tomain, 6 of the 32 cases in those two files fail.node scripts/check-changed.mjs --base upstream/mainon 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 aremain's own at6e4883fc: the max-lines suppression ratchet names threeui/src/pagesfiles 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 basea4182c6c.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/codex0.162.0, tagrust-v0.162.0, commitc1382380de69521303b416720a52f42d51af6248.InputText { text }content item:app-server-protocol/src/protocol/v2/item.rs#L1675-L1692.Op::DynamicToolResponse:app-server/src/dynamic_tools.rs#L18-L58.core/src/tools/handlers/dynamic.rs#L153-L164.InputTextreaches the follow-upfunction_call_output:app-server/tests/suite/v2/dynamic_tools.rs#L341-L582.On the OpenClaw side, the patch preserves the exact trailing
Use process (...)literal. The sandbox projection rewrites only that suffix tosandbox_processinshell-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 inexec-tool-target-pinning.ts.Evidence
git diff --checkandoxfmt --checkpass on the tree.node scripts/check-changed.mjs --base upstream/mainon this head: every lane passes except three that aremain's own (details above).node_execcase own the complete adapter output.qa-labmock provider is the one consumer that parses the running text; its regex and fixture are updated in the same commit.bash-tools.exec-run.ts; one regex inqa-lab'smock-openai-tool-routing.ts; one note indocs/tools/exec.md.CHANGELOG.mdremains untouched.da456ec3passed exact-head CI (run 36861733565). This head is rebased onto1a331439to take in fix: let long Claude shell jobs release chat turns #161780; the rebase conflicted inbash-tools.exec-run.tsand its test, resolved as described above.6e4883fc(fix: keep test compiler caches out of workspace synchronization #176802); earlier rebases in this series went ontoa4182c6c(refactor(ui): align page resources with Solid lifetimes #176397),3307a081(refactor(test): keep TLS parser coverage in its shared owner #176780) and6ec77340(refactor: remove redundant private freezes and checks #176838), each one picking up amain-side fix for a test this PR does not touch.mainmoved 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.mainrewrote 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.tsdid not exist at the previous base; the sandbox case moved there and the sibling file is gone.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, theqa-labconsumer 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 ontoa4182c6c,3307a081,6ec77340and6e4883fcwith the test port, the three-mode test, the docs note, the rerun transcripts, and this description. The author remains responsible for the submitted change.