MCPcopy
hub / github.com/langchain-ai/deepagents / CLIContext

Class CLIContext

libs/code/deepagents_code/_cli_context.py:47–96  ·  view source on GitHub ↗

Client-facing builder for the per-run graph context payload. Callers populate this and pass it via `context=` to `astream`/`ainvoke`. `ConfigurableModelMiddleware` and the `interrupt_on` `when` predicate read it from `request.runtime.context`. In-process LangGraph coerces it into `C

Source from the content-addressed store, hash-verified

45
46
47class CLIContext(TypedDict, total=False):
48 """Client-facing builder for the per-run graph context payload.
49
50 Callers populate this and pass it via `context=` to `astream`/`ainvoke`.
51 `ConfigurableModelMiddleware` and the `interrupt_on` `when` predicate read
52 it from `request.runtime.context`. In-process LangGraph coerces it into
53 `CLIContextSchema` (the registered `context_schema`); over the API it stays
54 a plain dict — which is why consumers handle both shapes.
55 """
56
57 model: str | None
58 """Model spec to swap at runtime (e.g. `'provider:model'`)."""
59
60 model_params: dict[str, Any]
61 """Invocation params (e.g. `temperature`, `max_tokens`) to merge
62 into `model_settings`."""
63
64 auto_approve: bool
65 """Whether gated tool calls should skip the human-approval interrupt.
66
67 Sourced from the client session (not graph state) so the model cannot
68 self-approve by writing state. The `interrupt_on` `when` predicate reads
69 this to suppress interrupts at the source when "approve always" is on,
70 avoiding the interrupt-then-auto-resolve round-trip.
71 """
72
73 approval_mode_key: str | None
74 """Store key for the live approval-mode control record.
75
76 The TUI updates this record when the user toggles approval mode mid-run.
77 The server-side interrupt predicate reads it from the LangGraph Store on
78 each gated tool call so auto-to-manual changes can take effect before the
79 current stream returns.
80 """
81
82 thread_id: str | None
83 """LangGraph thread ID for the active conversation.
84
85 Mirrors `config.configurable.thread_id` into runtime context for model-call
86 middleware that needs per-request session identity, including Fireworks
87 session-affinity headers.
88 """
89
90 blocked_goal_retry_context: str | None
91 """One-turn model context for retrying a previously blocked goal.
92
93 This is intentionally carried in runtime context instead of the user
94 message so it is not parsed as a file mention or checkpointed as human
95 input.
96 """

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…