# Streaming
Event streaming (recommended for new apps, LangChain v1.3 plus):
```python
stream = agent.stream_events(
{"messages": [{"role": "user", "content": "..."}]},
version="v3",
)
for message in stream.messages:
for delta in message.text:
print(delta, end="", flush=True)
final_state = stream.output
```
Each projection (messages, tool calls, values, subgraphs) is its own iterator, so you do not branch on chunk types.
Graph stream modes (still current for raw graphs):
```python
for chunk in agent.stream(
{"messages": [...]},
config={"configurable": {"thread_id": "1"}},
stream_mode=["updates", "messages"],
):
...
```
## Rules
- `stream_mode="updates"` emits an event after every agent step; `stream_mode="messages"` streams LLM token chunks; pass a list to get both.
- Always pass a `thread_id` via config when streaming a conversation. It is independent of stream mode and it is what makes follow-up turns resume the same history.
- Wrapping a create_agent as a node in a parent StateGraph? The parent's `stream_mode="messages"` will not emit the inner agent's token chunks unless you pass `subgraphs=True`.
- `stream_mode="custom"` is for your own `writer()` events inside nodes.
- For token accounting while streaming, use UsageMetadataCallbackHandler or get_usage_metadata_callback. Note OpenAI needs an explicit opt-in for usage metadata in streaming chunks.