Agent management and creation.
Accepted internal output modes for CLI subcommands.
Default agent / assistant identifier when no -a flag is given.
Default LangGraph runnable config for the main agent.
Sets recursion_limit to RECURSION_LIMIT_DEFAULT (2000) to accommodate deeply
nested agent graphs in long-running sessions without hitting the default
LangGraph ceiling. The literal lives in config_manifest so the default is
defined in exactly one place. This value is the fallback: create_cli_agent
resolves the effective limit at agent-build time via resolve_recursion_limit,
which honors the --recursion-limit CLI flag, the DEEPAGENTS_CODE_RECURSION_LIMIT
env var, and [runtime].recursion_limit in config.toml.
Subdirectory of the offload root that holds per-thread conversation archives.
Lives directly under ~/.deepagents/ in local mode. The /agent picker
excludes this reserved name in addition to requiring an AGENTS.md marker.
When True, compact_conversation requires HITL approval like other gated tools.
Matches the ### Model Identity section in the system prompt, up to the
next heading or end of string.
Asynchronously read a live approval mode from a LangGraph Store.
The graph server supplies an async batched Store whose synchronous methods
reject calls from the event-loop thread. Prefer aget() for that runtime,
while retaining a synchronous fallback for lightweight local test stores.
Return a validated mode, failing closed to manual.
Read a live approval mode from the server-side LangGraph Store.
Get the default coding agent instructions.
These are the immutable base instructions that cannot be modified by the agent. Long-term memory (AGENTS.md) is handled separately by the middleware.
Get the glyph set for the current charset mode.
Resolve the LangSmith project name if tracing is configured.
Checks for the required API key and tracing environment variables.
When both are present, resolves the project name with priority:
settings.deepagents_langchain_project (from
DEEPAGENTS_CODE_LANGSMITH_PROJECT), then LANGSMITH_PROJECT from the
environment (note: this may already have been overridden at bootstrap time
to match DEEPAGENTS_CODE_LANGSMITH_PROJECT), then 'deepagents-code'.
Restore caller tracing API keys in an environment passed to user code.
Reverts both bootstrap overwrites of the canonical LangSmith key — the
DEEPAGENTS_CODE_-prefixed override and the /auth-stored key — so shell
subprocesses receive the caller's own key rather than the agent's session
key. See original_tracing_api_keys for the rationale; this mirrors
restore_user_tracing_env, which does the same for tracing flags.
Restore caller tracing flags in an environment passed to user code.
Get the default working directory for a given sandbox provider.
Read the server project context from environment transport data.
List subagents from user and/or project directories.
Scans for subagent definitions in the provided directories. Project subagents override user subagents with the same name.
Check a URL for suspicious Unicode and domain spoofing patterns.
Detect deceptive or hidden Unicode code points in text.
Join safety warnings into a display string with overflow indicator.
Render hidden Unicode characters as explicit markers.
Example output: abc<U+202E RIGHT-TO-LEFT OVERRIDE>def.
Remove known dangerous/invisible Unicode characters from text.
Summarize Unicode issues for warning messages.
Deduplicates by code point. When more than max_items unique entries exist,
the summary is truncated with a +N more entries suffix.
Load async subagent definitions from config.toml.
Reads the [async_subagents] section where each sub-table defines a remote
LangGraph deployment:
[async_subagents.researcher]
description = "Research agent"
url = "https://my-deployment.langsmith.dev"
graph_id = "agent"
Return a sorted list of available agent names from ~/.deepagents/.
Scans the user's .deepagents directory and returns each real
subdirectory that contains the AGENTS.md agent marker and is not an
app-reserved name. Fail-closed: bare directories, reserved app state
(bin/, plugins/, conversation_history/), symlinks, and hidden
entries are not agents.
Filesystem errors (missing parent, permission denied, broken entries) are logged and surfaced as an empty list rather than raised — the caller shows an empty modal instead of crashing mid-render.
List all available agents.
Reset an agent to default or copy from another agent.
Build the ### Model Identity section for the system prompt.
Get the base system prompt for the agent.
Loads the base system prompt template from system_prompt.md and
interpolates dynamic sections (model identity, working directory,
skills path, and execution mode for interactive vs headless).
Create a CLI-configured agent with flexible options.
This is the main entry point for creating a Deep Agents Code agent, usable both internally and from external code (e.g., benchmarking frameworks).
Metadata for a configured MCP server and its tools.
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.
Path-safety and size limits for read-only repository inspection tools.
Tool-approval policy selected for an interactive thread.
Swap the model or per-call settings from runtime.context.
Reads two optional keys from the runtime context dict:
'model' — a provider:model spec (e.g. "openai:gpt-5").
When present and different from the current model, the request is
re-routed to the new model.'model_params' — a dict of extra model settings (e.g.
{"temperature": 0}) that are shallow-merged into the
request's model_settings.This middleware is typically the outermost layer so it intercepts every
model call before provider-specific middleware (like
AnthropicPromptCachingMiddleware) runs.
Inject local context (git state, project structure, etc.) into the system prompt.
Runs a bash detection script via backend.execute() on first interaction
and again after each summarization event, stores the result in state, and
appends it to the system prompt on every model call.
Because the script runs inside the backend, it works for both local shells and remote sandboxes.
Load namespaced plugin skills without extending the SDK source API.
Wraps the SDK SkillsMiddleware. Sources without a namespace load exactly
as the SDK loads them. Sources carrying a plugin namespace are walked
recursively so nested skill directories (skills/foo/bar/review/SKILL.md)
are discovered, and each skill's name is qualified as
plugin_id:foo:bar:review before the last-one-wins merge — matching
the plugin skill naming convention.
Explicit user/project path context for project-sensitive behavior.
Run a context-aware nested grader and retry transient transport failures.
The nested grader receives Deep Agents Code's verification middleware and
runtime context without requiring those application-specific capabilities in
the SDK's RubricMiddleware. A transport retry re-invokes only the grader,
never the task agent, so grader tools must be read-only or idempotent.
Validate shell commands against an allow-list without HITL interrupts.
When the agent invokes the execute shell tool, this middleware checks
the command against the configured allow-list before execution.
Rejected commands are returned as error ToolMessage objects — the
graph never pauses, so LangSmith traces stay as a single continuous
run.
Use this middleware in non-interactive mode to avoid the interrupt/resume cycle that fragments traces.
Stock HITL routing with an async live-mode read after model completion.
The transient routing marker is added only to a shallow state copy passed
directly into stock HITL routing. It is neither checkpointed nor accepted
without the process-local _RoutingDecision type identity, so graph input
cannot forge an autonomous mode.