Skip to content

fix(agents): retain final replies for nested tool runs - #140399

Merged
roboclaw-bot merged 1 commit into
mainfrom
openclaw/audit-team-server-for-code-mode-stalls
Sep 6, 2026
Merged

roboclaw-bot merged 1 commit into
mainfrom
openclaw/audit-team-server-for-code-mode-stalls

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #140398

Related: #133520, #139309, #138511

What Problem This Solves

Fixes an issue where nested or scheduled agent turns can finish their tools but fail to produce a final response after the launching turn has closed. Both isolated summary recovery and its fallback could inherit the launching turn's stale execution or transcript-writer context.

Why This Change Was Made

Finalization now enters the same child-owned transcript boundary as ordinary dispatch and binds the original child admission for the tool-free summary. The actual summary receives the committed writer fence, including first-write sessions. Fallback persistence uses one canonical fenced target and checks that the child admission remains live at the commit edge. Queue cancellation still preserves the original cancellation outcome.

This does not extend the parent's authority, re-admit the child, replay completed tools, change configuration or database schemas, or disable Code Mode.

User Impact

A child can deliver its summary or existing honest fallback after its parent finishes. A cancelled, superseded, removed, or no-longer-admitted child remains fenced.

Evidence

  • New runner-boundary regression exercises the real run loop, harness selection, active-run registration, and SQLite transcript writer with a synthetic provider attempt. Both original cases fail against unchanged production code with SessionTranscriptWriterClaimReboundError; both pass after the scope correction. The tool action executes once.
  • A separate admission-close case exposed an additional fallback bug and passes after admission fencing.
  • 30 focused owner/boundary tests pass across three files. Formatting, git diff --check, conflict-marker check, and targeted lint pass (0 warnings/errors).
  • First hosted CI found two TS2345 errors in the new fixture because sessionKey was optional. Follow-up head 93f3a2523da5917c72d4eeb00a74ae788efc2dad explicitly requires the actual runner-prepared key before append; all three affected ownership regressions pass again. No production code changed in that follow-up. Exact-head hosted CI completed successfully.
  • Independent autoreview found a target-resolution error outside the fallback error handler. A new regression failed for that reason; the resolution now remains inside the handler and the regression passes. Fresh corrected-candidate autoreview completed scoped-clean at P0–P2, with no accepted/actionable findings.
  • Existing coverage includes original-attempt abort, outer/Stop cancellation, pending fallback cancellation, writer supersession, session removal, committed first-writer fence, failed-tool preservation, and unavailable summary recovery.
  • Complete local check:changed is blocked at package-manager bootstrap by the host's minimum-release-age policy. Direct installed-tool core typechecking also refuses the shared external dependency symlink. Neither policy was weakened. The completed hosted CI run passed production/core-test typechecks and the required gate for head 93f3a2523da5917c72d4eeb00a74ae788efc2dad.
  • No live Gateway deployment or restart was performed. AWS attempts did not produce regression proof; both task-owned leases were released.

Review and merge status

ClawSweeper reviewed the current head and found no actionable introduced defect or security finding. Its sole follow-up concerned the previously documented attribution constraint, resolved by the requester’s explicit acceptance below.

On September 6, 2026, the requester explicitly accepted the native workflow’s additional existing source-author credit, provided the final squash commit preserves the exact human co-author trailer. No merge tooling or preservation guard is changed or bypassed.

Current head 737507b5ae4503755ec73d91a7d897cd143cbf7c consolidates only the task-owned commit metadata; the repository tree is unchanged (89dd4fb4b4b6bfd1e3d87745803230ccc8a2c846). All 30 focused tests passed again, and full current-head hosted CI passed.

The actual native-composed squash body has been inspected, and git interpret-trailers --parse recognizes exactly Co-authored-by: Tak Hoffman <[email protected]> in its terminal trailer block after all prose. The unchanged native workflow also preserves the branch author from GitHub’s preview, which the requester has accepted. The exact human trailer will be checked again at prepared head and on the landed commit; a PR comment is not a substitute for commit-level verification. No merge request has yet been submitted.

Worked on by:

Co-authored-by: Tak Hoffman [email protected]

@clawsweeper

clawsweeper Bot commented Sep 6, 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.

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 6, 2026 19:47
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 4:23 PM ET / 20:23 UTC.

ClawSweeper review

What this changes

Keeps nested agents’ final summaries and fallback replies within the child’s own live execution and transcript-writing scopes after the launching turn finishes.

Merge readiness

✅ Ready for maintainer review

This PR remains useful, with no actionable introduced defect found. The updated discussion resolves the previous attribution constraint; no additional review blocker remains.

