CLI-specific conversation compaction middleware.
Stable prefix for forced-compaction failure tool messages.
/offload drives the tool server-side and can only observe the resulting
ToolMessage text across the LangGraph server boundary, so it keys failure
detection on this prefix. Owning the literal here means the producer
(_forced_compact_error) and both consumers (app._drive_server_side_compaction
live-stream detection and app._find_compaction_failure committed-state scan)
reference one constant instead of re-hardcoding the wording independently.
Note: this value is deliberately identical to the leading text of the SDK's own
model-initiated compaction-failure message, so a failure emitted by either path
is recognized. Because the scan is bounded to messages produced by the current
/offload attempt, a stale failure from an unrelated prior turn is not matched.
Only the prefix position is load-bearing; wording after it is free to change.
Declared context_schema for the agent graph.
Registered via context_schema= when the graph is built, so LangGraph
coerces each run's context= payload into this dataclass — in-process,
runtime.context is a CLIContextSchema instance.
It exists alongside CLIContext (below) because the payload is shaped
differently on each side of the API boundary: in-process it is coerced to
this dataclass, but over the LangGraph API server (RemoteGraph) it is
serialized to JSON and arrives as a plain dict. Consumers
(configurable_model._get_context, _should_interrupt_tool_call)
therefore accept both shapes. CLIContext is the client-facing builder for
constructing that payload.
Fields mirror CLIContext; see its per-field docstrings for semantics.
Active model configuration read from a tool runtime.
A named tuple rather than a bare 4-tuple so the two structurally identical
dict slots (model_params, profile_overrides) are addressed by name at
both the construction sites (keyword args) and the read site (attribute
access) — a silent positional transposition the type checker would not catch
is thereby avoided. Positional construction/unpacking is still possible and
would defeat this, so call sites must keep using names.
Add explicit forced compaction and runtime model selection for dcode.
The SDK tool's normal, model-initiated behavior remains unchanged. The
private force input is used only by the user-initiated /offload path,
which must compact whenever messages exceed the retention window even when
the conversation has not reached the SDK's proactive eligibility gate.