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

# ストリーミング

> Pythonエージェントのテキスト、推論、項目、ツール、ライフサイクルイベントをストリーミングします。

`Agent.stream(...)`は`run(...)`と同じ状態機械を実行し、再走査可能な`AgentStreamResult`を返します。

```python theme={null}
stream = agent.stream(input="Research this topic", client=client)

for delta in stream.text_stream():
    print(delta, end="", flush=True)

completed = stream.result()
```

別の形式で取得するには`reasoning_stream()`、`item_stream()`、`tool_stream()`、または`full_stream()`を使います。Pythonの項目は現在辞書形式であり、ネイティブの判別可能なユニオンではありません。

アクティブなモデルストリームを停止し、ローカルランタイムの処理にもキャンセルを伝えるには`cancel()`を呼び出します。

## 関連項目

* [ツール](./agent-sdk-tools.mdx)
* [オブザーバビリティとDevTools](./agent-sdk-observability.mdx)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.