12 KiB
Consolidated Tool Card โ Design Spec
Replaces per-tool-call messages with a single, auto-updating "tool card" per prompt turn. Plan updates render inline within the same card.
Problem
Each tool_call event creates a separate message. An agent calling 10-20 tools floods the chat with short 1-line messages, pushing the actual text response off-screen. Users have to scroll past tool noise to see what the agent said. Plan events add a second card that interleaves with tool messages, making it worse.
Solution
Consolidate all tool calls AND plan updates within a prompt turn into one message (the "tool card") that updates in place as tools execute.
Verbosity Tiers
All three tiers show the full tool list. They differ in noise filtering and detail level.
| Verbosity | Noise tools (ls, dir reads, glob) | Viewer links | Input/Output details |
|---|---|---|---|
| Low | Hidden | Yes | No |
| Medium | Hidden | Yes | No |
| High | Shown | Yes | Yes |
Low โ Compact
Full list, noise tools filtered out. Viewer links shown inline.
๐ Tools (6/8)
โ
๐ Read src/main.ts
โ
โ๏ธ Edit src/config.ts ๐ View diff
โ
๐ Read src/types.ts
โ
๐ Grep "TODO" in src/
โ
โ๏ธ Edit src/utils.ts ๐ View diff
โ
๐ Read src/utils.ts
โโ Plan: 2/3 โโ
โ
1. Set up project
๐ 2. Implement API
โฌ 3. Write tests
โโโโ
๐ โถ๏ธ Run: pnpm test
When complete:
๐ Tools (8/8) โ
โ
๐ Read src/main.ts
โ
โ๏ธ Edit src/config.ts ๐ View diff
โ
๐ Read src/types.ts
โ
๐ Grep "TODO" in src/
โ
โ๏ธ Edit src/utils.ts ๐ View diff
โ
๐ Read src/utils.ts
โ
โถ๏ธ Run: pnpm test
โ
๐ Read package.json
โโ Plan: 3/3 โโ
โ
1. Set up project
โ
2. Implement API
โ
3. Write tests
โโโ
๐ 12.5K tokens ยท $0.05
Medium
Same as Low. Noise tools filtered out. Viewer links shown inline.
Low and Medium currently render identically. Medium exists as a tier for future differentiation (e.g., additional metadata, grouping).
๐ Tools (6/8)
โ
๐ Read src/main.ts
โ
โ๏ธ Edit src/config.ts ๐ View diff
โ
๐ Read src/types.ts
โ
๐ Grep "TODO" in src/
โ
โ๏ธ Edit src/utils.ts ๐ View diff
โ
๐ Read src/utils.ts
โโ Plan: 2/3 โโ
โ
1. Set up project
๐ 2. Implement API
โฌ 3. Write tests
โโโโ
๐ โถ๏ธ Run: pnpm test
High โ Full Detail
All tools shown (including noise tools). Viewer links + input/output details.
๐ Tools (6/10)
โ
๐ Read src/main.ts
โ
๐ Glob **/*.ts
โ
โ๏ธ Edit src/config.ts ๐ View file ยท ๐ View diff
โ
๐ Read src/types.ts
โ
๐ Read src/ (directory)
โ
๐ Grep "TODO" in src/
โ
โ๏ธ Edit src/utils.ts ๐ View file ยท ๐ View diff
โ
๐ Read src/utils.ts
โโ Plan: 2/3 โโ
โ
1. Set up project
๐ 2. Implement API
โฌ 3. Write tests
โโโโ
๐ โถ๏ธ Run: pnpm test
โฌ ๐ Read package.json
โโโ
๐ 12.5K tokens ยท $0.05
Card Lifecycle
tool_call(id=1) โ Create card message with 1 entry (๐ status)
tool_update(id=1) โ Edit card: entry 1 โ โ
, add viewer links
tool_call(id=2) โ Edit card: append entry 2 (๐)
plan(entries) โ Edit card: render plan section inline
tool_update(id=2) โ Edit card: entry 2 โ โ
...
usage event โ Edit card: append usage line at bottom
session_end โ Card becomes immutable
Finalization
- Card stays as-is (full state preserved) on all verbosity levels
- Usage line appended at bottom with separator
- Card becomes immutable โ no further edits
Usage Timing
Usage events can arrive after text response. The card accepts appendUsage() even after text starts โ only session_end makes the card truly immutable. This matches the actual ACP event order: tools โ text โ usage โ session_end.
Next Prompt Turn
A new prompt from the user creates a new tool card for the next batch. Previous card is immutable.
Inline Plan
Plan updates render as a section within the tool card instead of a separate PlanCard message.
Placement: Plan section appears after the most recent completed tool entries, before any running/pending tools. When plan updates arrive, the section is replaced in-place.
Format (same across all verbosity levels โ plan always shows full):
โโ Plan: 2/3 โโ
โ
1. Set up project
๐ 2. Implement API
โฌ 3. Write tests
No plan events: If the agent never sends a plan event, no plan section appears. The card is tools-only.
PlanCard deprecation: The existing standalone PlanCard in activity.ts is replaced by the inline plan section. PlanCard classes in Discord/Telegram activity trackers will be removed.
Debounce Strategy
To avoid API rate limits (Telegram: ~30 edits/s global, Discord: 5 edits/10s per message):
- Debounce window: 500ms โ collect all changes within the window, then flush once
- Immediate first render: First tool_call sends immediately (no debounce)
- Force flush on finalize: When usage/session_end arrives, flush immediately
This matches the existing PlanCard debounce pattern.
Viewer Links
Inline after each tool entry that has links:
| Platform | Format |
|---|---|
| Discord (embed) | โ
โ๏ธ Edit src/config.ts [View file](url) ยท [View diff](url) |
| Telegram (HTML) | โ
โ๏ธ Edit src/config.ts ๐ <a href="url">View file</a> ยท ๐ <a href="url">View diff</a> |
| Slack (blocks) | Context block with link elements |
Links only appear after tool_update with completed status delivers them.
Status Icons
| Status | Icon | Notes |
|---|---|---|
| Running / In Progress | ๐ | Only status from ACP tool_call |
| Completed | โ | From tool_update |
| Failed | โ | From tool_update |
ACP does not send a "pending/queued" state. Tools appear in the card only when they start running.
Noise Filtering
Noise tools are hidden on low and medium, shown on high:
lstool: hidden on low/medium- Directory reads (path ends with
/): hidden on low/medium globtool: hidden on low/mediumgreptool: hidden on low/medium
Hidden tools are NOT counted in the header total. ๐ Tools (5/5) means 5 visible tools, even if ls/grep were called many times in the background. This avoids confusing users with mismatched counts.
Architecture
ToolCard replaces platform ToolCallTrackers
The current architecture has 3 layers:
SharedToolCallTracker(state only) โ keptDiscordToolCallTracker(state + send/edit) โ replaced by ToolCardTelegramToolCallTracker(state + send/edit) โ replaced by ToolCard
ToolCard = renderer + message manager. It reads state from SharedToolCallTracker.
ToolCard class
ToolCard
โโโ entries: ToolCardEntry[] โ ordered list of tool calls
โโโ planEntries?: PlanEntry[] โ current plan state (if any)
โโโ usage?: UsageData โ appended at bottom
โโโ verbosity: DisplayVerbosity โ controls rendering tier
โโโ messageId?: string/number โ the single card message
โโโ debounce timer โ 500ms flush window
โโโ finalized: boolean โ true after session_end
โ
โโโ addTool(meta: ToolCallMeta) โ append new entry, schedule flush
โโโ updateTool(id, status, links?) โ update entry, schedule flush
โโโ updatePlan(entries: PlanEntry[])โ replace plan section, schedule flush
โโโ appendUsage(usage) โ set usage data, force flush
โโโ finalize() โ force flush, mark immutable
โโโ destroy() โ clear timers
โ
โโโ _flush() โ render + send/edit message
ToolCardEntry
interface ToolCardEntry {
id: string;
name: string;
kind?: string;
status: string;
icon: string; // resolved via resolveToolIcon
label: string; // from formatToolSummary/formatToolTitle
viewerLinks?: ViewerLinks;
viewerFilePath?: string;
hidden: boolean; // true if noise-filtered
}
Rendering
Each platform has a renderToolCard(card: ToolCardState) function in its formatting.ts:
- Discord: Returns markdown string for embed description (consistent with existing PlanCard embed usage)
- Telegram: Returns HTML string
- Slack: Returns Block Kit blocks
Integration with Adapter
handleToolCall() โ toolCard.addTool(meta)
handleToolUpdate() โ toolCard.updateTool(id, status, links)
handlePlan() โ toolCard.updatePlan(entries)
handleUsage() โ toolCard.appendUsage(usage)
handleSessionEnd() โ toolCard.finalize()
ActivityTracker integration:
onToolCall()โ dismiss thinking indicator +toolCard.addTool()onPlan()โtoolCard.updatePlan()cleanup()โtoolCard.finalize()+toolCard.destroy()
What Changes
| Component | Before | After |
|---|---|---|
handleToolCall |
Send new message via platform ToolCallTracker | toolCard.addTool() |
handleToolUpdate |
Edit per-tool message | toolCard.updateTool() |
handlePlan |
Separate PlanCard message | toolCard.updatePlan() |
handleUsage |
Separate usage message | toolCard.appendUsage() |
| Platform ToolCallTrackers | Send/edit messages | Deleted |
| PlanCard | Separate embed/message | Deleted (inline in ToolCard) |
What Stays the Same
MessagingAdapterdispatch flowMessageTransformerevent mappingformatToolSummary/formatToolTitle/resolveToolIcon(reused by ToolCard)- Noise filtering logic (
evaluateNoise) - Shared
ToolCallTrackerfor state tracking
Edge Cases
- No tools called: No card created. Usage rendered standalone as before.
- Single tool: Card still created (consistent UX).
- Agent tool (long-running): Shows ๐ until completed โ card updates when subagent finishes.
- Tool fails: Entry shows โ, card continues for remaining tools.
- 30+ tools on medium: Cap at 5 visible, rest collapsed. Header shows
(5/30)visible count. - Message length limit: If card exceeds platform limit (Telegram 4096, Discord 4096 embed), truncate oldest completed entries with
... N moreregardless of verbosity. - Rate limit hit: Debounce handles this. If edit still fails, log warning and retry on next flush.
- Plan without tools: If only plan events arrive (no tool calls), card still created with plan section only.
- Multiple plan updates: Each
planevent replaces the previous plan section entirely. - Usage after text: Accepted. Card only becomes immutable on
session_end.
Platform Rendering
Discord
- Card rendered as Embed with colored sidebar
- Embed description contains the full card content (markdown)
- Consistent with existing PlanCard embed pattern
- 4096 char embed description limit
Telegram
- Card rendered as plain HTML message
parse_mode: "HTML"withdisable_notification: true- 4096 char message limit
Slack
- Card rendered as Block Kit blocks
- Section blocks for content, context blocks for metadata
- 3000 char per section limit
Platform Limits
| Platform | Message edit limit | Max message length | Debounce |
|---|---|---|---|
| Telegram | ~30/s global | 4096 chars | 500ms |
| Discord | 5/10s per channel | 4096 embed desc | 500ms |
| Slack | Generous | 3000 per section | 500ms |
Files to Create/Modify
New Files
src/core/adapter-primitives/primitives/tool-card.tsโ shared ToolCard logic (state, debounce, flush orchestration)
Modified Files
src/plugins/discord/formatting.tsโ addrenderToolCard()src/plugins/telegram/formatting.tsโ addrenderToolCard()src/plugins/slack/formatter.tsโ add tool card block renderingsrc/plugins/discord/adapter.tsโ wire ToolCard, remove PlanCard/ToolCallTracker usagesrc/plugins/telegram/adapter.tsโ wire ToolCard, remove PlanCard/ToolCallTracker usagesrc/plugins/discord/activity.tsโ replace PlanCard + ToolCallTracker with ToolCardsrc/plugins/telegram/activity.tsโ replace PlanCard + ToolCallTracker with ToolCard
Deleted Files
src/plugins/discord/tool-call-tracker.tsโ replaced by ToolCardsrc/plugins/telegram/tool-call-tracker.tsโ replaced by ToolCard