Use the Qwen Code Adapter
Use the nvidia.fabric.qwen adapter to run tasks with Qwen Code. Each NVIDIA
NeMo Fabric runtime uses @qwen-code/sdk to start one bundled Qwen CLI child
process and reuses one live session across ordered invocations. Qwen Code runs
as a separate process; it is not embedded in the adapter process.
Install the Adapter
Install Node.js 22.19 or later. Then install the adapter and its exact-pinned, consumer-managed SDK in the project that owns the NeMo Fabric configuration:
The SDK is an optional peer and bundles the Qwen CLI. Installing the adapter
alone does not install it. Starting the adapter without the compatible SDK
returns qwen_sdk_missing.
For source development, run these commands from the repository root:
Configure the Adapter
Select the Qwen Code integration and point discovery at the installed adapter descriptor:
Set NVIDIA_API_KEY before starting the runtime. For a source build, set
discovery.local_paths to
adapters/typescript/qwen/qwen.fabric-adapter.json instead. The build commands
above create the descriptor’s dist/cli.js runner.
Supported Configuration
The adapter supports the following normalized configuration:
- Models: Selects the
defaultrole, or the only configured role. It mapsmodel,api_key_env,base_url,temperature, andtop_pfor theopenaiprovider. - Instructions: Supports
instructions.systemwithmode: replaceormode: append. - Tools: Maps Qwen-native tool names from
tools.blocked. Tool definitions andtools.enabledare unsupported. - Skills: Each
skills.pathsentry must be a directory containingSKILL.md. - MCP: Supports stdio and streamable HTTP servers, including per-server allowed and blocked tool filters.
- Harness settings: Maps
permission_modeto Qwen Code’sdefault,plan,auto-edit,auto, oryoloapproval mode.
Model Endpoints
The adapter requires models.<role>.provider: openai. When base_url is set,
it must identify an OpenAI-compatible Chat Completions endpoint.
HTTPS is required by default, except for loopback HTTP. For a trusted Docker or Kubernetes gateway, set harness.settings.insecure_http_model_hosts to the exact hostnames that can receive HTTP model requests. Entries contain only hostnames or IPv4 addresses, without schemes, ports, paths, or wildcards. Matching ignores case and a trailing DNS dot, and permits any port or path on the listed host. The adapter does not resolve DNS to infer trust. Allowlisted HTTP endpoints receive model credentials and prompt content over an unencrypted connection. This setting applies only to model endpoints; MCP endpoint restrictions are unchanged.
For example, allow the gateway hosts used by your deployment:
The adapter reads the variable named by api_key_env from NeMo Fabric
environment.env first and then the parent process environment. It does not
write the credential to Qwen settings.
MCP Configuration
Stdio servers map url to the executable and may define args and env, but
not HTTP headers. Streamable HTTP servers may define custom_headers, but not
process arguments or environment variables. Remote MCP endpoints require HTTPS
except for loopback development endpoints.
Header values may reference ${NAME}. Resolution checks NeMo Fabric
environment.env first and then the parent process environment. Unresolved
references fail startup. allowed_tools and blocked_tools map to Qwen Code’s
per-server filters. Normalized MCP authentication is unsupported.
Only explicitly configured server names are enabled. The pinned SDK discovers
external MCP servers on the first prompt and does not include them in
mcpServerStatus(). The adapter captures the SDK’s MCP startup diagnostic and
returns qwen_mcp_unavailable instead of accepting a result produced without
every explicitly configured server.
Runtime Behavior
The adapter accepts plain-text input and returns the terminal assistant text in
output.response. Qwen Code reports cumulative usage for a live query, so the
adapter returns the per-invocation difference. Create a new runtime to change
the selected model, workspace, system instructions, skills, MCP servers, tool
policy, or permission mode.
Input totals include cached tokens, and output totals include reasoning tokens under the adapter’s fixed OpenAI authentication path. Cache counters are reported separately as a breakdown and are not added again. Missing or invalid counters, cumulative-counter resets, and all-zero usage observations remain unknown rather than being converted to zero. A valid snapshot establishes a baseline for later invocation deltas.
These are the pinned SDK’s provider-reported observations, not independently verified billing totals. The SDK normalizes missing provider usage to zero and can omit usage from failed requests. An all-zero observation cannot distinguish missing data from real zero consumption, and partial omissions inside a nonzero summary cannot be detected through the public result.
The adapter gives the child process isolated temporary Qwen home and runtime
directories. It disables Qwen Code’s optional product-usage analytics and
telemetry. This does not affect model-provider metering or token usage reported
by NeMo Fabric. The adapter also disables extensions, ambient skills, and
ambient MCP servers. Explicit NeMo Fabric environment.env values and the
selected model credential are forwarded to the child process.
The adapter disables Qwen’s automatic CLI relaunch, which sizes the replacement
process’s heap from host RAM. The SDK-owned child retains Node.js’s default
memory sizing for its container and any explicit NODE_OPTIONS heap setting
forwarded through environment.env.
In SDK mode, set harness.settings.permission_mode to control Qwen Code’s
permission policy. The default value, default, denies tool calls that need
interactive approval. Use auto for Qwen’s classifier-mediated policy. Use
yolo only inside an appropriate task sandbox because it bypasses edit
approval. Qwen’s permission policy is not a filesystem sandbox.
models.max_tokens, provider-specific model settings, runtime.max_turns,
tools.enabled, native streaming, cancellation, service mode, and Relay
telemetry are unsupported.
Understand the Runtime Lifecycle
The adapter runs as a persistent Node.js process, but the Qwen Code harness does
not run in-process. start creates isolated configuration and asks
@qwen-code/sdk to launch its bundled Qwen CLI as a child process. The SDK
exchanges JSON-lines messages with the CLI over stdin and stdout. stop closes
the live query, terminates the child process, and removes the temporary profile.
To try the source adapter, use the code-review agent Qwen variant.
Runtime Health
Fabric.check() supports live, active, and ready. Each level obtains a fresh native Query.supportedCommands() response from the owned CLI query. Readiness establishes initialized CLI responsiveness.
Refer to the SDK health-check overview for shared behavior and a comparison of native evidence across adapters.