# build_stream_config

> **Function** in `deepagents_cli`

📖 [View in docs](https://reference.langchain.com/python/deepagents-cli/config/build_stream_config)

Build the LangGraph stream config dict.

Injects CLI and SDK versions into `metadata["versions"]` so LangSmith traces
can be correlated with specific releases.

Why the CLI sets *both* versions:

* `create_deep_agent` bakes `versions: {"deepagents": "X.Y.Z"}` into the
    compiled graph via `with_config`. At stream time, LangGraph merges
    the graph config with the runtime config passed here. Because the
    metadata merge is shallow (effectively `{**graph_meta, **runtime_meta}`
    for top-level keys), both configs containing a `versions` key means
    the runtime dict **replaces** the graph dict entirely — the SDK
    version would be lost.
* Including the SDK version here ensures it survives the merge.

Includes `ls_integration` metadata so LangSmith traces originating from the CLI
are distinguishable from bare SDK usage.

## Signature

```python
build_stream_config(
    thread_id: str,
    assistant_id: str | None,
    *,
    sandbox_type: str | None = None,
) -> RunnableConfig
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `thread_id` | `str` | Yes | The CLI session thread identifier. |
| `assistant_id` | `str \| None` | Yes | The agent/assistant identifier, if any. |
| `sandbox_type` | `str \| None` | No | Sandbox provider name for trace metadata, or `None` if no sandbox is active. (default: `None`) |

## Returns

`RunnableConfig`

Config dict with `configurable` and `metadata` keys.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/1ae053f347679e58562d2b81eb6d6e6e9bbf0b07/libs/cli/deepagents_cli/config.py#L608)