Skip to content

fix: prevent premature nested tool completion - #176403

Merged
roboclaw-bot merged 4 commits into
mainfrom
openclaw/pi-terminal-presentation
Oct 18, 2026
Merged

roboclaw-bot merged 4 commits into
mainfrom
openclaw/pi-terminal-presentation

Conversation

@roboclaw-bot

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

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: nested Code Mode tools can appear completed before their activity is saved, leaving completion events ahead of recoverable history.

User Impact

User impact: completed nested tools agree with saved history after reconnect. If activity persistence fails, known effects remain recorded for replay-safety decisions instead of making a completed operation safe to repeat. No configuration changes or migrations are required.

Why This Change Was Made

The existing completion owner captures semantic outcome and effect evidence first, prepares terminal presentation, and publishes it only after the current attempt accepts the existing nested-activity append. Ordinary provider-tool completions retain their immediate presentation path. Stale attempts suppress presentation without erasing captured effects.

The conflict refresh preserves upstream’s working pnpm run invocation and both hook regressions. Those hook changes are now on main and are no longer part of this PR’s net diff.

Evidence

  • Reproduced premature terminal tool/item events on the original pinned base while the nested executor’s activity append was held.
  • Composed lifecycle/executor regressions cover held, accepted, rejected, and superseded appends.
  • Original source-loaded isolated Gateway/model proof performed one nested write and one read. Each WebSocket terminal event found its saved history entry; reconnect returned the same nested entries, and the write occurred once. The three changed production modules remain byte-identical to that tested implementation.
  • On the refreshed candidate: all 110 focused agent tests and 14 hook tests pass; formatting and whitespace checks pass. A fresh Sol Ultrafast autoreview found no actionable P0–P2 issues in the five-file net change. Original targeted types/lint/docs/runtime-build proof is retained; historical proof is not current-head CI.

Worked on by

Work sessions

roboclaw-bot and others added 2 commits October 18, 2026 20:08
Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 13745fba-dab1-4608-b059-34c6940d2716
@clawsweeper

clawsweeper Bot commented Oct 18, 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 scripts Repository scripts agents Agent runtime and tooling size: L labels Oct 18, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 18, 2026 20:13
@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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR delays nested-tool terminal presentation until activity persistence is accepted while retaining execution and replay-safety evidence immediately.

Example: A nested write creates synthetic.txt while its activity append is delayed.

  • Before: The tool can appear completed before reconnectable history contains its activity.
  • After: Completion waits for append acceptance; rejection or supersession suppresses presentation without erasing known effects.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with meaningful boundary regressions and no actionable findings; public runtime evidence is limited, and current-head CI is still pending.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the ordinary contributor proof gate; its reported isolated Gateway run exercises nested write/read completion and reconnect, while inspectable support is the composed regression source and the production modules' verified identity across the refresh.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Nested tools can appear complete before their activity is available after reconnect.
Reason: The repair restores consistency between completion and accepted history while preserving replay protection; collaborator authorship supplies the direction decision.

Merge readiness

✅ Ready for maintainer review

This maintainer-authored PR addresses a completion-ordering defect still present on main. The previous hook-integration blocker is resolved, and no actionable introduced defect was found.

Priority: P2
Reviewed head: 733031fbca99d2ed2a3ffc7b08de286d8fb7471a

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The body reports Gateway write/read, reconnect, and base-red results, but independently inspectable runtime traces and baseline execution output are not attached.
Agent review details

How this fits together

The embedded runtime receives nested tool results, records execution evidence, appends display activity through SessionManager, and publishes terminal events to connected clients.

flowchart TD
 A[Nested tool result] --> B[Capture outcome and effects]
 B --> C[Existing activity append owner]
 C --> D[Current attempt acceptance]
 D --> E[Publish terminal events]
 C --> F[Reconnectable history]
Loading

Technical review

Best possible solution:

