Skip to content

fix(agents): keep tool-authored replies from hiding unfinished work - #165291

Merged
roboclaw-bot merged 7 commits into
mainfrom
openclaw/review-request-unclear
Oct 10, 2026
Merged

roboclaw-bot merged 7 commits into
mainfrom
openclaw/review-request-unclear

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #164558

What Problem This Solves

Fixes finished tool-authored replies hiding sibling failures, disappearing beside terminal tools, repeating pre-tool narration, or delivering content that result middleware withdrew.

User Impact

Plugin tools can return a finished answer without a model restatement while unfinished or failed sibling work still receives a continuation. Only the originating input's preamble is replaced; earlier and later answers and errors remain visible. No configuration migration or automatic tool opt-in is introduced.

Why This Change Was Made

Capture and completion now share the finalized batch after result rewriting. Codex keeps candidates private until the upstream response closes and every model-emitted call has an eligible result; raw receipts cover late request registration and native siblings. Explicit terminal siblings retain their completion contract without dropping a finished reply. Canonical assistant identity keeps reused call IDs distinct and recovery idempotent.

Reply content comes only from details.sourceReply. Calls nested inside Code Mode return data to that program, never an implicit send. Codex's direct-reply fast path requires the model-only direct-only catalog. Existing message-tool delivery remains separate.

Evidence

  • Runtime verification executed at 3ace76ecaf4f082c7b00cba861513046b6ff65b6. The final head adds only a documentation clarification learned from that live run; production and test source are unchanged. Documentation formatting and link audit pass (14,947 links, zero broken).
  • Full check:changed on all 34 changed paths passed, including 27 core-test type shards, extension types, lint, and remaining guards. Full normal pnpm build passed in 5m26s. Its nonfatal UI-budget notice was 365.2 KiB startup JS versus 364.7 KiB; no UI source was changed.
  • Real isolated Gateway, native Codex: 4/4 cases passed with the actual Codex harness selected. Direct delivery was exact and once, with one raw model response and a terminal-release receipt. A real provider preamble was excluded from final delivery. Nested Code Mode did not auto-deliver its tool result. Both sibling calls were proven to belong to one raw response; the failing sibling caused a visible model continuation and no terminal release.
  • Current embedded-runtime controls: 4/4 passed. Agent-loop requests were 1 for direct/preamble and 2 for nested/sibling. Native evidence spans two authenticated, catalog-admitted model configurations; initial runs that did not exercise direct calls or same-response siblings remain fixture-inconclusive, not passes. No model allowlist or safety bypass was used.
  • Red/green regressions cover finalized message_end rewriting, reused call IDs, response-only identity, terminal siblings, delayed native registration, and failure visibility. The refreshed 14-file selection passed in 216.56s. The final five-file selection passed 119 tests in 52.27s (pnpm test <files> --maxWorkers=1); a mechanical owner extraction passed 48 related tests in 6.29s, and the corrected consumer fixture passed 13 in 44.44s. These selections overlap; per-test CI seconds are not measured.
  • Independent review is clean through P2 after reproduced findings were fixed. Earlier local aggregates stopped on a line-count gate and then an outdated test fixture; both causes were corrected, and the full final aggregate passed. Earlier failed receipts were not relabeled successful.
  • Source and built-artifact hashes stayed unchanged during every live run. All six attempted fixtures verified process/port shutdown and removed ephemeral state/config; artifact scans found zero raw credential matches. No operator Gateway changes or cloud allocations.
  • Limits: no Telegram/Discord transport claim; native HTTP request counts are unmeasured (raw response receipts establish model continuations). Late extension mutation is integration-tested rather than claimed as live transport proof.

Worked on by

Work sessions


View the OpenClaw team session

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 37ed7a7b-e914-41f4-9fff-0e3bf1e5f546
@clawsweeper

