feat(cli): add an opt-in tool/approval wall-time bottleneck report for unattended runs (#220)#221
Merged
Conversation
…r unattended runs (#220) A long autonomous run could look healthy in the aggregate run summary while one slow tool or one long approval gate dominated its wall-time, with no way to tell where the time went short of parsing raw logs. Add a privacy-safe, bounded bottleneck report (opt-in --bottleneck) that ranks tools and approval gates by wall-time and call count, in both the NDJSON headless stream and the plain-text path. The report is metadata only (tool names, wall-time, counts) and has no channel for prompts, file contents, secrets, or raw tool payloads.
Owner
Author
E2E verification
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in (
--bottleneck) privacy-safe wall-time bottleneck report for unattended (-p) runs, decomposed from roadmap #38 (observable autonomous execution).A long run could look healthy in the aggregate run summary (#40) while one slow tool or one long approval gate dominated its wall-time, with no way to tell where the time went short of parsing raw logs. This report ranks tools and approval gates by wall-time and call count so an operator can target the real bottleneck.
Design
src/run-bottleneck.ts: aBottleneckCollectoraccumulates per-tool execution wall-time and per-approval-gate wait wall-time;buildranks entries by wall-time (desc), head-bounds to 16, and reports the truncated count. Mirrors therun-summary.tsschema/redaction conventions.src/agent.ts:executeToolCalltimes the approval gate (requestApproval) and the tool execution (tool.execute) separately, recording into an optional collector threaded throughAgentOptions.src/headless-protocol.ts: newbottleneckNDJSON event.src/index.ts: opt-in--bottleneckflag wired into both the NDJSON and plain-text headless paths.The report is metadata only — tool names, wall-time, and counts. It has no channel for prompts, file contents, secrets, or raw tool payloads.
Testing
tests/unit/run-bottleneck.test.ts(13 tests): ranking, tool/approval separation, tie-breaks, head bound + truncation, name sanitization, empty inventory, formatting.tests/integration/run-bottleneck.test.ts(5 tests): text/JSON emission, a deliberately slow tool ranked first, secret-shaped arguments kept out of the report, empty inventory.Gates: typecheck, build, unit (1598), integration (433 + desktop), smoke (51) all pass.
Closes #220