Skip to content

fix(agent-core): close tool batches at the launch boundary - #129293

Merged
steipete merged 1 commit into
mainfrom
codex/cleanup-aug25-agent-core-tool-batch
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/cleanup-aug25-agent-core-tool-batch

Conversation

@steipete

@steipete steipete commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Close tool-batch launch authority at the canonical agent-loop boundary so an idle or stale run cannot start prepared side effects.
  • Preserve paired lifecycle, rejection, result, and turn events through one batch owner.
  • Clone caller-owned message context unconditionally, including empty-prompt runs, so exported loop APIs never mutate the supplied transcript.

Root cause

Tool execution admission and lifecycle settlement were spread across launch and result paths, allowing stale run state to reach a prepared tool. During consolidation, the empty-prompt path also reused the caller's messages array while the loop appends assistant and tool-result messages, violating the existing public context-isolation contract.

The current-main reconstruction keeps all intervening owner changes, centralizes launch admission, and restores an unconditional context clone before the loop mutates its working transcript.

User impact

  • Delayed tool side effects cannot start after the owning turn becomes idle.
  • Lifecycle events remain paired for observers and recovery logic.
  • Empty-prompt callers retain an unchanged input transcript.
  • No new public API, configuration, persistence, or fallback behavior is introduced.

Verification

  • Two caller-context regressions failed before the correction and pass afterward.
  • Agent-core owner, lifecycle, rejection-contract, and stale-authority coverage passed on the current-main reconstruction.
  • Independent final verification and both mandatory local and committed-branch reviews completed without findings.

Surface

  • Three agent-core source/test files.
  • Production: net -62 lines.
  • Tests cover lifecycle admission and caller-context isolation at the exported loop boundary.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Aug 25, 2026
@steipete
steipete marked this pull request as ready for review August 25, 2026 11:53
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 10:24 PM ET / August 26, 2026, 02:24 UTC.

ClawSweeper review

What this changes

The PR moves tool-batch commitment to the immediate launch boundary, preserves tool lifecycle outcomes after an admission failure, and clones caller message arrays for all exported loop entry points.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer landing: the prior caller-context finding is resolved on the current head, and this review found no new blocking defect; exact-head CI and normal maintainer review remain pending.

Priority: P1
Reviewed head: 424955d35f73bf2d6f4af88c47619655b414300a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative production repair with meaningful boundary coverage; remaining confidence depends on exact-head checks for this session-sensitive path.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This maintainer-authored PR is exempt from the external-contributor real-behavior-proof gate; the PR body and focused tests provide supplemental validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor real-behavior-proof gate; the PR body and focused tests provide supplemental validation.
Evidence reviewed 6 items Current-main behavior: Current main prepares each parallel tool call, then invokes every ready execution through Promise.all; each execution commits immediately before its implementation callback. The PR replaces this with a single launch coordinator that stops later calls when the commit rejects.
Launch-boundary implementation: The current head creates the caller-owned working transcript with an unconditional array clone and routes ready calls through launchParallelToolCalls, where the lifecycle commit happens immediately before implementation start.
Owner-boundary contract: The embedded runner attaches the private lifecycle bridge, and the owner records history only in commitReadyCalls while releaseSkippedCalls removes unlaunched admission markers.
Findings None None.
Security None None.

Live Verification

Command: pnpm test packages/agent-core/src/agent-loop.test.ts

Result: PASS (completed)

$ node --import tsx scripts/test-projects.mts packages/agent-core/src/agent-loop.test.ts
[test] starting test/vitest/vitest.unit.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129293-XfVrle/target

 ✓  unit  packages/agent-core/src/agent-loop.test.ts (71 tests) 139ms

 Test Files  1 passed (1)
      Tests  71 passed (71)
   Start at  02:25:01
   Duration  1.74s (transform 1.20s, setup 650ms, import 721ms, tests 139ms, environment 0ms)

[test] passed 1 Vitest shard in 8.96s
$ node --import tsx scripts/test-projects.mts packages/agent-core/src/agent-loop.test.ts
[test] starting test/vitest/vitest.unit.config.ts

Assertions:

  • PASS expect_output: agent-loop.test.ts

How this fits together

Agent Core accepts model tool calls, validates and admits them through the agent loop, then dispatches tool side effects and emits transcript/lifecycle events. The changed boundary is between preparing a tool call and allowing its implementation to start.

flowchart LR
  A[Model tool calls] --> B[Agent loop]
  B --> C[Batch admission]
  C --> D[Launch commitment]
  D --> E[Tool side effect]
  E --> F[Lifecycle and transcript events]
Loading

Before merge

  • Resolve merge risk (P1) - This changes exported loop execution and lifecycle-event ordering around prepared tool calls; exact-head CI should confirm the current-main integration before merge.
  • Resolve merge risk (P1) - Transcript ownership and tool-result ordering are session-sensitive even though the focused regression coverage is strong.
