This example demonstrates real-time streaming responses from an A2A server, perfect for chat applications and interactive experiences.
- What This Example Shows
- Directory Structure
- Running the Example
- Understanding Streaming
- Configuration
- Use Cases
- Troubleshooting
- Real-time streaming of responses
- Character-by-character output for better UX
- Mock streaming when no AI is configured
- Proper event stream handling
streaming/
├── client/
│ └── main.go # Streaming client
├── server/
│ └── main.go # Streaming-enabled server
├── docker-compose.yaml # Uses ../Dockerfile.server and ../Dockerfile.client
└── README.md
docker-compose up --buildcd server
go run main.gocd client
go run main.goThe server sends different event types during streaming:
- Status Event - Task state updates
- Delta Event - Content chunks (characters/words)
- Error Event - Error notifications
- Task Complete - Final task with full response
stream, err := a2aClient.SendTaskStreaming(ctx, params)
if err != nil {
log.Fatalf("Failed to start streaming: %v", err)
}
for event := range stream {
// Process each streaming event
fmt.Printf("Received event: %+v\n", event)
}Sending streaming request...
Received stream:
T-h-i-s- -i-s- -a- -s-t-r-e-a-m-i-n-g- -r-e-s-p-o-n-s-e-.- -E-a-c-h- -c-h-a-r-a-c-t-e-r-
-a-p-p-e-a-r-s- -i-n- -r-e-a-l---t-i-m-e-.
✅ Stream completed
CAPABILITIES_STREAMING: Must betrue
- Automatically detects server streaming capability
- Falls back to non-streaming if not supported
- Chat Applications: Real-time conversation UI
- Code Generation: Show code as it's generated
- Content Creation: Display writing in progress
- Progress Updates: Stream processing steps
# List tasks and debug the A2A server
docker compose run --rm a2a-debugger tasks list --include-history