> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cosmon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Stream the work

> Iterate the run — typed ToolCall / TextChunk events as they happen.

Iterate the run to get events **as data** — route them to a GUI, a websocket,
metrics, or `break` mid-stream to cancel. Each iteration yields a typed event:
`ToolCall` (a tool-call boundary, `finished=False` on start and `True` on
finish) or `TextChunk` (the answer, as it streams).

```python theme={null}
import sys
from cosmon_agent_sdk import Client, TextChunk, ToolCall

with Client() as client:
    for event in client.run("Mesh and solve the model", agent="abaqus"):
        if isinstance(event, TextChunk):
            print(event.text, end="", flush=True)          # answer, token by token
        elif isinstance(event, ToolCall) and not event.finished:
            print(f"▶ {event.summary}", file=sys.stderr)    # tool steps
```

A run is single-use: iterate it **or** call `.text()`, not both. The `TextChunk`s
reconstruct the same answer `.text()` returns.

<Card title="Guide: streaming the run" icon="book-open" href="/sdk/guide#streaming-the-run">
  Observe vs respond, agent attribution, and cancelling mid-stream.
</Card>
