perf(web): reasoning rows skip the tool-failure text scan #21146
main fromrefs/pull/21146/head·merged by juliusmarminge View on GitHubEvery timeline derivation ran the tool-failure regexes over each reasoning row's detail, which is the model's own thinking text. A long thread holds thousands of reasoning rows averaging ~5 KB (up to 70 KB), and deriveTurnFolds and withoutSubagentDelegationRows both check every work entry. That scan was the single largest app-owned script cost in the long frames while a reply streams, and it also marked reasoning as a failed tool whenever the prose mentioned something like "that exit code 2 is expected" (35 of 8,438 reasoning rows in the test data).
Reasoning rows now skip the text scan. Real tool rows are unchanged: command rows still use the server's outputIndicatesFailure, and tool rows still scan their detail.
Measured on a production build (vp build --minify false), headless Chromium, seeded with the same migrate-dev-db snapshot (large thread: 2,637 messages, 1,739 reasoning items). CDP trace per window; long tasks are main-thread RunTask of 50 ms or more. Each row is the median of 3 runs, alternating the build order (main and this branch on the same machine).
| Window | Metric | main | this PR |
|---|---|---|---|
| Switch 3 threads x3 | long-task ms (≥50 ms) | 1,363 | 1,310 |
| Switch 3 threads x3 | toolOutputIndicatesFailure ms inside long tasks | 83 | 0 |
| Switch 3 threads x3 | ScriptDuration ms | 1,561 | 1,485 |
| Open large thread (warm, n=6) | long-task ms | 519 | 490 |
| Open large thread (warm, n=6) | toolOutputIndicatesFailure ms | 26 | 0 |
| Open large thread (cold) | long-task ms | 510 | 466 |
Long-task counts do not change for open and switch: those frames are dominated by list measurement and React commit work, and this removes 5–10% of each frame. The bigger win is streaming, where the timeline re-derives on every delta. On main, three traced full Haiku turns in the large thread spent 1,263 / 749 / 336 ms inside this regex, 25%, 21% and 20% of all long-task time in those turns, and the largest single cost in each (CDP trace, attributed by stack). On this branch that cost is gone by construction. Streaming wasn't A/B'd because each turn depends on live provider pacing.
Tests: packages/client-runtime/src/work-log/presentation.test.ts (new case for reasoning prose), and apps/web/src/session-logic.test.ts plus MessagesTimeline.logic.test.ts still pass.
Claude Opus 5.5 via Claude Code.
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
95d9d68Macroscope's review found this PR approvable — This is a small, covered client-runtime fix that prevents model reasoning prose from being scanned as tool output while preserving explicit and real tool failure states. Its runtime impact is limited to more accurate reasoning-row status and reduced processing cost, with no defaults, schemas, infrastructure, or static-analysis overrides changed.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
7bd62dc4-d52c-46dc-970d-0c4825a9742a
📥 Commits
-
Reviewing files that changed from the base of the PR and between eb1d80c66765072dd7fd9f96c365820cbae3d48b and 95d9d683fa5abbf1f60b089eb5b26558a0f802fb.
📒 Files selected for processing: 2
-
packages/client-runtime/src/work-log/presentation.test.tspackages/client-runtime/src/work-log/presentation.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
-
📝 Walkthrough
-
The tool failure detection logic now excludes reasoning entries. A test confirms that failure-like phrases in completed reasoning text do not report a tool failure.
Changes: Tool failure detection
Layer / File(s) Summary Exclude reasoning entries from failure detection
packages/client-runtime/src/work-log/presentation.ts,packages/client-runtime/src/work-log/presentation.test.tsworkEntryIndicatesToolFailureFromOutputreturnsfalsefor reasoning entries. Tests cover reasoning text that mentions an exit code and a deleted directory.Priority: ➖ Normal
Estimated code review effort: 1 (Trivial) | ~5 minutes
Change: Bug fix
Suggested reviewers:
t3dotgg
Merge Risk: ⚪ Minimal · up to
95d9d-
Reasoning text will no longer be mistaken for tool failure, while command and tool failure detection remains unchanged. No material merge risk is indicated.
Pre-merge checks:
3 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Description check The description clearly explains the problem, implementation, performance measurements, tests, and agent attribution. It does not include the required Scope and approval information or explain why thi… Add the Scope and approval section. Link the triaged issue or maintainer approval with the approval comment, or explain why this focused fix qualifies as an obvious bug without prior approval. Passed checks: 3 passed-
Check name Status Explanation Title check The title clearly and concisely describes the main change: reasoning rows skip the tool-failure text scan. Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request.
Full details: Description check
-
Explanation
The description clearly explains the problem, implementation, performance measurements, tests, and agent attribution. It does not include the required Scope and approval information or explain why this focused fix qualifies for an exemption.
Resolution
Add the Scope and approval section. Link the triaged issue or maintainer approval with the approval comment, or explain why this focused fix qualifies as an obvious bug without prior approval.
-
- Fix all pre-merge checks with AI
✨ Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
juliusmarminge merged thise0366ad
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes