Skip to content

feat(transcript): show cancelled tool calls and conversation optimization - #450

Merged
edenreich merged 3 commits into
mainfrom
feat/transcript-cancelled-tools
Nov 7, 2026
Merged

edenreich merged 3 commits into
mainfrom
feat/transcript-cancelled-tools

Conversation

@edenreich

@edenreich edenreich commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #442

Summary

The transcript now shows a cancelled tool call as cancelled and notes when the CLI optimized the conversation. The CLI sends both as ACTIVITY_SNAPSHOT events since inference-gateway/cli#1722 (infer v0.246.0): tool_progress with status cancelled, and optimization_status. A run you stop also marks its unfinished tool calls cancelled instead of done.

Changes

  • backend/src/agent.rs: activity() maps a tool_progress with status cancelled to ToolCancelled { tool_call_id }, and optimization_status to ConversationOptimized { message, original_count, optimized_count }. Every other tool_progress status stays ignored. Parser tests cover both.
  • frontend/lib/tauri.ts: the two new AgentEvent kinds.
  • frontend/lib/transcript.ts: ToolState gains cancelled, and the transcript gains an info item. ToolCancelled marks that call cancelled, even one an earlier run already finalized. finalizeTools only changes tools still running, and on a stopped run it marks them cancelled.
  • frontend/components/Transcript.tsx: the tool card's colours come from a per-state lookup. A cancelled card is grey with a muted name and a (cancelled) tag, distinct from done and failed. The optimization renders as a muted centred line, "Conversation optimized - 40 to 12 messages".
  • Tests: 4 bun test cases (a cancelled call, a cancel after the run finished, a stopped run, the optimization line), the write-stopped scenario and e2e/tests/stop-pending-tool.yaml.

Verification

  • The pre-commit hook ran on every commit: prettier, bun run build, cargo fmt --check, cargo clippy -- -D warnings, cargo check, cargo test (216 passed).
  • bun test 208 passed, cargo test -p desktop-e2e passes.
  • macOS e2e: stop-pending-tool.yaml 6/6, plus approval-approve.yaml, approval-deny.yaml and multi-tool.yaml for the tool cards around it.

Notes for review

  • The e2e does not show the CLI's cancelled activity. The CLI emits it only when a message queued mid-run is drained while the conversation still holds a tool call without a result (ensureConversationIntegrity from batchDrainQueue in internal/agent/loop/agent.go). The desktop cannot reach that deterministically. A Stop cancels before any drain, a stopped Bash returns a failed result, and the desktop queues prompts itself while a tool runs. The parser and reducer paths for the activity are covered by unit tests.
  • Extra behaviour (commit 3124011): stopping a run now ends a tool still waiting for its result as cancelled, where it read as done before - for example a Write stopped at its approval, which never ran. A run that ends on its own still marks open calls done. This is what the e2e demos, and reverting that commit drops it.
  • The optimization line appears only when the CLI compacts a conversation (compact.enabled, a known context window, past compact.auto_at), so it has no e2e.

Docs ticket

inference-gateway/docs#1119

…tion

A ToolCancelled event marks the tool call it names cancelled, a new tool state the run's end leaves alone, and the tool card renders it muted with a (cancelled) tag. A ConversationOptimized event adds a muted info line with the message counts before and after.
…ities

A tool_progress activity with status cancelled maps to ToolCancelled for its tool call id, and optimization_status to ConversationOptimized with the message and both counts. Every other tool_progress status stays ignored.
A tool call that still has no result when the user stops the run never ran - the CLI drops it with the run, and its approval expires. The transcript showed it as done. It now ends cancelled, and a run that ends on its own still finalizes its open calls as done. The stop-pending-tool e2e test stops a run at a Write approval and waits for the card to read (cancelled).
@edenreich
edenreich marked this pull request as ready for review November 7, 2026 17:45
@edenreich
edenreich merged commit 6c3e564 into main Nov 7, 2026
1 check passed
@edenreich
edenreich deleted the feat/transcript-cancelled-tools branch November 7, 2026 18:32
@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.55.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-maintainer inference-gateway-maintainer Bot added the released Shipped in a release label Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Show cancelled tool calls and conversation optimization in the transcript

1 participant