build_stream_config(
thread_id: str,Build the LangGraph stream config dict.
Stamps the shared coding-agent-v1 trace-metadata contract via
build_coding_agent_metadata — identity block, plugin/runtime versions,
turn markers, and repo/git/cwd attribution — onto metadata. Metadata set
here propagates trace-wide to every run in the graph (root, llm, tool, and
subagent subgraphs), which is exactly what the contract's "always" and
"where-known" keys require, so the helper output is stamped once here.
Scope-restricted contract keys are deliberately not emitted. approval_policy
(root/interrupted only) and ls_subagent_id / ls_subagent_type (subagent
only) cannot live in this trace-wide metadata: LangGraph propagates each key
to all descendant runs (per-key config merge, langgraph#7926 /
deepagents#3634), so they would leak onto run types outside their contract
appliesTo set and fail validation. This runtime exposes no clean
per-run-type metadata seam to scope them, so they are omitted by design
rather than leaked. (Subagent runs still inherit the parent/root thread_id
and all required keys, satisfying the contract's grouping rule.)
Also injects the dcode version into metadata["lc_versions"] so LangSmith
traces can be correlated with specific releases. create_deep_agent supplies
the SDK version through the compiled graph config, and LangChain merges
nested metadata dictionaries so both versions survive at stream time.
Also records dcode_client_deepagents_version as a dcode-client diagnostic.
This describes the Deep Agents package installed alongside the TUI, which
can differ from a remote graph's Deep Agents runtime version. Editable
installs carry an +editable suffix, matching how the SDK stamps
lc_versions["deepagents"]; for sibling monorepo packages that suffix
identifies workspace HEAD relative to the pinned published SDK baseline.
Also records dcode_experimental=True when DEEPAGENTS_CODE_EXPERIMENTAL
is enabled, so experimental runs are filterable in trace metadata.
Also records dcode_auto_approve=True when auto-approve ("YOLO") mode is
active, so runs that ran tools without HITL approval are filterable in trace
metadata. This is a diagnostic key, not the contract-scoped approval_policy
key (see above), so it is safe to stamp trace-wide.
Also records dcode_term_program from TERM_PROGRAM when that is non-empty
after stripping, so traces are groupable by launch environment (e.g.
"iTerm.app", "vscode", "Apple_Terminal"). Blank values are treated as unset
to match every other reader of this variable — some shells export
TERM_PROGRAM="" rather than leaving it unset, and terminals that never set
it (Windows Terminal, ssh, the Linux console) omit the key entirely rather
than forming a junk grouping bucket. This is a diagnostic key, not part of
the contract.
Default: None |
turn_number | int | None | Default: None |
auto_approve | bool | Default: False |
The app session thread identifier. Set both on
configurable.thread_id and as the top-level metadata.thread_id
used by the contract for grouping turns.
The dcode agent identifier, if any. When set, it is
surfaced in trace metadata under dcode_agent_name and
agent_name.
Sandbox provider name for trace metadata, or None if no
sandbox is active.
Stable per-turn id for the current user prompt, or None.
1-based per-thread turn index, or None.
Whether auto-approve ("YOLO") mode is active for this turn.
When True, dcode_auto_approve=True is recorded in trace metadata.