Skip to content

fix(agents): complete nested final replies after owned work settles - #174487

Merged
vincentkoc merged 2 commits into
mainfrom
fix-code-mode-final-reply-547c
Oct 17, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix-code-mode-final-reply-547c

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes an unnecessary model turn after Code Mode has delivered a final reply to the current conversation and finished its work.

Related: #119057. This addresses the demonstrated completion defect, not the old PR's entire scope.

User Impact

A completed final reply can finish its input without another model request. Progress replies still continue, sibling work still settles, and a later accepted input cannot inherit an earlier input's completion.

No configuration, schema, or protocol changes are required.

Why This Change Was Made

Nested delivery bypassed the direct message-tool completion path. The existing completion owner now consumes private delivery facts only after the originating cell and its sibling work settle. Those facts retain the input accepted at invocation, including across waits and failed result publication, rather than borrowing whichever input is current later.

The same accepted-input identity is committed before fallible message publication. Cancelled or context-only input does not advance it. Generic all-terminal batch behavior is unchanged.

Evidence

The integration uses real execution, message delivery, and SQLite owners with a scripted model transport. It does not claim live provider or physical network-delivery proof. Testbox workload results are separate from hosting-workflow teardown and custody settlement.

Scope and ownership

Production: +222/-9 lines. Tests: +774/-2 lines. The added production state is private invocation, cell, and batch authority needed to preserve input ownership across asynchronous delivery and settlement; it is not a new public feature or protocol. Public result fields cannot forge completion. Progress, pending siblings, accepted/cancelled steering, same-input continuation, and new-input recovery are covered.

@vincentkoc vincentkoc self-assigned this Oct 16, 2026
@clawsweeper

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

@vincentkoc
vincentkoc marked this pull request as ready for review October 16, 2026 17:34
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL labels Oct 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR finishes an input after its nested final reply and owned work settle, without requesting another model response.

Example: Code Mode reads input.txt and sends “RESULT: VERIFIED INPUT” with final:true.

  • Before: The agent requests another model response after the reply and tools finish.
  • After: The originating input finishes after sibling work settles; a later accepted input still receives its own response.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair has coherent ownership and meaningful composition coverage, with no actionable defect found; supplied execution evidence remains harness-based and historically attributed.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its supplied evidence exercises real Agent, Code Mode, WebChat delivery, and SQLite owners with a scripted model transport, with results attributed to earlier trees rather than the refreshed head.
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 user receives a completed final reply from Code Mode but the agent makes another model request afterward.
Reason: Maintainer-authored direction restores the documented confirmed-final contract for nested execution while preserving progress and later-input behavior.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a current nested-reply completion gap, preserves input ownership, and has no actionable defect found in review; exact-head CI remains pending.

Priority: P2
Reviewed head: 07bd31c03f437956fc5d850d380c06c41edec8aa

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied composition does not demonstrate the change through a shipped CLI or Gateway session.
Agent review details

How this fits together

The agent loop launches tools, Code Mode owns nested execution, and delivery records confirmed replies; the existing completion hook combines those facts to finish or continue the input.

flowchart TD
  A[Accepted input] --> B[Agent tool batch]
  B --> C[Code Mode cell]
  C --> D[Message delivery]
  D --> E[Private delivery fact]
  C --> F[Cell and sibling settlement]
  E --> G[Completion hook]
  F --> G
  G --> H[Finish or continue]
Loading

Technical review

Best possible solution:

Land the focused completion repair once the existing exact-head CI gates pass.

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

Current main lacks the nested-delivery completion bridge, and the added production-owner composition provides a deterministic scenario; no target code was executed during this review.

Is this the best way to solve the issue?

The repair extends the existing completion hook, preserves delivery facts at their producer, and binds invocation identity before awaited admission without adding a public setting or competing delivery path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 7a5529f adds src/agents/embedded-agent-runner/run/message-tool-terminal.ts:106 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7a5529f4c964; files: src/agents/embedded-agent-runner/run/message-tool-terminal.ts)
  • Vincent Koc: Raw commit 6e8fe8d adds src/agents/code-mode.ts:188 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6e8fe8d8e778; files: src/agents/code-mode.ts)
  • Dallin Romney: Raw commit 4cb9f12 adds src/agents/code-mode.ts:206 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 4cb9f126859e; files: src/agents/code-mode.ts)

PR surface

Source +213, Tests +772. Total +985 across 18 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 11 222 9 +213
Tests 7 774 2 +772
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 996 11 +985

Review metrics

Metric Value Why it matters
Production versus test LOC Production +222/-9; tests and test infrastructure +774/-2 Production growth retains invocation identity and sibling settlement; the larger test addition exercises asynchronous completion and recovery contracts.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Avoids an unnecessary model request and possible repeated confirmation after a completed nested reply, with limited scope.
  • 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.

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 execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-16T17:52:17.176Z sha f756ce7 :: needs maintainer review before merge. :: none

Reviewed October 16, 2026, 7:53 PM ET / 23:53 UTC (Revision 2).

Baseline-Refresh: f0ddebc9c896862dc0b0ff5c7bcb6a73714dff72
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 07bd31c03f437956fc5d850d380c06c41edec8aa. The native baseline refresh incorporates the canonical Gateway/MCP fixture repairs while retaining the independently reviewed completion patch. Prior failing CI and historical focused proof remain documented in the PR body; renewed exact-head CI is pending.

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@vincentkoc
vincentkoc merged commit 09dece0 into main Oct 17, 2026
159 checks passed
@vincentkoc
vincentkoc deleted the fix-code-mode-final-reply-547c branch October 17, 2026 00:03
@vincentkoc

Copy link
Copy Markdown
Member 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 P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

1 participant