anthropics / anthropics/claude-agent-sdk-typescript

Feature Request: Stream tool execution status and output (e.g., Bash command stdout/stderr)

Abierto
#213 1 comentario 6 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Shell
Estrellas
1.8k
Forks
226
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### Problem

Currently, the streaming API (`includePartialMessages: true`) only provides events for Claude's **response generation** phase:
- `content_block_start` / `content_block_delta` / `content_block_stop` for text and tool call declarations

However, there are **no streaming events during tool execution**. The message flow shows a gap:

StreamEvent (content_block_stop) ← tool call declaration complete
AssistantMessage
... tool executes ... ← NO EVENTS HERE
... next turn ...

This is especially problematic for **long-running Bash commands**, where users have no visibility into:
1. Whether the command has started
2. What output is being produced (stdout/stderr)
3. When the command finishes

### Proposed Solution

Add new `StreamEvent` types for tool execution lifecycle:

| Event Type | Description |
|------------|-------------|
| `tool_execution_start` | Tool begins execution (includes tool name, tool_use_id) |
| `tool_execution_output` | Incremental stdout/stderr from the tool (for Bash, shell output) |
| `tool_execution_end` | Tool execution complete (includes exit code for Bash) |

### Example Expected Flow

StreamEvent (content_block_start) - tool_use block
StreamEvent (content_block_delta) - tool input JSON
StreamEvent (content_block_stop) - tool call declaration complete
StreamEvent (tool_execution_start) - { tool: "Bash", tool_use_id: "..." }
StreamEvent (tool_execution_output) - { chunk: "Installing dependencies...\n" }
StreamEvent (tool_execution_output) - { chunk: "npm WARN deprecated...\n" }
StreamEvent (tool_execution_end) - { exit_code: 0 }
AssistantMessage

### Use Cases

1. **Real-time terminal UI**: Show command output as it streams, similar to a real terminal
2. **Progress indicators**: Display "Running npm install..." with live output
3. **Long-running commands**: Provide feedback during builds, tests, or deployments that may take minutes
4. **Debugging**: See exactly what a command outputs when troubleshooting failures

### Additional Context

This feature would significantly improve the developer experience when building interactive CLI tools or chat interfaces that invoke shell commands. Currently, developers have to either:
- Show a generic "executing..." spinner with no real feedback
- Or implement custom workarounds outside the SDK

Thank you for considering this enhancement!

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.