Skip to content

fix: show background commands after agent turns - #110468

Merged
steipete merged 1 commit into
mainfrom
codex/background-task-wakeup
Jul 18, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/background-task-wakeup

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users could ask an agent to start a CLI command in the background, end the agent turn, and then see no running task in the Web, iOS, or Android task view while the command was still active.

Why This Change Was Made

Background exec sessions now project a privacy-safe row into the durable task ledger only after the exec actually yields. The row is finalized before the existing completion heartbeat wakes the agent, supports operator cancellation, and is reconciled after a gateway restart. Command text and command output are not persisted in task metadata.

User Impact

Web, iOS, and Android now show one running background task for an agent-started CLI command after the initiating turn ends, then move it to finished when the command exits. Failed nonzero exits are shown as failed rather than successful.

Release note: Background CLI commands now remain visible in task views until completion.

AI-assisted: yes. I reviewed the implementation and understand the lifecycle, privacy, cancellation, and recovery behavior.

Evidence

  • Live OpenAI Responses API run with an approved OpenAI key: the agent launched a 90-second command, ended with STARTED, the Web task badge and rail showed one running CLI task, and completion triggered a second OpenAI model turn through the existing exec-event heartbeat path.
  • Live Web completion state: the same row moved to Completed with a 1m 30s duration and Command completed summary.
  • Blacksmith Testbox changed gate: format, core/test typecheck, full core/UI lint, import-cycle, SDK boundary, dependency, and database-first guards passed.
  • Focused task/exec tests: 159 tests passed after the nonzero-exit fix; 162 tests passed in the wider lifecycle run.
  • Web background-task E2E: 2 tests passed, including the one-running-task badge, rail row, and screenshot artifact.
  • Android unit suite: BUILD SUCCESSFUL, including the background exec parsing/display assertion.
  • Autoreview: clean on the exact branch diff after addressing nonzero exit-code projection.
  • iOS parsing/display assertion added; exact-head macOS CI will provide compiler and test proof before merge.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: android App: android app: ios App: ios app: web-ui App: web-ui agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Jul 18, 2026
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 18, 2026, 2:24 AM ET / 06:24 UTC.

Summary
The branch records agent-started background exec sessions in the durable task ledger, finalizes their state before completion wakeups, and exposes cancellation/recovery behavior to Web, iOS, and Android task views.

PR surface: Source +209, Tests +323, Docs +1, Other +18. Total +551 across 17 files.

Reproducibility: yes. source-reproducible with medium confidence: a process that crosses the exec yield threshold becomes backgrounded while the initiating agent turn has already ended. I could not execute the current-main or branch reproduction because read-only shell inspection failed before repository commands could run.

Review metrics: none identified.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦐 gold shrimp
Patch quality: 🦐 gold shrimp
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Provide a redacted live-run artifact or terminal/browser capture showing one yielded exec task, its completion transition, and no command/output persistence.
  • Complete the queued Android, iOS, and macOS exact-head validation.
  • Have the task-runtime owner confirm restart and cancellation behavior against current main.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body reports a live OpenAI/Web run and successful real-behavior check, but no inspectable artifact, transcript, screenshot, recording, or linked live output was available in the supplied context for independent confirmation. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] This change crosses exec finalization, durable task state, cancellation, restart reconciliation, and three clients; the remaining Android, iOS, and macOS validation should complete against the exact head before merge.
  • [P1] Because the patch creates a new durable task projection for background exec sessions, maintainers should confirm that task cleanup/recovery cannot retain or prematurely remove rows during gateway restart or process finalization races.

Maintainer options:

  1. Complete lifecycle and platform proof (recommended)
    Verify yielded-process creation, cancellation, terminal finalization, and restart reconciliation on the exact PR head, then wait for the pending Android/iOS/macOS checks before merging.
  2. Pause for owner review
    Pause the PR if maintainers cannot confirm durable-task cleanup and restart behavior across the process-supervisor boundary.

