Streaming

Streaming

LeafMesh supports streaming LLM responses for real-time output delivery. When streaming is enabled, the LLM sends response tokens as they are generated rather than waiting for the complete response.

Configuration

Enable streaming in the agent's model configuration:

agents: streaming_agent: name: "streaming_agent" model: "gpt-4o" prompt: | Provide detailed analysis of the input data. yields: analysis: "string" confidence: "number"

Streaming is supported whenever the underlying provider supports it -- OpenAI, Anthropic, and Google all support streaming.

Integration Pattern

Streaming works through the API layer. When an external system connects via the FastAPI endpoints with streaming enabled, the response is delivered progressively:

Client Request → API Server → LLM Provider (streaming)
                                    │
                                    ├── Token 1 → Client
                                    ├── Token 2 → Client
                                    ├── Token 3 → Client
                                    └── Final   → Client

The unified LLM request includes a stream flag that activates streaming mode.

Yields and Streaming

When streaming is active, the yields schema is still enforced — but parsing happens on the complete response after all tokens have been received. The stream provides progressive output to the client while the pipeline validation runs on the final assembled response.

When to Use Streaming

Use CaseStreaming?
Real-time user interfacesYes — progressive display
API-to-API callsUsually no — wait for complete response
Agent-to-agent mesh callsNo — can_call needs complete yields
Long-form generationYes — reduces perceived latency

Next Steps


LeafMesh — Progressive response delivery

Last updated: 11/10/2026