Skip to content

fix(agents): attribute tool preparation delays to the correct stages - #148349

Merged
steipete merged 2 commits into
mainfrom
codex/attempt-bundle-stage-timing-20260915
Sep 14, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/attempt-bundle-stage-timing-20260915

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes misleading embedded preparation logs when MCP or LSP preparation takes time: the wait was attributed to code-mode, while bundle-tools measured later bookkeeping.

User Impact

Operators can distinguish awaited bundle preparation from synchronous tool-catalog construction. This changes diagnostic attribution, not tool behavior or preparation speed.

Why This Change Was Made

Measure bundle-tools and tool-catalog inside the existing admitted callbacks. Keep one inclusive tool-preparation checkpoint so later stages do not charge those intervals again; the documentation explains that these entries overlap and must not be summed. Existing log identity fields, warning thresholds, catalog activation messages, admission and cleanup remain intact. Permission refresh no longer appends initial-preparation checkpoints.

Evidence

The regression drives the real embedded-attempt sequence with a deferred synthetic LSP runtime and a controlled clock. On the original source, a 6,000 ms bundle wait appeared as code-mode:6000, bundle-tools:0, and the 37 ms catalog cost appeared under system-prompt. The corrected flow reports bundle-tools:6000, tool-catalog:37, tool-preparation:6037, and system-prompt:0, with successful completion and exactly one LSP disposal.

The initial patch head (87614efdde1ec27669f6720fc5080e68de4d8104) passed the timing/privacy regressions, 60 focused sibling cases, the full selected repository check, and independent P2 autoreview. Linux controlled-clock proof passed both real-attempt tests on that head. After incorporating main, the PR delta remained byte-identical; current head 25054712ea775e31b0fbe56ee189d49e7ebe3229 passed ten focused diagnostics/wizard-recovery cases and exact-head CI, including openclaw/ci-gate, without a CI rerun.

Real-request Blacksmith Testbox proof ran an ordinary Anthropic Code Mode request on exact current head with Node 24.19.0 and pnpm 12.3.4. The exported runtime and transcript records identify a successful nested read of proof.txt, its matching result, and the exact expected final reply. The same run/session/process reports preparation of 162 ms, with bundle-tools:57, tool-catalog:10, tool-preparation:68, and system-prompt:13. The inclusive checkpoint overlaps the two owner spans. The complete agent CLI capture took 9,398 ms.

The full build and all twelve expected capture-control outcomes passed. Source/build snapshots were identical before and after the request; the agent, session lookup and trajectory export captures closed without errors or forced cleanup, and the isolated worktree and lease were closed. The exported exec program is redacted: the evidence supports the recorded file-read path and corrected timing attribution, but does not establish program contents or absence of other actions. These elapsed times are observations from one synthetic live request, not CPU measurements, throughput results, or a production-stall improvement claim.

@clawsweeper

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

@steipete
steipete marked this pull request as ready for review September 14, 2026 15:42
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 4:24 PM ET / 20:24 UTC (Revision 3).

ClawSweeper review

What this changes

Separates awaited tool preparation from synchronous catalog construction in agent startup logs and documents the overlapping timing intervals.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main and the latest release retain the misleading attribution. No actionable correctness or security findings remain.

Priority: P2
Reviewed head: 25054712ea775e31b0fbe56ee189d49e7ebe3229

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary correction with a meaningful attribution regression, explicit overlap documentation, and relevant live-request observations.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied exact-head Testbox observations exercise an ordinary Anthropic request through the changed runner and report separate bundle/catalog timings alongside a successful nested read and final reply. Controlled-clock regression evidence supplements that live observation; raw workflow logs could not be independently inspected because of the reviewer network restriction.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied exact-head Testbox observations exercise an ordinary Anthropic request through the changed runner and report separate bundle/catalog timings alongside a successful nested read and final reply. Controlled-clock regression evidence supplements that live observation; raw workflow logs could not be independently inspected because of the reviewer network restriction.
Evidence reviewed 9 items Current main still needs the correction: Fetched main still records code-mode or tool-search inside catalog construction, followed by the misleading bundle-tools checkpoint.
Latest-release check: The catalog source in v2026.9.4 retains both old checkpoints. The GitHub tag object resolves to the supplied release commit.
Correct production timing boundaries: The introduced spans execute inside existing admitted callbacks. The shared tracker records spans without advancing checkpoints, and tool-preparation advances the checkpoint before system-prompt work. Resource acquisition, cleanup ownership, and permission decisions remain unchanged.
Findings None None.
Security None None.

How this fits together

The embedded agent runner prepares tools before submitting a model request. Its timing summaries help operators locate startup delays across bundle preparation, catalog construction, and prompt assembly.

flowchart LR
  A[Agent request] --> B[Preparation admission]
  B --> C[Await bundle tools]
  C --> D[Build tool catalog]
  D --> E[Assemble system prompt]
  C --> F[Preparation timing summary]
  D --> F
  E --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0, Tests +59, Docs +24. Total +83 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 31 31 0