Next step before merge

  • [P1] The PR is protected by a maintainer label and needs owner confirmation of task/process lifecycle ordering plus completion of exact-head platform evidence, not an automated repair pass.

Security
Cleared: The supplied diff touches process/task lifecycle code and client tests/docs, with no indicated dependency, workflow, secret, permission, or supply-chain change.

Review details

Best possible solution:

Retain the existing task-ledger projection approach if focused lifecycle review confirms one canonical exec row per yielded process, correct terminal-state precedence, and successful exact-head mobile/macOS validation.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible with medium confidence: a process that crosses the exec yield threshold becomes backgrounded while the initiating agent turn has already ended. I could not execute the current-main or branch reproduction because read-only shell inspection failed before repository commands could run.

Is this the best way to solve the issue?

Unclear. The proposed post-yield ledger projection and pre-notification finalization are plausible owner-boundary choices, but the repository and feature history could not be inspected deeply enough to establish that this is the best existing task-runtime seam.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against 00eb33fe8e6e.

Label changes

Label changes:

  • add P2: The PR fixes a visible but bounded background-command task-state gap across supported clients.
  • add merge-risk: 🚨 session-state: The change adds durable task rows and terminal reconciliation for background process sessions, so lifecycle ordering can affect persisted task state.
  • add merge-risk: 🚨 availability: The new cancellation and restart-reconciliation paths interact with active process supervision and require exact-head lifecycle proof.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body reports a live OpenAI/Web run and successful real-behavior check, but no inspectable artifact, transcript, screenshot, recording, or linked live output was available in the supplied context for independent confirmation. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: The PR fixes a visible but bounded background-command task-state gap across supported clients.
  • merge-risk: 🚨 session-state: The change adds durable task rows and terminal reconciliation for background process sessions, so lifecycle ordering can affect persisted task state.
  • merge-risk: 🚨 availability: The new cancellation and restart-reconciliation paths interact with active process supervision and require exact-head lifecycle proof.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body reports a live OpenAI/Web run and successful real-behavior check, but no inspectable artifact, transcript, screenshot, recording, or linked live output was available in the supplied context for independent confirmation. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +209, Tests +323, Docs +1, Other +18. Total +551 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 9 217 8 +209
Tests 4 323 0 +323
Docs 2 2 1 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 2 19 1 +18
Total 17 561 10 +551

What I checked:

  • PR scope and claimed behavior: The supplied PR body describes durable, privacy-safe task rows only after exec yield; it also claims completion, cancellation, gateway-restart reconciliation, and Web/iOS/Android visibility. (src/agents/bash-tools.exec.ts:2017, e6d7f2edfb43)
  • Lifecycle wiring in proposed patch: The supplied diff registers the task only after the guarded yield transition and finalizes it through onSettledBeforeNotify, which is the relevant ordering boundary for the requested behavior. (src/agents/bash-tools.exec.ts:2093, e6d7f2edfb43)
  • Protected maintainer handling: The PR carries the maintainer label in the provided GitHub context. Repository policy requires such items to remain open for explicit maintainer handling rather than automated cleanup.
  • Available CI/proof context: The supplied check digest reports successful core checks and a successful Real behavior proof check, while Android and macOS-related checks were still queued or in progress at review time.

Likely related people:

  • steipete: The provided context identifies this person as author of the single branch commit that introduces the exec/task lifecycle integration; current-main history could not be inspected in the read-only environment. (role: proposed implementation author and recent area contributor; confidence: low; commits: e6d7f2edfb43; files: src/agents/bash-tools.exec.ts, src/tasks/task-registry.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 0996341 into main Jul 18, 2026
337 of 355 checks passed
@steipete
steipete deleted the codex/background-task-wakeup branch July 18, 2026 07:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

agents Agent runtime and tooling app: android App: android app: ios App: ios app: web-ui App: web-ui docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant