feat(advisor): render /advisor calls as tool rows with token accounting
Summary
Renders /advisor tool calls as normal tool rows in the timeline, adds token accounting for advisor output, and an eval-report display.
What changed
- Advisor rendering:
/advisorcalls now render as standard tool rows instead of being dropped (#175). - Token accounting: Advisor output tokens are counted, empty input is labeled, and advisor usage surfaces in the context panel.
- Eval report display: new renderer path for eval reports, plus tool-row improvements.
- Tool-name string utils: shared helpers in
stringUtils.tsfor tool-name formatting, used by linking + summaries. - Types:
jsonl.ts/messages.tsextended foradvisor_tool_result/server_tool_use. - Hardening: guard
block.content.text; harden a test literal.
Tests
SemanticStepExtractor.test.ts,displayItemBuilder.test.ts,renderHelpers.test.ts,stringUtils.test.ts,toolLinkingEngine.test.ts,toolTokens.test.ts- New fixture:
test/mocks/advisorBlocks.fixture.ts
Scope
20 files changed (feature code + tests). Single squashed commit.
Summary by CodeRabbit
-
New Features
- Added support for advisor tool functionality with proper semantic step tracking and result linking.
- Added npm scripts (
standalone:kill,standalone:restart) for managing standalone mode processes.
-
UI Improvements
- Tool names now display with proper capitalization across all tool displays.
- Empty tool parameters now show a "no parameters" placeholder instead of blank fields.
-
Improvements
- Enhanced token counting logic for advisor tool results.
📝 Walkthrough
Walkthrough
This PR adds end-to-end support for an "advisor" server tool flow: new JSONL content types encode advisor calls and results, messages carry advisorModel metadata, semantic steps are extracted for advisor interactions, display items are built and linked, tools are rendered with capitalized names and source-model labels, and token accounting skips estimation for advisor calls while counting result tokens. Additionally, standalone mode scripts are added for process lifecycle management.
Changes
Advisor Tool Flow Support
| Layer / File(s) | Summary |
|---|---|
Type contracts for advisor blocks src/main/types/jsonl.ts, src/main/types/messages.ts |
New ServerToolUseContent and AdvisorToolResultContent interfaces, extended ContentBlock union, and optional advisorModel field in AssistantEntry and ParsedMessage to represent advisor tool invocations. |
JSONL parsing with advisor metadata src/main/utils/jsonl.ts |
parseChatHistoryEntry extracts advisorModel from assistant entries and propagates it into the returned ParsedMessage. |
Semantic step extraction for advisor src/main/services/analysis/SemanticStepExtractor.ts |
extractSemanticStepsFromAIChunk detects server_tool_use blocks (advisor) and emits tool_call steps with sourceModel; detects advisor_tool_result blocks and emits tool_result steps with token counts from advice text. |
Advisor semantic extraction tests and fixtures test/mocks/advisorBlocks.fixture.ts, test/main/services/analysis/SemanticStepExtractor.test.ts |
Mock advisor call and result messages; test suite verifies tool_call/tool_result step emission and token accounting. |
Display item construction from advisor messages src/renderer/utils/displayItemBuilder.ts, test/renderer/utils/displayItemBuilder.test.ts |
buildDisplayItemsFromMessages records advisor tool calls and results into indexed maps for later linking; subagent-input detection refined to exclude messages with tool results. |
Tool name capitalization utility src/renderer/utils/stringUtils.ts, test/renderer/utils/stringUtils.test.ts |
New capitalize helper function and test coverage for name formatting. |
Tool rendering with formatting and summaries src/renderer/components/chat/items/linkedTool/renderHelpers.tsx, src/renderer/utils/toolRendering/toolSummaryHelpers.ts, src/renderer/components/chat/items/LinkedToolItem.tsx, src/renderer/components/chat/SessionContextPanel/items/ToolBreakdownItem.tsx, src/renderer/components/chat/SessionContextPanel/components/RankedInjectionList.tsx, test/renderer/utils/renderHelpers.test.ts |
renderInput renders empty inputs as "no parameters" placeholder; getToolSummary accepts optional sourceModel and returns it for advisor tools; components use capitalize for display names and pass sourceModel through summary generation. |
Token accounting for advisor tool calls src/renderer/utils/toolLinkingEngine.ts, test/renderer/utils/toolLinkingEngine.test.ts, test/renderer/utils/toolRendering/toolTokens.test.ts |
linkToolCallsToResults sets callTokens to undefined for advisor calls (skipping estimation) while counting result tokens. |
Standalone Mode Process Management
| Layer / File(s) | Summary |
|---|---|
Standalone lifecycle scripts package.json |
Added standalone:kill to terminate process on port 3456 and standalone:restart to chain kill → build → start commands. |
Suggested labels
feature request
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.