Tests 1 60 1 +59
Docs 1 24 0 +24
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 115 32 +83

Review metrics

None.

Technical review

Best possible solution:

Keep timing at the preparation owners, preserve existing admission and cleanup, and document that explicit spans overlap the inclusive checkpoint.

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

Yes, from source: awaited bundle work precedes the catalog's old checkpoint, so that wait receives the wrong stage name. The supplied controlled-clock regression demonstrates the distinction; this review did not execute it.

Is this the best way to solve the issue?

Yes. Reusing the shared tracker's explicit spans at the actual preparation boundaries fixes attribution without introducing another timing owner or changing tool policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied exact-head Testbox observations exercise an ordinary Anthropic request through the changed runner and report separate bundle/catalog timings alongside a successful nested read and final reply. Controlled-clock regression evidence supplements that live observation; raw workflow logs could not be independently inspected because of the reviewer network restriction.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Misleading startup timing hampers diagnosis, but this correction does not change tool execution or runtime availability.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied exact-head Testbox observations exercise an ordinary Anthropic request through the changed runner and report separate bundle/catalog timings alongside a successful nested read and final reply. Controlled-clock regression evidence supplements that live observation; raw workflow logs could not be independently inspected because of the reviewer network restriction.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied exact-head Testbox observations exercise an ordinary Anthropic request through the changed runner and report separate bundle/catalog timings alongside a successful nested read and final reply. Controlled-clock regression evidence supplements that live observation; raw workflow logs could not be independently inspected because of the reviewer network restriction.

Evidence

What I checked:

  • Current main still needs the correction: Fetched main still records code-mode or tool-search inside catalog construction, followed by the misleading bundle-tools checkpoint. (src/agents/embedded-agent-runner/run/attempt-tool-catalog.ts:168, dcc64f10d5c4)
  • Latest-release check: The catalog source in v2026.9.4 retains both old checkpoints. The GitHub tag object resolves to the supplied release commit. (src/agents/embedded-agent-runner/run/attempt-tool-catalog.ts:168, 3a9d69db306c)
  • Correct production timing boundaries: The introduced spans execute inside existing admitted callbacks. The shared tracker records spans without advancing checkpoints, and tool-preparation advances the checkpoint before system-prompt work. Resource acquisition, cleanup ownership, and permission decisions remain unchanged. (src/agents/embedded-agent-runner/run/attempt.ts:261, 25054712ea77)
  • Regression protects observable attribution: The test drives the production attempt sequence with controlled LSP waiting and catalog work, checking 6000 ms bundle-tools, 37 ms tool-catalog, 6037 ms inclusive preparation, zero spill into system-prompt, successful completion, and one disposal. Tests were inspected, not executed during this read-only review. (src/agents/embedded-agent-runner/run/attempt.spawn-workspace.diagnostics.test.ts:39, 25054712ea77)
  • Supplied real-request observations: The complete supplied body, captured under sourceRevision 2aa04193c95fbf93257f43d9cf186392c443e8da52d86f1a9f32a66c40582fe7, reports an exact-head Anthropic request in Blacksmith Testbox on Node 24.19.0: a successful nested file read and expected final reply, with bundle-tools 57 ms, tool-catalog 10 ms, inclusive tool-preparation 68 ms, and system-prompt 13 ms. These observations directly cover the changed diagnostic output; they do not claim a speed improvement. (25054712ea77)
  • Independent proof-inspection limit: The linked Testbox workflow https://github.com/openclaw/openclaw/actions/runs/34889007312 has a cancelled overall conclusion and a workflow head distinct from the reported tested worktree. Its cleanup steps succeeded. Fetching job logs was blocked at GitHub's backing storage host, so the raw request capture was not independently inspected; workflow metadata alone neither verifies nor disproves the supplied request observations.

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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-14T16:15:22.429Z sha 87614ef :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-14T16:54:47.474Z sha 2505471 :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 14, 2026
@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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 14, 2026
@steipete
steipete merged commit c3842f0 into main Sep 14, 2026
202 checks passed
@steipete
steipete deleted the codex/attempt-bundle-stage-timing-20260915 branch September 14, 2026 20:25
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 14, 2026
vincentkoc added a commit that referenced this pull request Sep 14, 2026
* origin/main:
  perf(secrets): keep pure helpers out of file writer imports (#148096)
  perf(models): normalize suppression policy once per compilation (#148428)
  test: route provider integration and wizard recovery tests correctly (#148504)
  test: reuse prepared bundled plugins in startup corpus (#148465)
  fix(agents): attribute tool preparation delays to the correct stages (#148349)
  refactor: remove redundant Parallels source checks (#148394)
  fix(test): avoid timeout failures before descendant readiness (#148410)
  fix: open browser side panel without creating a dashboard (#148471)
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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