Skip to content

Add tool result streaming for long-running operations #2

@tombee

Description

@tombee

Problem

When tools execute long-running operations (shell commands, file processing), the agent and UI receive no feedback until the operation completes. This creates poor UX for:

  • Build commands that take minutes
  • Large file operations
  • Network requests with slow responses

Concrete example from foreman: Running npm test during implementation can take 30+ seconds. Users see no progress until completion.

Proposal

Add streaming support for tool results:

// Tool interface extension
type StreamingTool interface {
    Tool
    ExecuteStream(ctx context.Context, inputs map[string]any) (<-chan ToolChunk, error)
}

type ToolChunk struct {
    Data     string
    IsFinal  bool
    Metadata map[string]any
}

// SDK emits events as chunks arrive
s.OnEvent(sdk.EventToolOutput, func(e *sdk.Event) {
    chunk := e.Data.(*sdk.ToolOutputEvent)
    // Stream to UI
})

General Utility

  1. CI/CD agents - Build and test output streaming
  2. Data processing - Progress indicators for large operations
  3. Interactive shells - Real-time command output

Acceptance Criteria

  • StreamingTool interface for tools that support streaming
  • EventToolOutput event type for streaming chunks
  • Built-in shell tool supports streaming stdout/stderr
  • Non-streaming tools continue working unchanged
  • Integration test demonstrating streaming behavior

Priority

Medium - Improves UX but not blocking for MVP.

Labels

enhancement, sdk, priority:medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions