Server-side graph entry point for langgraph dev.
This module is referenced by the generated langgraph.json and exposes a graph
factory that the LangGraph server can load and serve.
The graph is created by make_graph(), which reads configuration from
ServerConfig.from_env() — the same dataclass the CLI uses to write the
configuration via ServerConfig.to_env(). This shared schema ensures the two
sides stay in sync.
Report a server graph startup failure to the parent app process.
Emits two stderr outputs: the full traceback for logs/debugging, then a
single-line {STARTUP_ERROR_MARKER}{type}: {summary} line that
server._extract_startup_error_marker parses to upgrade an opaque
"Server process exited with code N" into an actionable summary.
Read the server project context from environment transport data.
Fingerprint value with the canonical workspace serialization.
Name the project-scoped fields that drifted from their binding.
The refusal these feed is safe either way, but it is not diagnosable without the field names: the resolution reads the extension trust store on every call, so a transient read failure reports as a policy change. These values are paths and booleans, never secrets, so naming them is safe.
Read the persisted comparison snapshot recorded for a binding.
Resolve a client-supplied cwd into a canonical workspace binding.
cwd is untrusted and is validated here. workspace_config is not: every
caller passes server-resolved policy. A client claim is verified against
server policy in offload_api.workspace and never reaches this function.
Compare a persisted snapshot against the current one.
Fields present in the snapshots are compared with values; fields named in
changed_names (e.g. fingerprint-only or path-valued fields detected by a
fingerprint comparison) are reported as changed without values.
Build the snapshot persisted with a workspace binding.
Return resources shared by the graph and dcode operation routes.
Builds once and caches. A construction failure is converted into a
startup-error marker (scraped by the parent app process) before
sys.exit(1), which is right for the langgraph.json graph factory at
startup. Callers in request scope must contain that exit -- SystemExit is a
BaseException -- as offload_api._execute_offload does, mapping it to a 503
rather than killing the server mid-request.
Return the graph after validating execution workspace context.
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.
Full configuration payload passed from the app to the server subprocess.
Serialized to/from DEEPAGENTS_CODE_SERVER_* environment variables so
that the server graph (which runs in a separate Python interpreter)
can reconstruct the app's intent without sharing memory.
Configuration consumed by CodeInterpreterMiddleware.
Explicit user/project path context for project-sensitive behavior.
A workspace claim or runtime conflicts with server resource policy.
Structured, secret-free detail attached to a workspace refusal.
One complete generation of credentials and project context.
Server-authoritative workspace and resource policy for one thread.
The one-per-process result with named slots to prevent transposition.