Keep semantic outcome recording in the existing completion owner and publish nested terminal presentation only after current-attempt activity acceptance.

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

Main's lifecycle establishes the failing order, and the added composed regression supplies a deterministic held-append scenario; no target code was executed during this review.

Is this the best way to solve the issue?

The patch repairs the ordering at existing completion and persistence owners, preserves effect evidence before fallible persistence, and retains ordinary provider-tool presentation without unnecessary machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 5843d60 adds src/agents/embedded-agent-runner/run/attempt-tool-search-executor.ts:91 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5843d60cb445; files: src/agents/embedded-agent-runner/run/attempt-tool-search-executor.ts)
  • RoboClaw: Raw commit 729c6b1 adds src/agents/embedded-agent-runner/run/attempt-tool-search-executor.ts:88 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 729c6b1cc3d0; files: src/agents/embedded-agent-runner/run/attempt-tool-search-executor.ts)
  • Marvinthebored: Raw commit a7a1d05 adds src/agents/embedded-agent-subscribe.tool-lifecycle.ts:49 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: a7a1d05a46c6; files: src/agents/embedded-agent-subscribe.tool-lifecycle.ts)

PR surface

Source +23, Tests +121, Docs +3. Total +147 across 5 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 190 167 +23
Tests 1 121 0 +121
Docs 1 5 2 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 316 169 +147

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The defect causes a bounded mismatch between live nested-tool completion and recoverable activity history.
  • 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-18T20:29:32.921Z sha 245d35a :: needs changes before merge. :: none

Reviewed October 18, 2026, 5:48 PM ET / 21:48 UTC (Revision 2).

roboclaw-bot and others added 2 commits October 18, 2026 21:08
Preserve the upstream package-script invocation and combined hook regressions while retaining deferred nested terminal presentation.

Co-authored-by: steipete <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added size: M and removed scripts Repository scripts size: L labels Oct 18, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@roboclaw-bot
roboclaw-bot enabled auto-merge (squash) October 18, 2026 21:44
@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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 18, 2026
@clawsweeper clawsweeper Bot removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 18, 2026
@roboclaw-bot
roboclaw-bot merged commit 440c86f into main Oct 18, 2026
142 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/pi-terminal-presentation branch October 18, 2026 21:55
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash auto-merge.

steipete added a commit that referenced this pull request Oct 19, 2026
Record terminal lifecycle accounting before nested activity acceptance can
reject or suppress presentation. Keep terminal event publication after
accepted history and preserve captured effect evidence.

Fixes the accounting regression introduced by 440c86f (#176403).
Both reported cases failed on main under Node and Bun; reversing only that
commit's production delta made both pass. The append-boundary regression
also failed for rejected and superseded writes before this fix.

Full focused proof: Node 42/42, pinned Bun 42/42, maxWorkers=1.
Targeted types, typed core/boundary lint, format and P2 review passed.
Changed fixture full-file wall time: Node 185.99s, Bun 171.58s; imports
and worker preparation dominate, with no additional cases or setup.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
* fix: prevent premature nested tool completion

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

* fix: prevent premature nested tool completion

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 13745fba-dab1-4608-b059-34c6940d2716

* fix: retain upstream package-script invocation

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

---------

Co-authored-by: steipete <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
…6658)

Record terminal lifecycle accounting before nested activity acceptance can
reject or suppress presentation. Keep terminal event publication after
accepted history and preserve captured effect evidence.

Fixes the accounting regression introduced by 716bf79 (openclaw#176403).
Both reported cases failed on main under Node and Bun; reversing only that
commit's production delta made both pass. The append-boundary regression
also failed for rejected and superseded writes before this fix.

Full focused proof: Node 42/42, pinned Bun 42/42, maxWorkers=1.
Targeted types, typed core/boundary lint, format and P2 review passed.
Changed fixture full-file wall time: Node 185.99s, Bun 171.58s; imports
and worker preparation dominate, with no additional cases or setup.
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 P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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