Priority: P2
Reviewed head: 737507b5ae4503755ec73d91a7d897cd143cbf7c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused ownership repair with meaningful boundary regressions, reported passing CI, and no remaining actionable review concern.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer/bot exemption applies. Recorded synthetic-provider regressions exercise the real child runner and SQLite writer for summary success, fallback, and admission closure; they are supplemental boundary validation, not live-provider proof. Source tracing found no unresolved material authority violation requiring an additional proof gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer/bot exemption applies. Recorded synthetic-provider regressions exercise the real child runner and SQLite writer for summary success, fallback, and admission closure; they are supplemental boundary validation, not live-provider proof. Source tracing found no unresolved material authority violation requiring an additional proof gate.
Evidence reviewed 9 items Pinned patch and checkout identity: The merge-base-to-head delta contains only the two production files and two regression-test files described by the host. HEAD has tree 89dd4fb4b4b6bfd1e3d87745803230ccc8a2c846, matching the updated PR body's recorded tree. The checkout remained clean and diff whitespace validation passed.
Child-owned finalization and commit fencing: Finalization reuses the original admitted child, carries the committed session-writer fence into the summary, and supplies the admission assertion to fallback persistence. Cancellation and writer-rebound errors retain their rejection paths.
Final storage boundary: The existing transcript lock checks admission and authoritative session/writer ownership inside the SQLite transaction, before append and again before commit. The patch uses this existing owner without changing the schema or persisted representation.
Findings None None.
Security None None.

How this fits together

The embedded agent runner turns completed tool work into a final assistant response. Its finalization stage writes the summary or fallback to the session transcript and prepares the reply for delivery.

flowchart TD
  A[Child completes tool work] --> B{Final answer available?}
  B -->|Yes| F[Prepare reply for delivery]
  B -->|No| C[Child-owned tool-free summary]
  C --> D{Child admission and writer still valid?}
  D -->|Yes| E[Persist summary or fallback]
  D -->|No| G[Reject stale completion]
  E --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +65, Tests +316. Total +381 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 134 69 +65
Tests 2 316 0 +316
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 450 69 +381

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #140398
Summary: This PR implements the linked nested-child finalization repair; the earlier merged work addresses related but distinct completion and writer paths.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep finalization under the independently admitted child, preserving existing cancellation, writer-supersession, and no-tool-replay guarantees.

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

Yes, source inspection supports the closed-parent/independently admitted-child sequence, and the supplied regression reports failure on the unchanged baseline. This review did not execute a reproduction.

Is this the best way to solve the issue?

Yes. Reusing the existing child admission and transcript owner repairs the lifecycle boundary without introducing another recovery mechanism, configuration option, or storage format.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9ca3a9ef5794.

Labels

Label justifications:

  • P2: This repairs a bounded nested-agent completion failure that can suppress the final reply after successful tool work.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer/bot exemption applies. Recorded synthetic-provider regressions exercise the real child runner and SQLite writer for summary success, fallback, and admission closure; they are supplemental boundary validation, not live-provider proof. Source tracing found no unresolved material authority violation requiring an additional proof gate.

Evidence

What I checked:

Likely related people:

  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • altaywtf: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

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

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-06T20:00:30.500Z sha 93f3a2523da5917c72d4eeb00a74ae788efc2dad :: needs maintainer review before merge. :: none
  • reviewed 2026-09-06T20:14:33.088Z sha 737507b :: needs changes before merge. :: none

Keep tool-free finalization and fallback persistence in the child's own live
admission and committed transcript-writer scope after its parent finishes.
Preserve cancellation, writer supersession, and completed tool actions.
The regression fixture requires the actual runner-prepared session key.

Fixes #140398

Worked on by:
- @Takhoffman

Co-authored-by: Tak Hoffman <[email protected]>
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/audit-team-server-for-code-mode-stalls branch from 93f3a25 to 737507b Compare September 6, 2026 20:07
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

The sole current review follow-up—the PR body’s attribution constraint—is resolved by the requester’s explicit acceptance of the unchanged native workflow’s existing source-author credit. The required final squash trailer remains exactly:

Co-authored-by: Tak Hoffman [email protected]

I inspected the actual composed squash body and verified the exact line with git interpret-trailers --parse; it is in the terminal trailer block after prose. It will be rechecked at prepared head and on the landed commit. No merge guard or tooling has been bypassed or modified.

The PR body now records that acceptance and full successful CI for current head 737507b5ae4503755ec73d91a7d897cd143cbf7c: https://github.com/openclaw/openclaw/actions/runs/34057008531. No source changes since your current-head review.

@clawsweeper

clawsweeper Bot commented Sep 6, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@roboclaw-bot
roboclaw-bot merged commit 04fb401 into main Sep 6, 2026
190 of 192 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

@roboclaw-bot
roboclaw-bot deleted the openclaw/audit-team-server-for-code-mode-stalls branch September 6, 2026 21:15
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
Keep nested tool-turn finalization in the child's live caller and committed writer scopes, preserve cancellation, and avoid replaying completed actions.

Fixes openclaw#140398

Worked on by:
- @Takhoffman

Co-authored-by: Tak Hoffman <[email protected]>
Co-authored-by: roboclaw-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Nested tool runs lose final replies after the launching turn closes

1 participant