Skip to content

feat: Stream tool call actions to UI early via tool-input-start parsing#56

Merged
homanp merged 1 commit intomainfrom
cursor/stream-tool-call-actions-early
Mar 25, 2026
Merged

feat: Stream tool call actions to UI early via tool-input-start parsing#56
homanp merged 1 commit intomainfrom
cursor/stream-tool-call-actions-early

Conversation

@homanp
Copy link
Copy Markdown
Owner

@homanp homanp commented Mar 25, 2026

Summary

  • Parse tool-input-start and tool-input-delta events from the AI SDK fullStream to show shimmer actions immediately when the model begins generating a tool call
  • Extract the specific file path (writeFile/readFile), command (bash), or query (web_search) from the streamed JSON arguments as soon as it appears — well before the full content is generated
  • Forward toolCallId and bash stdout/stderr/exitCode in tool-result SSE events for richer client-side handling

Before: The shimmer action (e.g. "Writing components/Chart.tsx") only appeared after the model finished generating the entire tool call arguments (including the full file content), then flashed briefly for ~700ms before clearing.

After: The shimmer appears as soon as the model starts a tool call with a generic label, then refines to the specific file path or command within milliseconds as the first few characters of the JSON arguments stream in. The action is visible for the entire duration of argument generation + tool execution.

Test plan

  • TypeScript compiles cleanly (tsc --noEmit)
  • All 47 existing tests pass (npm test)
  • ESLint passes via pre-commit hook
  • Manual: send a prompt that triggers writeFile — verify shimmer shows specific path early, not just after code is written
  • Manual: send a prompt that triggers bash — verify shimmer shows specific command early

Parse tool-input-start and tool-input-delta from the AI SDK fullStream
to show shimmer actions immediately when the model starts a tool call,
then refine with the specific file path or command as soon as it appears
in the streamed JSON arguments—before the full content is generated.
Also forward toolCallId and bash stdout/stderr/exitCode in tool-result
SSE events for richer client-side handling.
@github-actions github-actions bot added the contributor:verified Contributor passed trust analysis. label Mar 25, 2026
@homanp homanp changed the title Stream tool call actions to UI early via tool-input-start parsing feat: Stream tool call actions to UI early via tool-input-start parsing Mar 25, 2026
@homanp homanp marked this pull request as ready for review March 25, 2026 13:20
@homanp homanp self-assigned this Mar 25, 2026
@homanp homanp merged commit add3bca into main Mar 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:verified Contributor passed trust analysis.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant