Repository navigation
fix(agents): attribute tool preparation delays to the correct stages - #148349
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 4:24 PM ET / 20:24 UTC (Revision 3). ClawSweeper reviewWhat this changesSeparates 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 Review scores
Verification
How this fits togetherThe 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
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource 0, Tests +59, Docs +24. Total +83 across 5 files. View PR surface stats
Review metricsNone. Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
* 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)
What Problem This Solves
Fixes misleading embedded preparation logs when MCP or LSP preparation takes time: the wait was attributed to
code-mode, whilebundle-toolsmeasured 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-toolsandtool-cataloginside the existing admitted callbacks. Keep one inclusivetool-preparationcheckpoint 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 undersystem-prompt. The corrected flow reportsbundle-tools:6000,tool-catalog:37,tool-preparation:6037, andsystem-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 head25054712ea775e31b0fbe56ee189d49e7ebe3229passed ten focused diagnostics/wizard-recovery cases and exact-head CI, includingopenclaw/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
readofproof.txt, its matching result, and the exact expected final reply. The same run/session/process reports preparation of 162 ms, withbundle-tools:57,tool-catalog:10,tool-preparation:68, andsystem-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
execprogram 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.