Agent review details

Security

None.

PR surface

Source -62, Tests +270. Total +208 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 476 538 -62
Tests 1 302 32 +270
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 778 570 +208

Review metrics

Metric Value Why it matters
Production versus test delta production -62, tests +270 The repair consolidates production launch handling while adding targeted boundary regressions for context isolation and admission failure.

Merge-risk options

Maintainer options:

  1. Confirm exact-head lifecycle coverage (recommended)
    Let the exact PR-head checks finish and confirm the agent-loop regressions remain green against the current main merge result before landing.

Technical review

Best possible solution:

Land the canonical launch-boundary flow once exact-head validation confirms both the lifecycle contract and caller-transcript isolation on the current main base.

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

Yes, source-reproducible: current main launches ready parallel executions through Promise.all, while the PR’s coordinator closes admission immediately before each implementation starts; the new focused tests exercise the rejection and transcript paths.

Is this the best way to solve the issue?

Yes. Centralizing the commitment at the shared launch boundary removes the split admission state while preserving one lifecycle owner, rather than adding downstream guards.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 637da87a5da1.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor real-behavior-proof gate; the PR body and focused tests provide supplemental validation.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The PR repairs agent-tool dispatch and lifecycle behavior that can affect active user runs.
  • merge-risk: 🚨 compatibility: It changes behavior behind exported Agent Core loop entry points and their event/error sequencing.
  • merge-risk: 🚨 session-state: It changes transcript-array ownership and the ordering of lifecycle and tool-result events.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor real-behavior-proof gate; the PR body and focused tests provide supplemental validation.

Evidence

What I checked:

  • Current-main behavior: Current main prepares each parallel tool call, then invokes every ready execution through Promise.all; each execution commits immediately before its implementation callback. The PR replaces this with a single launch coordinator that stops later calls when the commit rejects. (packages/agent-core/src/agent-loop.ts:1078, 637da87a5da1)
  • Launch-boundary implementation: The current head creates the caller-owned working transcript with an unconditional array clone and routes ready calls through launchParallelToolCalls, where the lifecycle commit happens immediately before implementation start. (packages/agent-core/src/agent-loop.ts:236, 424955d35f73)
  • Owner-boundary contract: The embedded runner attaches the private lifecycle bridge, and the owner records history only in commitReadyCalls while releaseSkippedCalls removes unlaunched admission markers. (src/agents/tool-loop-admission.ts:213, 637da87a5da1)
  • Regression coverage: The new tests cover empty-prompt and continuation context isolation, sequential and parallel admission-commit failure pairing, and waiting for already-started parallel work before Agent becomes idle. (packages/agent-core/src/agent-loop.test.ts:277, 424955d35f73)
  • History and diff provenance: The exact head is a single commit atop 2d465c2; its three-file diff is 302 additions/32 deletions in tests, 475/537 in production, and a comment-only hook adjustment. The reachable history is shallow/grafted, so older feature provenance is limited. (packages/agent-core/src/agent-loop.ts:1127, 424955d35f73)
  • No Codex dependency signal: The changed agent-core files and package manifest contain no Codex import, harness, protocol, or compatibility claim, so sibling Codex inspection is not applicable under the dependency gate. (packages/agent-core/package.json:1, 424955d35f73)

Likely related people:

  • Peter Steinberger: The reachable current-main snapshot includes an Agent Core update by Peter, and the PR head is the current focused repair to the same agent-loop owner boundary; deeper attribution is limited by grafted history. (role: recent agent-core contributor; confidence: medium; commits: 2d85e9c50322, 424955d35f73; files: packages/agent-core/src/agent-loop.ts, packages/agent-core/src/agent-loop.test.ts, src/agents/tool-loop-admission.ts)

Rank-up moves

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

  • Allow the exact-head agent-core checks to complete before merge.

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 (3 earlier review cycles)
  • reviewed 2026-08-25T12:23:22.959Z sha 1c4eb75 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-25T13:00:04.616Z sha 1c4eb75 :: found issues before merge. :: [P2] Preserve caller context isolation for empty prompt runs
  • reviewed 2026-08-25T13:32:19.242Z sha 1c4eb75 :: needs changes before merge. :: [P2] Clone messages for empty-prompt runs

@clawsweeper clawsweeper Bot added 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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed 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 Aug 25, 2026
@steipete
steipete force-pushed the codex/cleanup-aug25-agent-core-tool-batch branch from 1c4eb75 to 424955d Compare August 26, 2026 02:17
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 26, 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:

@clawsweeper clawsweeper Bot added 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. and removed 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. labels Aug 26, 2026
@steipete
steipete merged commit 39535f2 into main Aug 26, 2026
131 checks passed
@steipete
steipete deleted the codex/cleanup-aug25-agent-core-tool-batch branch August 26, 2026 02:41
@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

maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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