clawsweeper Bot commented Oct 5, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: codex size: XL labels Oct 5, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 5, 2026 02:49
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: d491ff5bf7f19d4f88f7d49db46c5079d2fa3a66
  • Maintainer: @roboclaw-bot
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/embedded-agent-tool-authored-source-reply.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR admits tool-authored replies only after finalized batch settlement and associates them with their originating assistant input.

Example: One model response calls order_confirm and stock_check; order_confirm returns “Order SO1 created,” while stock_check fails.

  • Before: The finished reply can end the turn and conceal the stock-check failure.
  • After: The batch remains with the model for a continuation that can explain or recover from the failure.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is coherent and has meaningful boundary coverage; reported live scenarios improve the evidence, but their underlying runtime output was unavailable for inspection.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the ordinary external-contributor proof gate; its body records isolated native Codex and embedded verification, but supplies summaries rather than inspectable runtime output, so the earlier request is addressed narratively rather than independently verified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A finished plugin reply can hide failed or unfinished sibling work, repeat narration, or deliver content withdrawn by result middleware.
Reason: The maintainer-authored repair restores visible outcomes for sibling work while retaining the existing direct-reply capability.

Merge readiness

✅ Ready for maintainer review

Keep this PR: current main still permits a tool-authored reply to conceal unfinished sibling work, and the patch coherently repairs that behavior without a concrete introduced correctness defect.

Priority: P2
Reviewed head: d491ff5bf7f19d4f88f7d49db46c5079d2fa3a66

Before merge

None.

Findings

None.

Tests

  • Low-value test src/agents/embedded-agent-subscribe.handlers.tools.source-reply.test.ts: Remove the nested-call assertion at line 108: it exercises the completion handler after reply capture was removed from that handler, so direct calls also leave the asserted collection empty.
  • Missing end-to-end proof: The body reports the requested native scenarios, but inspectable native terminal output or runtime receipts are not included in the supplied public evidence.
Agent review details

How this fits together

Embedded agents and the Codex plugin convert tool results into completion decisions and source-conversation reply payloads, which existing delivery owners send and mirror into transcripts.

flowchart TD
  A[Model tool calls] --> B[Tool execution and result middleware]
  B --> C[Finalized batch admission]
  C --> D[Model continuation]
  C --> E[Committed source replies]
  E --> F[Conversation delivery]
  F --> G[Transcript mirror]
Loading

Technical review

Best possible solution:

Retain whole-batch admission and per-input identity within the existing source-reply delivery path.

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

