Runs a LangChain Deep Agents agent inside NeMo Fabric's persistent Python adapter host. One started runtime retains the compiled graph, checkpointer, and LangGraph thread across ordered invocations.
Fabric.check() supports live, active, and ready for a started runtime.
| Level | Evidence |
|---|---|
live |
A fresh read from the owned checkpoint connection. |
active |
The compiled graph exposes its message input and invocation interface. |
ready |
A native state read succeeds for the owned LangGraph thread. |
The adapter qualifies LangGraph's aget_state() as the readiness response.
Checkpoint tables are initialized during startup. Health checks preserve the
thread and checkpoint contents and respond during an invocation.
Refer to the SDK health-check overview for shared behavior and a comparison of native evidence across adapters.
The following table shows which components each installation provides:
| Installation | Runtime | Adapter | Harness | NeMo Relay Python Package |
|---|---|---|---|---|
pip install "nemo-fabric[deepagents]" |
Yes | Yes | Yes | No |
pip install "nemo-fabric[deepagents,relay]" |
Yes | Yes | Yes | Yes |
pip install "nemo-fabric-adapters-deepagents[harness]" |
No | Yes | Yes | No |
pip install "nemo-fabric-adapters-deepagents[full]" |
No | Yes | Yes | Yes |
pip install "nemo-fabric-adapters-deepagents[relay]" |
No | Yes | No | Yes |
pip install nemo-fabric-adapters-deepagents |
No | Yes | No | No |
For an environment-managed stack, use deepagents>=0.6.12,<0.8.0,
langchain>=1.3,<2.0, and langgraph>=1.2,<2.0. For split runtime and adapter
environments, configure ADAPTER_PYTHON and use matching NeMo Fabric release
versions. Refer to the
installation guide.
The adapter builds a LangChain chat model from the selected NeMo Fabric model
role: models.default, or the sole configured role when default is absent.
The openai, nvidia, and openai-compatible providers use ChatOpenAI;
nvidia and openai-compatible require an explicit compatible base_url.
Any other provider is constructed through
langchain.chat_models.init_chat_model, so LangChain-supported backends do not
require adapter-specific branches.
models.<role>.api_key_env names the environment variable holding the API key,
and defaults to OPENAI_API_KEY only for the native openai provider. Every
other provider must set api_key_env explicitly (a missing one is a normalized
configuration failure), so a key is never sent to the wrong endpoint.
Set models.<role>.top_p from 0 through 1 and a positive
models.<role>.max_tokens to control nucleus sampling and the response token
limit for that model role. These are normalized model fields, not entries in
models.<role>.settings:
from nemo_fabric import ModelConfig
model = ModelConfig(
provider="nvidia",
model="nvidia/nemotron-3-nano-omni-30b-a3b-reasoning",
api_key_env="NVIDIA_API_KEY",
base_url="https://integrate.api.nvidia.com/v1",
top_p=0.8,
max_tokens=512,
)The adapter passes top_p and max_tokens to LangChain only when configured,
so omitted fields preserve the model provider's defaults. Planning rejects
unknown top-level model fields and every key under
models.<role>.settings.
Because models.<role>.api_key_env is provider-specific, the adapter declares no
static env requirement; a runtime preflight verifies that the deepagents
package is importable and the configured credential is set. A failed preflight
fails runtime start with a stable lifecycle error.
NeMo Fabric maps the following into the harness:
- The selected
modelsrole suppliesmodel,provider,api_key_env,base_url,temperature,top_p, andmax_tokens. instructions.systemsupportsreplaceand becomes the Deep Agentssystem_prompt. Deep Agents rejectsappend.runtime.timeout_secondssets the NeMo Fabric invocation deadline.runtime.max_turns=10configures LangGraph withrecursion_limit=10. This is a graph-superstep budget, not a promise of ten model responses or tool calls. One interaction can consume multiple supersteps. Omit the field to preserve the Deep Agents default.- By default,
environment.workspaceroots the Deep Agents filesystem backend (FilesystemBackend(root_dir=..., virtual_mode=True)).virtual_modeconfines filesystem tools to the workspace: absolute paths and..cannot escaperoot_dir. skills.pathsandskills.directoriesare checked in the task environment with the adapter contract's shared skills helper, using Deep Agents' own front-matter parser (nameanddescriptionare required). Each entry is one Deep Agentsskillssource, in list order, and only its immediate child folders are skills. The adapter routes each entry's skills into the Deep Agents backend at the path of the folder that holds them, so skills outside the workspace, or with no workspace at all, load, andlocal_shellcommands reach the same files at the same paths. Nothing is copied, and the mount decides whether the agent can change a skill. Apathsentry that holdsSKILL.mdis one skill; any other folder is a folder of skills. An absolutepathsentry that exists only under the workspace (for example/.agents/skillsfor skills already staged there) names that workspace folder and is loaded like any other entry.skills.duplicates(reject,first_wins,last_wins) resolves skills that share a name; when it is left out, the later entry wins, as in Deep Agents. A missing or invalid entry, or a duplicate underreject, fails start withdeepagents_skill_not_foundordeepagents_skill_invalid, naming the field. Every result reportsoutput.skills(loaded skills, skipped candidates, empty entries, and duplicates). Deep Agents ships no bundled skills, soskills.bundledis rejected at planning. Declarative subagentskillsinharness.settings.deepagents.subagentsare passed to Deep Agents unchanged and are read as workspace paths.- Configured MCP servers are loaded as Deep Agents tools via
langchain-mcp-adapters. A misconfigured server (non-mapping, empty target, unsupported transport) is a normalized configuration failure, not a silent drop. MCP-reported tool errors (ToolException) and argument validation failures return error tool messages to the model so it can correct a call. Local argument-validation feedback includes field paths and reasons, such ascommand: Field required, without dumping argument payloads. This does not automatically retry or replay commands; other exceptions still propagate. - An MCP server that cannot be reached, or that does not list its tools within
60 seconds, is skipped at startup; the runtime starts with the tools of the
remaining servers. Every result from that runtime reports the skipped servers
under
output.mcp.unavailable_servers(name,transport,reasonoffailed,timed_outorauthentication_required, anderror_type), and the adapter writes a warning to standard error. Error messages are omitted because they can carry credentials. Discovery runs again on each runtime start, so a recovered server is picked up by the next runtime. - MCP servers on
sseorstreamable-httpacceptservice_accountauthentication (OAuth 2.0 client credentials). The adapter requests a token fromtoken_urlwith the secret read fromclient_secret_env, sends it as a bearer token, renews it before it expires, and on a401requests a new token and retries the request once. The token is kept in memory only. A missing secret variable, astdioorwebsocketserver, a non-httpstoken_url(plainhttpis accepted only for a loopback host), a non-httpsserverurl(same exception), or anAuthorizationcustom header on the same server fails startup. The server is skipped and reported with reasonauthentication_requiredwhen the token endpoint rejects the client (HTTP400or401) or the MCP server still answers401after the token is renewed; any MCP server that answers401during discovery, with or withoutauthentication, is reported the same way. A token endpoint that cannot be reached, answers with another error status such as5xx, or returns no access token gives reasonfailed. The secret variable is withheld from thelocal_shellbackend's environment. A server that also needs a second token in its own header takes it throughcustom_headerswith a${NAME}reference; the adapter sends it unchanged and does not renew it.oauth2authentication is not supported. tools.enabledandtools.blockedare enforced by middleware across the full tool surface: Deep Agents built-ins (includingtask), MCP tools, and delegated subagents alike. Use Deep Agents-native tool names.tools.definitionsadds custom LangChain tools from installed Python packages withkind: "python". Refer to Add Custom Python Tools and Middleware.harness.settings.deepagentsaccepts the adapter-ownedbackendselector, custommiddleware, and the JSON-serializable Deep Agentsinterrupt_onandsubagentsoptions. The descriptor schema rejects unknown settings and fields before runtime start.
Set harness.settings.reasoning_effort to none, minimal, low, medium,
high, or xhigh to pass a reasoning effort to ChatOpenAI. For example,
settings={"reasoning_effort": "none"} disables reasoning on endpoints that
support that value. This setting requires an OpenAI-compatible provider, and
the endpoint must support the selected value. Omit the setting to preserve the
model default. Subagents inherit the setting when they inherit the main model;
a subagent with its own model override uses that model's defaults.
Use harness.settings.deepagents for Deep Agents-native controls that do not
have a normalized NeMo Fabric field:
from nemo_fabric import HarnessConfig
harness = HarnessConfig(
adapter_id="nvidia.fabric.langchain.deepagents",
settings={
"deepagents": {
"interrupt_on": {
"write_file": {
"allowed_decisions": ["approve", "edit", "reject"],
"description": "Review this file write.",
}
},
"subagents": [
{
"name": "researcher",
"description": "Researches the workspace before implementation.",
"system_prompt": "Investigate the request and return concise findings.",
}
],
}
},
)The deepagents object is closed and supports the following properties:
backendaccepts only{"type": "local_shell"}. This opt-in constructsLocalShellBackendat the requiredenvironment.workspace. Omitbackendto preserve the existing filesystem or Deep Agents default backend behavior.interrupt_onmaps a Deep Agents tool name to a boolean or an object with requiredallowed_decisions. Decisions areapprove,edit,reject, orrespond. The object can also contain a staticdescriptionand anargs_schemaJSON Schema. An omitted map defaults to no caller-defined interrupts. Callable descriptions andwhenpredicates cannot cross the JSON configuration boundary.subagentsdefaults to no caller-defined subagents and accepts declarative synchronous or Agent Protocol asynchronous subagents. A declarative subagent requiresname,description, andsystem_prompt; it can also contain aprovider:modeloverride, its owninterrupt_onmap, skill source paths, and a JSONresponse_format. An asynchronous subagent requiresname,description, andgraph_id; it can also containurland string-valuedheaders.middlewarelists custom LangChain middleware classes by import path, each with optional constructorsettings. Refer to Add Custom Python Tools and Middleware.
Warning
LocalShellBackend executes commands directly on the adapter host with the
host user's permissions. It provides no process isolation, and shell commands
can bypass virtual_mode filesystem restrictions. Use it only with trusted
input in a controlled environment. Do not use it for production or
multi-tenant workloads.
The adapter requires environment.workspace and an explicit Fabric tool policy
when local_shell is selected. Planning and host metadata inspection reject a missing policy before installation. An explicit empty tools.enabled allowlist is valid and disables all tools. The policy is applied to the main agent and all
declarative subagents, including a subagent that replaces the parent's
interrupt_on map. Include execute in tools.enabled to permit commands;
omit it from that allowlist or add it to tools.blocked to prevent commands.
Do not configure interrupt_on.execute with local_shell. The current adapter
lifecycle cannot surface and resume a LangGraph approval interrupt, so the
adapter rejects that combination instead of reporting an interrupted command as
a completed turn.
The following configuration opts in to local shell execution and limits the
tool surface to execute. It does not provide per-command approval; use it only
with trusted input under direct operator supervision:
from nemo_fabric import EnvironmentConfig, HarnessConfig, ToolsConfig
harness = HarnessConfig(
adapter_id="nvidia.fabric.langchain.deepagents",
settings={
"deepagents": {"backend": {"type": "local_shell"}}
},
)
environment = EnvironmentConfig(
provider="local",
workspace="/path/to/supervised-demo",
)
tools = ToolsConfig(enabled=["execute"])LocalShellBackend keeps inherit_env=False, so commands do not inherit
ambient adapter-host variables such as HOME. Values explicitly configured in
environment.env or named by environment.env_names are passed to shell commands
and are available to agent-generated commands. If neither sets PATH, the shell
provides only its fallback path; configure required variables explicitly and
use absolute executable paths when needed. The execute tool remains subject
to tools.enabled and tools.blocked, like all other Deep Agents built-ins.
On POSIX, with local_shell, file tools accept absolute paths inside
environment.workspace as aliases for workspace files. For example, with
workspace /app, both file-tool paths /app/report.txt and /report.txt refer
to /app/report.txt on disk. Shell commands use host paths and start in the
workspace, so cat report.txt and cat /app/report.txt read that file.
On POSIX, listings and searches return canonical physical paths inside the
workspace. These paths identify the same file in subsequent reads and edits,
even when a nested directory repeats the workspace prefix. For example, /app/app/report.txt
remains distinct from /app/report.txt; the relative file-tool path
app/report.txt also identifies the nested file.
On Windows, listings and searches retain workspace-rooted virtual paths, such
as /nested/report.txt. Use these paths with file tools; Deep Agents rejects
drive-prefixed paths such as C:/workspace/nested/report.txt before backend
resolution. Shell commands continue to use native host paths.
File-tool traversal and symlink-escape checks remain enabled. Paths outside the workspace retain the existing virtual-root interpretation; they do not grant access to host files.
A NeMo Fabric configuration is JSON, so it cannot carry Python objects. Instead,
it names code that is already installed in the adapter environment, as
package.module:attribute. The adapter imports that code when the runtime
starts. NeMo Fabric never fetches or installs it: install the package in the
same environment, or container image, as the adapter.
from nemo_fabric import HarnessConfig, ToolDefinitionConfig, ToolsConfig
tools = ToolsConfig(
definitions={
# A ready-made tool, such as a @tool function. Takes no settings.
"convert_units": ToolDefinitionConfig(
kind="python", ref="acme_agent_ext.tools:convert_units"
),
# A BaseTool subclass, constructed with settings as keyword arguments.
"erp_lookup": ToolDefinitionConfig(
kind="python",
ref="acme_agent_ext.tools:ErpLookup",
settings={"endpoint": "https://erp.example.com/api"},
),
},
blocked=["execute"],
)
harness = HarnessConfig(
adapter_id="nvidia.fabric.langchain.deepagents",
settings={
"deepagents": {
"middleware": [
{
"ref": "acme_agent_ext.middleware:DateContext",
"settings": {"timezone": "Europe/Berlin"},
}
]
}
},
)| Entry | ref must name |
The adapter |
|---|---|---|
| Tool | A LangChain BaseTool instance, such as a @tool function |
Uses it as is. settings must be empty. |
| Tool | A LangChain BaseTool subclass |
Constructs it with settings |
| Middleware | A LangChain AgentMiddleware subclass |
Constructs it with settings |
The adapter rejects any other object without calling it. It also applies the following rules when the runtime starts, and reports a failure that names the entry:
- A tool's name must equal its
tools.definitionskey, sotools.enabledandtools.blockedrefer to it. Custom tools cannot reuse a Deep Agents built-in tool name or the name of a tool provided by an MCP server. Tools that custom middleware exports throughAgentMiddleware.toolsfollow the same rule and cannot reuse atools.definitionsname either. - Custom middleware runs on the main agent in list order, before NeMo Relay.
NeMo Fabric checks the tool policy both before and after it, so it cannot
bypass
tools.enabledortools.blockedby running or rewriting a tool call, and Relay records what actually runs. - Middleware names must be unique and cannot reuse the name of a LangChain, Deep Agents, or NeMo Fabric middleware class. Deep Agents would otherwise replace its own middleware, such as filesystem confinement.
- Middleware cannot declare a custom
state_schema. - Settings are validated by the class itself, for example by its Pydantic
fields or
__init__signature.
NeMo Fabric runs Deep Agents asynchronously. Middleware that wraps model or
tool calls must implement the async hooks, such as awrap_model_call and
awrap_tool_call, in addition to the sync hooks.
Planning checks only the shape of these entries: the kind, the
package.module:attribute form of ref, and that settings is an object.
A missing package or attribute fails when the runtime starts. Keep secrets out
of the configuration; custom code reads them from its own environment variables.
Custom middleware applies to the main agent only. Declarative subagents use their own Deep Agents middleware stack, which still includes the NeMo Fabric tool policy.
FilesystemPermission objects and precompiled runnable subagents are not
exposed through harness.settings.
When tools.enabled or tools.blocked is configured, NeMo Fabric applies the
policy to declarative subagents and rejects asynchronous subagents because
their remote tools cannot be gated locally.
Deep Agents can delegate through its built-in task tool. The built-in
subagent inherits the parent run's model, tools, skills, workspace,
telemetry, and permissions. When a normalized tools policy is configured,
NeMo Fabric supplies an explicitly gated general-purpose subagent so
delegation cannot broaden capabilities beyond the parent. Caller-defined
declarative subagents are separate locally compiled graphs invoked through the
task tool. Agent Protocol subagents run asynchronously on their configured
server. Precompiled
subagents are not exposed through the public NeMo Fabric SDK because their
runnable objects cannot cross the JSON configuration boundary.
The configured runtime.max_turns limit applies as recursion_limit to the
main local graph. Declarative subagent graphs retain their Deep Agents limits,
and Agent Protocol subagents manage their own recursion limit in the remote
service.
The normalized result includes the final response, buffered messages and
per-step events, LangGraph thread id, token usage (and cost when the provider
reports it), and errors. Usage aggregates the current turn across the main agent
and any delegated subagents (streamed with subgraphs=True). Input totals use
LangChain's inclusive convention, which already includes cached tokens; an
unavailable cache breakdown stays unknown. If an assistant message omits a token
counter, that invocation's corresponding total stays unknown rather than
reporting a partial sum. Configuration and
preflight failures (a missing credential, an absent deepagents package, or an
invalid MCP server) fail runtime start before an invocation is accepted.
NeMo Fabric starts one local adapter host for every runtime. During runtime start,
the host compiles one Deep Agents graph, opens its async LangGraph checkpointer,
and creates one thread ID. Every invocation reuses those native objects; later
turns report resumed as true. The checkpointer lives under
the NeMo Fabric artifact root, scoped by runtime ID, and is closed during
runtime stop. The live host owns the thread identity, and LangGraph owns the
transcript.
Fabric.run(...) is a convenience over that same lifecycle: it starts the
runtime, invokes it once, and stops it. It does not use a separate adapter
entrypoint or execution path.
The deepagents_config() builder in examples/code_review_agent is the SDK
example. Run it from the CLI with
python -m examples.code_review_agent --variant deepagents --input "...", or
drive the SDK directly:
from examples.code_review_agent import BASE_DIR, deepagents_config
from nemo_fabric import Fabric
config = deepagents_config()
client = Fabric()
# Single invocation through the standard runtime lifecycle.
result = await client.run(
config, base_dir=BASE_DIR, input="Review the workspace changes."
)
print(result["output"]["response"])
# Multi-turn: one started runtime keeps the LangGraph thread across turns.
async with await client.start_runtime(config, base_dir=BASE_DIR) as runtime:
await runtime.invoke(input="Remember the value 42.")
reply = await runtime.invoke(input="What value did I ask you to remember?")
# reply["output"]["resumed"] is True and the response recalls "42".
print(reply["output"]["resumed"], reply["output"]["response"])NeMo Relay is Deep Agents' single, SDK-native observability path — the adapter
does not expose gateway, CLI, or plugin launch modes for this harness. Relay is
optional: nemo_relay is imported lazily and only when telemetry is enabled,
so the core install stays Relay-neutral at import time. Relay telemetry and
Runtime.invoke_stream() require one of the installations in the table that
includes the NeMo Relay Python package.
-
Relay (
telemetry.providers.relay): the SDK-native integration attaches three complementary pieces aroundcreate_deep_agent, applied uniformly to single-invocation, multi-turn, and subagent-enabled runs:nemo_relay.integrations.deepagents.add_nemo_relay_integration(...)injects Deep Agents-aware middleware that routes model and tool calls through Relay and emits skill/subagent configuration marks.- The top-level invocation runs inside a
nemo_relay.scope.scope("deepagents-request", nemo_relay.ScopeType.Agent)scope, so the whole NeMo Fabric turn is captured under one Agent scope. A UUIDrequest_idroots that scope's propagation. To group turns into one Relay session, send the same UUID string asRunRequest.relay_session_rooton each invocation: it becomes the propagated root, a UUIDrequest_idstays the parent (otherwise the session root is), and ATIF exports one trajectory per turn under onesession_id. Values Relay cannot use fall back to the request root without an error. NemoRelayDeepAgentsCallbackHandler()is added to the LangGraph run config (without dropping consumer-provided callbacks) to capture LangGraph scopes and human-in-the-loop interrupt/resume marks.
Runs emit ATOF/ATIF/OTLP artifacts to the configured output directory, referenced in the normalized result's
relay_artifacts(and theRunResultArtifactManifest). OTel/OpenInference export is available through the relay plugin config; the example provideswith_relay_otel(...)andwith_relay_openinference(...)variants.Telemetry is a separate failure domain from the agent turn. After the agent has been invoked, no telemetry fault — a failed scope close, a failed export flush, or a failed artifact scan — changes the functional outcome: it is reported in the
telemetryblock instead, astelemetry.degraded: trueplus atelemetry.errormessage. A turn the agent completed therefore stayscompleted, and a turn the agent failed stays failed with its ownerror; the telemetry fault never overwrites either. Faults from more than one stage are joined into that one message rather than the first one winning. Both keys are absent on a clean run.telemetry.degradedis the machine-readable signal to branch on. After a scope or flush fault the run is degraded butrelay_artifactsis still populated, because a partial trajectory is usually worth reading — treat it as untrusted rather than absent. When artifact collection itself is what failed there is nothing to reference, sorelay_artifactsis absent entirely.A telemetry failure that happens before the agent runs leaves no functional outcome to preserve, so it is reported as an invocation
erroras well.Relay's scope stack lives in the process and outlives a single invocation, so a fault that leaves a scope current poisons the runtime rather than just the turn. When that happens the runtime is quarantined: every later turn keeps running and stays
completed, but is no longer wrapped in a request scope, reportstelemetry.degraded: truewith a sticky message, and references norelay_artifactsof its own — the artifacts on disk belong to the earlier turns. This contains the damage rather than repairing it: the Relay middleware attached to the agent at start still emits, and those events nest under the stale scope, so a quarantined runtime's trajectory is untrustworthy rather than empty. The quarantine deliberately survivesstop()/start(), because restarting the runtime does not clean the process's scope stack.On the turn the fault happened,
telemetry.errorcarries it verbatim. On the turns that inherit the quarantine it appears astelemetry.quarantine_causeinstead, so a consumer counting or matching per-turn errors does not see the same fault reported once per remaining turn. -
Native (
telemetry.providers.native.config): the provider config OpenTelemetry/OpenInference exporter is applied and spans export directly to the configured collector, without writing ATOF/ATIF relay artifacts.
Subagent boundary. The built-in and caller-defined declarative subagents are instrumented with the same Relay middleware, so their model and tool calls appear under the same trajectory. Agent Protocol subagents execute on their configured server and are outside the local adapter's Relay instrumentation. Precompiled subagents are not exposed through the public NeMo Fabric configuration.
Enable Relay on a FabricConfig with the typed helpers — no gateway process or
CLI flags are involved:
from nemo_fabric import (
RelayAtifConfig,
RelayAtofConfig,
RelayAtofFileSinkConfig,
RelayObservabilityConfig,
)
from examples.code_review_agent import deepagents_config
# Start from a complete Deep Agents configuration, then enable typed Relay telemetry.
config = deepagents_config()
config.enable_relay(
output_dir="./artifacts/relay",
observability=RelayObservabilityConfig(
atof=RelayAtofConfig(
enabled=True,
sinks=[
RelayAtofFileSinkConfig(
output_directory="./artifacts/relay",
filename="events.atof.jsonl",
mode="overwrite",
)
],
),
atif=RelayAtifConfig(
enabled=True,
output_directory="./artifacts/relay",
filename_template="trajectory-{session_id}.atif.json",
agent_name="deepagents-agent",
),
),
)