Current-main source establishes the failure path: one eligible authored reply can complete the batch despite an ordinary or failed sibling; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The repair fixes completion at its existing owners, captures finalized results, preserves explicit terminal siblings, and prevents one input’s reply from suppressing another input’s answer or failure.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Embedded and native tool-authored batch completion changes intended behavior with a stated reason (0ed2e0c: Avoid a second model turn after a plugin already authored a finished reply, including mixed batches.)
  • Reply extraction after middleware keeps the original intent (0ed2e0c: Middleware must be able to rewrite or withdraw reply content before delivery.)
  • Per-input answer selection keeps the original intent (6349e43: Deliver completed answers in order while replacing progress only within its originating input.)
  • Assistant-scoped reply idempotency keeps the original intent (ae7f17a: Keep reused provider call IDs distinct across assistant responses and stable across recovery.)
  • Codex terminal interruption and steering keeps the original intent (7a3c26b: Cancel accepted but unconsumed steering before interruption so completion delivery can recover it.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +221, Tests +967, Docs +14. Total +1202 across 34 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 22 369 148 +221
Tests 11 1157 190 +967
Docs 1 26 12 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 34 1552 350 +1202

Review metrics

Metric Value Why it matters
Production versus test changes Production +369/−148; tests +1,157/−190 Production growth adds response-inventory admission and input identity; most test growth exercises sibling ordering, delayed registration, and finalized-result behavior.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The existing plugin capability changes completion semantics for mixed batches; the maintainer-authored body explicitly accepts model continuation when sibling work remains.
  • add proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Telegram can observe narration replacement and the preserved continuation after a failed sibling tool.
  • remove merge-risk: 🚨 message-delivery: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.

Label justifications:

  • P2: The defect affects opted-in plugin reply tools and can conceal sibling failures, with a limited affected surface.
  • merge-risk: 🚨 compatibility: The existing plugin capability changes completion semantics for mixed batches; the maintainer-authored body explicitly accepts model continuation when sibling work remains.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Telegram can observe narration replacement and the preserved continuation after a failed sibling tool.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach redacted native Gateway output showing exact-once direct delivery, nested-call non-delivery, and failed-sibling continuation.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-05T02:56:02.507Z sha 55f0f98 :: blocked before merge. :: none
  • reviewed 2026-10-05T03:23:48.920Z sha 8026735 :: blocked before merge. :: none
  • reviewed 2026-10-05T03:41:01.362Z sha 8026735 :: blocked before merge. :: none

Reviewed October 9, 2026, 11:47 PM ET / October 10, 2026, 03:47 UTC (Revision 4).

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 97079130-b77a-4758-880a-d87dd43c3b94
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 5, 2026
roboclaw-bot and others added 5 commits October 10, 2026 03:04
Refresh the reply-boundary repair against current main, retaining canonical assistant identity and explicit terminal sibling dispositions.

Co-authored-by: steipete <[email protected]>
Move the existing error factories without behavioral changes to keep the agent loop within its inherited line-count budget.

Co-authored-by: steipete <[email protected]>
Reflect live native proof: catalog identity alone does not authorize automatic delivery; raw model-call ownership is required.

Co-authored-by: steipete <[email protected]>
Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 1714e232-1a9e-4158-a507-68b5bff9c58f
@roboclaw-bot roboclaw-bot changed the title fix(agents): finalize tool-authored replies at batch boundaries fix(agents): keep tool-authored replies from hiding unfinished work Oct 10, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. and removed merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Oct 10, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Maintainer disposition for d491ff5bf7f19d4f88f7d49db46c5079d2fa3a66:

  • The completion-handler assertion is retained as a guard against restoring eager capture in that retired owner; it is not our evidence for nested-call isolation. Actual nested Code Mode non-delivery was verified in both native Codex and embedded Gateway runs.
  • Required native delivery/continuation proof is complete and its receipts were inspected locally, including same-raw-response sibling correlation and terminal-release evidence. The PR body records the executing revision, source equivalence, results, and limitations. Publishing additional receipts is an optional presentation improvement, not an unperformed runtime check.
  • This repair makes no Telegram-specific change or transport claim. The Telegram proof label is a suggested additional surface, not a new acceptance requirement for the verified Gateway/runtime boundary.

The current-head durable review reports no findings and no before-merge items, and both required CI gate entries are successful. Proceeding through the repository’s guarded landing workflow.

@roboclaw-bot
roboclaw-bot merged commit 9c9b2bb into main Oct 10, 2026
144 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/review-request-unclear branch October 10, 2026 03:55
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
…penclaw#165291)

* fix(agents): finalize tool-authored replies at batch boundaries

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 37ed7a7b-e914-41f4-9fff-0e3bf1e5f546

* fix(agents): finalize tool-authored replies at batch boundaries

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 97079130-b77a-4758-880a-d87dd43c3b94

* refactor(agents): colocate error factories with tool outcomes

Move the existing error factories without behavioral changes to keep the agent loop within its inherited line-count budget.

Co-authored-by: steipete <[email protected]>

* test(agents): include terminal inventory in stream consumer fixture

Co-authored-by: steipete <[email protected]>

* docs(plugins): clarify native reply admission for nested calls

Reflect live native proof: catalog identity alone does not authorize automatic delivery; raw model-call ownership is required.

Co-authored-by: steipete <[email protected]>

* fix(agents): keep tool-authored replies from hiding unfinished work

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 1714e232-1a9e-4158-a507-68b5bff9c58f

---------

Co-authored-by: steipete <[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 docs Improvements or additions to documentation extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: XL 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.

2 participants