Python ngn configuration reference¶
Python client schema
This is the existing Python harness's layered configuration and provider registry. It is not the Rust application's explicit JSON schema; use native configuration for that bundle.
This page describes the current source-checkout ngn harness, which can differ
from an installed release or another coding assistant. See
release availability and installation and the installed
release notes before assuming every current field or behavior is available.
Quick example¶
Keep general settings in JSON config.json, named connections in
providers.json, and reusable assistant behavior in native Markdown
assistant.md. Existing JSON profiles remain supported. profiles and the
optional providers file reference are nested settings in the general config:
{
"providers": "./providers.json",
"model": "gpt-6-luna",
"agent": "assistant",
"theme": "terminal",
"animations": true,
"max_subagent_depth": 2,
"profiles": {
"audit": {
"mode": "reviewer",
"instructions": "Prioritize regressions and missing tests. Do not edit files."
}
}
}
Unknown fields, wrong JSON types, invalid values, and literal api_key fields
are errors rather than silently ignored options.
The checkout includes an example pair at examples/harness/config.json and
examples/harness/providers.json. To try it
without provider calls, run from the repository root:
Managed background shells¶
The shell tool accepts background: true when the host enables this capability.
It returns a job ID and a live output-file path instead of waiting. Use /shells
to inspect jobs and /shells stop JOB_ID to stop one without running the model.
The shell remains a non-sandboxed POSIX tool and still requires approval.
Background execution is currently available only to root agents. Delegated child
agents retain foreground shells, but their schema omits background and stale
background calls are rejected because their runtime closes after a normal reply.
{
"shell": {
"allow_background": true,
"max_log_bytes": 67108864,
"max_total_log_bytes": 268435456,
"max_concurrent": 8,
"max_concurrent_per_owner": 4
},
"shell_timeout": 600
}
Set shell.allow_background to false to remove the background argument from
advertised schemas and reject stale background requests at execution. The
standalone shell library defaults to background disabled; ngn explicitly opts in.
Shell fields merge individually across configuration layers. Unknown fields and
incorrect types are rejected. Environment defaults use NGN_SHELL_ALLOW_BACKGROUND,
NGN_SHELL_MAX_LOG_BYTES, NGN_SHELL_MAX_TOTAL_LOG_BYTES,
NGN_SHELL_MAX_CONCURRENT, and NGN_SHELL_MAX_CONCURRENT_PER_OWNER.
The existing top-level shell_timeout setting remains unchanged.
Per-owner concurrency cannot exceed the total concurrency; total log capacity
cannot be smaller than a single job's limit. Background jobs retain the existing
shell_timeout ceiling (at most 600 seconds), rather than running indefinitely.
Full output is written privately beneath the workspace's ngn data directory. Completion notices contain at most the last 200 lines and 32 KiB, plus the log path. Reaching a disk/output limit stops the job with an explicit failure instead of silently discarding the rest. Logs may contain sensitive command output; do not publish them without inspection.
Natural completion or failure requests an automatic continuation of the owning agent through the normal serialized admission gate. Stopping a job explicitly, interrupting its agent, or closing ngn instead records a cancellation reason without waking the model. A normal assistant reply does not terminate running background jobs. Jobs do not survive ngn shutdown, and interrupted commands are never replayed automatically. The reusable library lets its host select temporary or persistent storage and whether to react to completion events.
Provider wire logging¶
Wire logging currently requires POSIX ownership and no-follow filesystem
protections. On unsupported platforms (including Windows), enabling it fails
before creating files; leave wire_log disabled. Unknown HTTP headers are
redacted by default; only explicit transport/routing diagnostics are retained.
wire_log is a strict boolean (default false) in HarnessConfig and harness
JSON, for example {"wire_log": true}. Set NGN_WIRE_LOG=true|false|1|0 for an
environment default. --wire-log enables it and --no-wire-log disables it for
one invocation, without saving the setting. Flags work before or after a
subcommand; when repeated, the last flag wins. An omitted flag preserves the
loaded value. Precedence is built-ins < environment < user JSON < trusted project
JSON < explicit JSON < explicit CLI flags, as described below.
Wire logs are sensitive diagnostic data: provider requests and responses can
contain prompts, model output, tool arguments/results, workspace contents, and
other private information. Enable only when needed; protect the files and review
them before sharing. The log location is logs/wire-<unique>.jsonl under
data_dir (by default $XDG_DATA_HOME/ngn, or ~/.local/share/ngn). Files are
created with owner-only permissions (0600). Transport authentication/cookie headers are redacted, but
application payloads are not. This captures traced provider HTTP traffic during
agent turns, including streaming responses; it is not an MCP protocol, realtime
WebSocket, or approval-decision log. There is no automatic rotation or retention
cleanup: disable logging and remove sensitive logs when no longer needed.
Legacy terminal performance preference¶
tui_performance is a strict boolean (default false) in harness JSON. It is
also available as NGN_TUI_PERFORMANCE=true|false|1|0. It controlled the
performance panel of the removed Python terminal UI and is retained so existing
configuration and preference files stay valid; nothing in the Python client
displays it now. It adds no telemetry or configuration to the core Agent library.
Terminal integrations can persist the user's explicit global/local selection:
from nagents.harness.config import save_tui_performance
path = save_tui_performance(config, enabled=True, scope="global")
# scope="local" saves only for config.workspace.
The exact signature is
save_tui_performance(config: HarnessConfig, enabled: bool, scope: Literal["global", "local"]) -> Path.
It saves atomically and updates config.tui_performance only after success.
Global preferences live in $XDG_CONFIG_HOME/ngn/tui.json; local preferences
live in $XDG_CONFIG_HOME/ngn/workspaces/<workspace-hash>/tui.json, using the
same workspace identity as the other scoped settings. With no XDG_CONFIG_HOME,
~/.config is used. Local preferences override global preferences; both override
JSON/environment defaults.
A saved global change updates the current config immediately, but an existing
local preference still wins on the next load.
Saving preserves unrelated fields in the preference document and never edits project JSON, grants project trust, or changes provider/assistant settings. Storage is cross-platform, atomic, bounded non-secret JSON, not a credential store. Ordinary owned directories (including mode 755 on POSIX) and regular files (including mode 644) are accepted; existing directory permissions are never changed. Symlink directories/files and hard-linked files are rejected. POSIX checks additionally reject foreign-owned files and directories writable by other users (apart from root-owned sticky temporary ancestors). Malformed or unsafe existing preferences raise an error rather than being silently replaced. Only save when the user explicitly chooses a scope; startup does not create these files.
Precedence¶
The order is lowest to highest priority:
- Built-in defaults.
- The active named connection in
$XDG_CONFIG_HOME/ngn/providers.json, when present. NGN_*environment defaults, includingNGN_PROVIDER_IDfor a named selection.- Global/user JSON.
- Trusted project JSON.
- An explicitly selected JSON file.
- Explicit CLI flags.
Environment variables are not the highest-priority override. For example,
NGN_MODEL=environment-model loses to "model": "file-model" in global JSON;
--model cli-model overrides that top-level setting. A flag omitted from the
command line leaves the loaded value intact.
Files are layered, not exclusive: --config does not suppress the global file
or a project file allowed by --trust-project. Re-selecting the global file with
--config puts it at explicit-file priority, after the trusted project file.
An explicit file must exist; absent global and project files are fine.
Each loaded file must be valid JSON with valid field types. CLI flags are applied after configuration loading and validation, so a CLI override is not a way to repair a malformed or invalid lower-priority configuration. Likewise, invalid environment conversions can fail before a file replaces the value.
Profile model selection happens at runtime after loading the top-level
configuration; see profiles before combining a profile-specific
model with --model.
Shared named provider connections¶
ngn and ngn serve share $XDG_CONFIG_HOME/ngn/providers.json (default
~/.config/ngn/providers.json) for global connections. Use Settings → Global →
Provider connections to edit them and choose the default. Settings → Workspace →
Provider connections manages connections and a selection for this workspace;
its JSON lives at $XDG_CONFIG_HOME/ngn/workspaces/<workspace-hash>/providers.json.
The workspace list includes global connections, which can be selected without
changing the global default. Use global default clears a workspace selection.
Without an active connection,
ngn serve starts for setup, but chat waits until one is selected. You can edit either JSON while
ngn is stopped. A revision prevents an older UI from overwriting another
process's edits. A separate connection can be selected for a trusted agent profile using
profiles.NAME.provider: CONNECTION_NAME.
Provider connections contain kind, authentication source, endpoint where needed,
HTTP API and environment variable names. Chat models are chosen separately:
the model field in global $XDG_CONFIG_HOME/ngn/assistant.md or workspace
$XDG_CONFIG_HOME/ngn/workspaces/<workspace-hash>/assistant.md provides shared
defaults for the CLI and web UI. Explicit trusted JSON model selections, agent-profile models,
NGN_MODEL and explicit --model overrides retain their precedence. Switching
connections does not change the chat model. Voice duplex preferences are edited
separately in GPT-Live → Voice settings: Global supplies defaults, and the
workspace may override individual fields. Use "api_key_env": "OPENAI_API_KEY" or
"api_key_env": "${OPENAI_API_KEY}"; ngn resolves the variable when it makes a
request. It never writes the key value to this file. Set environment variables
in the environment of the ngn process (including the ngn serve process),
not in the browser. For Microsoft Entra ID, "auth": "entra" uses the optional
azure-identity package's DefaultAzureCredential chain; its SDK credential
owns token caching and refresh. OpenAI supports auth: chatgpt for ngn's device
login and "auth": "codex" for the library's local Codex discovery (CODEX_HOME or
~/.codex). These existing OAuth/Codex files are not copied into the provider
registry. "auth": "auto" prefers an existing ngn ChatGPT login or local Codex
configuration before an OpenAI API-key environment variable. Auto auth is
available only for OpenAI; Codex auth uses only local Codex discovery. OpenAI
uses a fixed API host; use openai_compatible for custom endpoints.
Web voice uses the normal provider registry
and defaults; an explicit Voice connection can select a different Live-capable
provider. The browser sends audio only to ngn, which owns provider authentication
and connections. ChatGPT/Codex login uses the server's native Codex media/control
path, while API-key and Entra connections use supported Live WebSockets. Subscription
tokens are never exposed to the browser or used as public Live API keys.
Example:
{
"version": 2,
"revision": "0000000000000000000000000000000000000000000000000000000000000000",
"active": "work",
"providers": {
"work": {
"kind": "foundry",
"base_url": "https://resource.openai.azure.com/openai/v1",
"api": "responses",
"auth": "entra",
"request_timeout": 120.0
}
}
}
Provider connections also accept context_window (a positive input-token limit,
or 0 for automatic) and model_context_windows (exact model IDs mapped to
positive limits). Model overrides take precedence over the connection default:
{
"kind": "litellm",
"base_url": "https://gateway.example/v1",
"context_window": 0,
"model_context_windows": {
"eu.anthropic.claude-opus-5-5": 1000000
}
}
When no override applies, ngn uses exact-model provider metadata where available:
LiteLLM's /model/info
model_info.max_input_tokens, Anthropic's model max_input_tokens, Gemini's
inputTokenLimit, OpenRouter's context_length, and context metadata returned by
compatible or Codex catalogs. The public OpenAI /models API does not advertise
context limits. Name-based estimates remain a last resort and are labelled
guessed in the interface. Metadata requests stay on the configured provider,
are bounded to three seconds and 1 MiB, and cache results or failures for five
minutes per model. A denied LiteLLM management endpoint does not block generation;
set an explicit override when the key cannot read model metadata.
Automatic compaction uses 70% of this same effective window. A token compaction
budget is separate: a configured compact_tokens value of 600,000 triggers at
420,000, even on a model with a 1,000,000-token window. The interface shows both
values and warns when a configured budget exceeds a known model window. Child
agents use their own model, connection, and applied compaction settings.
Context usage prefers the last provider-reported prompt-token count for the active session and model; it is a last measured request, not a prediction of the next request. Append-only history can retain that measurement. Resetting or replacing history, compaction, changing provider/model or request setup, or completing a new generation without usage invalidates it. The component breakdown remains a separate estimate whose parts always sum to its estimated total.
request_timeout is the total deadline, in seconds, for each ngn-issued model
HTTP request on this named connection, including connection setup and streaming
response reads. It accepts positive finite integers or decimals; omission keeps
the existing 120-second default. Booleans, numeric strings, zero, negative
values, and nonfinite values are rejected. There is no additional upper cap.
The same setting applies to API-key, ChatGPT/Codex, and Foundry/Entra model
requests, including agents and native children selecting this connection.
Editing an active connection replaces its HTTP client so the new deadline takes
effect on subsequent requests. Global and workspace connection scope works as
for its other fields. Model catalogs retain their separate cap of
min(request_timeout, 30) seconds.
This field does not change shell limits, Live session duration, Live backend
waiting limits, or authentication SDK deadlines. Subagents have no overall
execution timeout.
Existing retries remain unchanged; retries and backoff can make a generation
last longer than one request deadline. There is no top-level Harness JSON field
or NGN_REQUEST_TIMEOUT environment alias. Use the named connection's JSON,
or web provider editor.
An optional session_id_header on the named connection sends the current
conversation ID in that HTTP header on model generation requests. For example,
add "session_id_header": "x-opencode-session" to a LiteLLM connection when its
upstream needs conversation correlation. The default "" disables it. Configure
this in the web connection editor under Advanced or the connection's JSON. Global and workspace scopes use the same field.
ngn uses each conversation's actual ID, stable across turns and tool rounds; it never saves a shared static ID in the provider profile. Catalog and credential requests omit the header. Names are limited to 128 ASCII HTTP token characters and cannot override authentication, routing, or protocol headers. Values use 1–1024 visible ASCII characters without spaces. This setting applies to text generation, including Chat Completions, Responses, and Messages; batch uploads and Live/Realtime connection headers are separate.
The UI generates a fresh revision on save and writes indented JSON. Workspace JSON uses the same schema:
its active may reference a global connection, and an empty active inherits
the global default. Other provider types (openai,
openai_compatible, openrouter, anthropic, gemini, litellm, both Azure
routes) have their own authentication/API/endpoint requirements; the UI shows
the allowed fields for the selected type. A provider catalog is a best-effort
list of model IDs, not a guarantee of access. Providers without a catalog or a
compatible /models endpoint require manual model entry. Saving a named
connection does not perform network authentication.
To place the registry elsewhere, set "providers": "./providers.json" in
config.json. A reference in the user config selects the global provider file;
a reference in a trusted project or explicit config selects the workspace file.
Use "providers": {"global": "./shared.json", "workspace": "./team.json"}
to set either scope explicitly. Paths are relative to the containing config
file. Omitted references use the default providers.json paths. An explicit
reference to a missing file starts with an empty registry; the UI creates that
file on save. The references must name distinct .json files. The full resolved
provider definitions are visible as config.providers during CLI startup.
Voice defaults and full prompts share the live section of the scoped
assistant.md files described below. The framework uses only this native format;
an existing installation needs operator-managed conversion of prior settings.
It does not import Voice SQLite records or separate prompt files. Provider
connections contain no chat or Voice model and no API-key values.
Create a named connection in the web UI and set its environment variable; the provider editor does not offer an API-key-value field.
File locations and trust¶
| Item | Location or selection | Behavior |
|---|---|---|
| Global/user JSON | $XDG_CONFIG_HOME/ngn/config.json; defaults to ~/.config/ngn/config.json when XDG_CONFIG_HOME is unset or empty |
Automatically trusted and loaded if present. |
| Global provider registry | $XDG_CONFIG_HOME/ngn/providers.json; defaults to ~/.config/ngn/providers.json |
Shared across workspaces by web and headless ngn; no API key values. |
| Workspace provider registry | $XDG_CONFIG_HOME/ngn/workspaces/<workspace-hash>/providers.json |
Workspace-only connections and selection; inherits global connections and default. |
| Global assistant defaults | $XDG_CONFIG_HOME/ngn/assistant.md |
Native Markdown containing the assistant prompt, model/tool selections, and live settings; created from the packaged asset on startup if absent. |
| Workspace assistant defaults | $XDG_CONFIG_HOME/ngn/workspaces/<workspace-hash>/assistant.md |
Supplied fields override global defaults; missing fields and missing files inherit. |
| Agent UI overrides | $XDG_CONFIG_HOME/ngn/workspaces/<workspace-hash>/agents/<name>.md |
One native document for an agent's model, prompt, tools, and Live overrides, including assistant; section saves preserve other fields. |
| Native project agents | <workspace>/.ngn/agents/<name>.md or <name>/agent.md |
Requires trusted project discovery; assistant.md is allowed and hot-reloads with other definitions. |
| Project JSON | <workspace>/.ngn/config.json |
Ignored with a diagnostic unless --trust-project is supplied or that exact file is selected explicitly. |
| Explicit JSON | --config /any/path/settings.json |
Any filename/location ending in .json is accepted. Selecting it explicitly trusts it, including endpoint and plugin settings. |
| Workspace | --workspace PATH or -C PATH; defaults to the shell's current directory |
Must already be a directory. Determines project configuration, file-tool boundaries, and session scope. |
| State root | data_dir; default $XDG_DATA_HOME/ngn or ~/.local/share/ngn when XDG_DATA_HOME is unset or empty |
Stores workspace-scoped session databases. |
| OpenAI login store | $XDG_DATA_HOME/ngn/auth/openai.json or ~/.local/share/ngn/auth/openai.json |
Separate credential store, not a general config setting or a session database. Changing data_dir does not move it. Never include it in a config example or bug report. |
| Provider login store | $XDG_DATA_HOME/ngn/auth/login.json or ~/.local/share/ngn/auth/login.json |
Login credentials beside the ChatGPT store; this does not select a named provider. ngn logout removes it. Never include it in a config example or bug report. |
The workspace's .ngn/config.json is the project file; ngn does not search every
ancestor directory for more configuration layers. The trust decision is made
from CLI arguments before project configuration is read. There is no
trust_project = true JSON escape hatch or NGN_TRUST_PROJECT shortcut.
ngn --workspace /path/to/project --trust-project
ngn --workspace /path/to/project --config /path/to/project/.ngn/config.json
ngn --workspace /path/to/project --config /another/location/review.json
The second command explicitly trusts the selected project file without needing
--trust-project. The third trusts only the explicitly selected file in addition
to global configuration; it does not implicitly trust a different workspace
project file.
Review trusted configuration and its referenced Python code. It can redirect requests and select executable plugins. There is no safe-settings subset loaded from an untrusted project file: the entire file is skipped.
Model preferences store a complete reference, for example
"model": {"provider": "openai", "id": "gpt-6.1-sol"}. Resolution uses the
agent's model, then the workspace default, then the global default. Each layer
selects a connection and model together from the merged global/workspace
registry. A missing named connection is an error, not a fallback to a different
provider. Native agent frontmatter requires the same complete map; see
agent definitions. Startup config.json model settings
remain explicit runtime configuration, separate from these reusable documents.
Agent definitions refresh before each model call, while already issued calls
keep their accepted definitions. Team refreshes newly discovered and renamed
profiles independently of chat execution. A trusted agent_imports entry may
name a definition directory to enable these updates without trusting the entire
project. This refresh does not reload endpoints, credentials, host permission
ceilings, or arbitrary project code.
Relative paths¶
--workspace,--config, and file paths passed with--pluginresolve from the shell's current working directory, not from each other.-Cselects a workspace; it does not change how another CLI path is resolved.data_dir, provider references, and.pyplugin paths written in JSON resolve from the directory containing that JSON file. In.ngn/config.json,"data_dir": "state"means.ngn/state, andplugins: ["../extension.py:setup"]refers toextension.pyat the workspace root.NGN_DATA_DIRis a path relative to the shell's working directory unless absolute. It is the full state root; ngn does not append another/ngnto it.- Supported path values expand
~and resolve to absolute paths. Use absolute XDG environment paths. General$VARIABLEor${VARIABLE}interpolation in JSON strings is not supported. - An installed-module plugin such as
my_package.extension:setupis imported from the selected Python environment, not resolved as a filesystem path.
Complete top-level schema¶
Defaults below are built-ins, before environment, JSON, CLI, profile activation, or authentication-route selection. String choices are case-sensitive.
Model and named provider selection¶
| Field | JSON type | Default | Accepted values and meaning |
|---|---|---|---|
provider_id |
string | "" |
Optional named connection from providers.json; otherwise the registry's active connection is used. |
providers |
string or object | omitted | Relative .json file reference for this scope, or {"global": "path.json", "workspace": "path.json"}. Omitted scopes use their default providers.json. The web UI saves the selected file. |
model |
string or {provider, id} reference |
"gpt-6-astra" |
A model ID supported by the endpoint/account, or an Azure deployment name. A reference selects its named connection and model together. No model-catalog validation occurs at startup. |
Connection details—kind, api, base_url, api_key_env, auth, and
api_version—belong only to entries under providers.json → providers.NAME.
They are rejected as top-level config.json fields. The resolved connection is
available by name at CLI startup: config.provider is the selected name and
config.providers maps names to provider definitions.
At the CLI's serve(config, ...) breakpoint, inspect config.provider
and config.providers[config.provider] for its kind, auth, api, base_url,
api_key_env, and api_version. The api value selects the provider's HTTP
protocol, such as messages, responses, or chat_completions; allowed values
depend on the provider kind and authentication mode. There is no connection
wrapper or provider_registry field, and no flat config.auth or API fields. General
settings such as config.model, config.workspace, and limits remain separate.
The profile's key_env property resolves the environment-variable name;
loading configuration does not read its secret value.
| Provider string | Aliases | Default endpoint/behavior |
|---|---|---|
openai |
None | Fixed native OpenAI host; API key, ngn ChatGPT login or explicit local Codex discovery. |
openai_compatible |
None | Explicit compatible API prefix required in named connections; API-key authentication. |
openrouter |
None | https://openrouter.ai/api/v1; choose a model exposed by OpenRouter. |
anthropic |
None | https://api.anthropic.com/v1; native Messages protocol with api: auto. |
gemini |
None in named connections | https://generativelanguage.googleapis.com/v1beta; native Gemini protocol with api: auto. |
azure_openai_compatible |
None in named connections | Explicit Azure resource endpoint and nonempty api_version required. |
azure_openai_compatible_v1 |
None | Explicit Azure endpoint required; use the endpoint form expected by that route, rather than assuming the versioned Azure configuration is interchangeable. |
foundry |
None | Azure AI Foundry OpenAI-compatible v1; explicit API prefix; API key or Microsoft Entra ID. |
litellm |
None | Explicit base_url required. This is a connection to your gateway, not an embedded proxy or a LiteLLM SDK dependency. |
This table describes named providers.json kinds, not the library's enum values
or compatibility aliases in programmatic/CLI selection. api: auto retains
provider-specific routing: native OpenAI chooses by model/authentication;
compatible gateways and versioned Azure retain their supported defaults;
Messages is used for Anthropic and native Gemini for gemini. The three explicit API choices refer to /chat/completions, /responses, and
/messages respectively under the configured API base, where that provider/endpoint
supports the route. Native Gemini routing is not one of those OpenAI/Anthropic-style
paths. Named OpenAI and Azure v1 connections accept auto, responses or
chat_completions; Foundry accepts responses or chat_completions.
OpenRouter accepts auto, responses or chat_completions; compatible and
LiteLLM connections also accept messages. Anthropic accepts auto or
messages; versioned Azure accepts auto or chat_completions; native Gemini
requires auto. Server/model support remains necessary.
For named openai connections, auth: auto prefers a saved ngn ChatGPT login,
then local Codex configuration when present, then the referenced API key.
A broken selected Codex configuration does not authorize switching accounts.
"api-key" forces API-key selection. Use api: auto with automatic/subscription
authentication; set auth: api-key when explicitly selecting an API-key protocol.
"chatgpt" requires an ngn login and uses the dedicated Codex Responses route,
not a general-purpose OpenAI API credential. Named registry connections require
kind: "openai" without base_url and with api: auto. Explicitly
combining auth: chatgpt with an api override is rejected, even for
api: responses. When explicitly selecting an API-key protocol, set
auth: api-key alongside api instead of relying on automatic login
selection. Saved OAuth credentials are never sent to a custom endpoint,
including LiteLLM. Do not use api to attempt to
redirect a ChatGPT login to a gateway or to the ordinary paid API.
The key's value is read from the variable named by the active connection
when a live request needs it. Put the variable name in providers.json, not
config.json; no API-key value belongs in either file. ngn
does not automatically load .env files or borrow another coding assistant's
credentials.
Agent and tool limits¶
| Field | JSON type | Default | Accepted values and meaning |
|---|---|---|---|
agent |
string | "assistant" |
The built-in "assistant" or an explicitly configured profile name. |
read_only |
boolean | false |
Enforce read-only operation for the assistant and child agents. |
shell_timeout |
integer or float | 600.0 (10 minutes) |
Seconds, strictly greater than 0 and at most 600. Booleans are not numbers here. |
max_output |
integer | 32768 |
1024 through 1048576, inclusive; bounds tool output in bytes. |
max_file_bytes |
integer | 262144 |
1024 through 4194304, inclusive; file-size limit in bytes for guarded file operations. |
max_tool_rounds |
integer | 3000 |
1 through 3000, inclusive; maximum model/tool rounds in the agent loop. This is not the subagent count. |
max_subagent_depth |
integer | 2 |
0 through 8, inclusive. Root depth is 0, child depth 1, grandchild depth 2. 0 disables delegation; the default allows children and grandchildren, not great-grandchildren. |
demo |
boolean | false |
Offline scripted provider, no workspace mutations or shell execution, and no plugin imports. Local demo conversations are still saved. |
Integer fields reject floats and booleans even if numerically equivalent. Subagent concurrency, per-run job counts, and result-size budgets are additional safeguards, not extra JSON fields. See subagents. Subagent runs have no overall execution timeout; individual tools and network operations retain their deadlines.
The model receives the active shell timeout, output cap, and whole-file read
limit in the native tool descriptions. These descriptions refresh when settings
change and when a child harness starts. A shell call may omit timeout or use
0 for the configured default; a positive value cannot exceed shell_timeout.
Reading fewer lines does not bypass max_file_bytes: guarded reads take a
snapshot of the whole file. Invalid arguments and limit failures return tool
errors for the model to correct; they do not automatically relax limits or retry
the operation.
Terminal and submission behavior¶
| Field | JSON type | Default | Accepted values and meaning |
|---|---|---|---|
theme |
string | "terminal" |
"terminal", "graphite", "ocean", or "ember". |
theme_background |
string | "auto" |
"auto", "terminal", or "theme". Automatic preset behavior, terminal-native background, or the theme's background. Separate from palette selection. |
animations |
boolean | true |
Legacy terminal motion preference; retained for compatibility. |
submit_mode |
string | "queue" |
"queue" or "interrupt": queue new prompts during work, or cancel/await current work before sending the new prompt. |
theme, theme_background and animations configured the removed Python
terminal UI. They remain valid fields so existing files keep loading, and the
native ngn reads theme and theme_background when importing legacy Python
settings. submit_mode still controls prompts submitted while the web client is
working.
Browser GPT-Live preferences are configured in GPT-Live → Voice settings at either scope. See GPT-Live setup.
Storage and extensions¶
| Field | JSON type | Default | Accepted values and meaning |
|---|---|---|---|
data_dir |
string path | $XDG_DATA_HOME/ngn or ~/.local/share/ngn |
Full session-state root; converted to an absolute Path. JSON-relative paths use the file's directory. |
mcp_servers |
mapping | {} |
Named stdio MCP servers (command, args, optional env and cwd). Higher-priority maps replace lower-priority maps. |
plugins |
list of strings | [] |
Ordered "path.py:setup" or "installed.module:setup" references. Converted to a tuple internally. Each higher-priority JSON list replaces the previous list. |
profiles |
mapping of profile mappings | No custom profiles | Entries under profiles.NAME, merged by name with whole-profile replacement. Built-in profiles remain available. |
workspace (Path), trust_project (bool, default False), and diagnostics
(tuple[str, ...], initially empty) also exist on the Python HarnessConfig
object. They are runtime/loader inputs or outputs, not accepted JSON fields.
Select workspace and trust through the CLI; diagnostics are generated by loading.
Environment defaults¶
Every configurable top-level scalar field in the tables above has an
NGN_<UPPERCASE_FIELD_NAME> environment default. This includes
NGN_API, NGN_MAX_SUBAGENT_DEPTH, and NGN_THEME_BACKGROUND as well as
provider, model, limits, and state storage.
NGN_THEME=ocean NGN_ANIMATIONS=false ngn --demo
NGN_SUBMIT_MODE=interrupt NGN_MAX_SUBAGENT_DEPTH=1 ngn
NGN_PROVIDER_ID=team-openai ngn --model gpt-6-luna
JSON can override every one of these defaults. Booleans accept case-insensitive
true/false or 1/0 in the environment. Integer fields are converted with
integer parsing; shell_timeout uses floating-point parsing. Normal value/range
validation still applies.
There is no NGN_PLUGINS list or NGN_PROFILES mapping parser, no per-profile
environment-variable convention, and no NGN_CONFIG, NGN_WORKSPACE, or
NGN_TRUST_PROJECT configuration mechanism. Use JSON, --config, --workspace,
--trust-project, and repeatable --plugin flags as appropriate. Unknown
NGN_* environment names are not a substitute for supported fields.
Agent profiles¶
assistant is the only built-in agent. Its native assistant.md definition is
customizable; other agents come from JSON profiles or
discovered Markdown and TOML definitions.
Native Markdown contains only a YAML header enclosed by ---; body text is rejected.
name defaults to the filename, and missing fields inherit. The canonical
prompt: | field replaces the packaged assistant policy; live.prompt: | replaces
the complete voice prompt. Explicit empty prompts remain empty. Project
AGENTS.md context and runtime capability/permission messages still apply.
Use model: {provider: connection-name, id: exact-model-id} for one complete model
reference; provider connections and credentials are configured separately.
See the complete native example.
Startup creates the global $XDG_CONFIG_HOME/ngn/assistant.md from the packaged
asset when missing, with auto_update: true and a default_revision SHA-256
source digest. When that bundled revision changes, ngn logs a warning and
replaces the whole global file, including manual edits if auto_update is still
true. Set auto_update: false to keep a custom document across upgrades.
Global assistant edits in the UI set it to false and show a notice.
Use read_only: true (or NGN_READ_ONLY=true) to constrain the assistant and its
children to read-only operation. This startup restriction cannot be relaxed by
switching profiles or saving web preferences. Select assistant in JSON and
NGN_AGENT; use read_only for its read-only mode. Other names must refer to
explicitly configured custom profiles.
| Profile | Mode | Purpose |
|---|---|---|
assistant |
build |
Default interactive agent and default delegation target. Guarded changes and shell require approval; child agents inherit their parent's permission ceiling. |
Custom profile names match [A-Za-z0-9_-]{1,128}. JSON profiles accept these fields;
native Markdown additionally supports the full prompts and update metadata above:
| Profile field | Default | Meaning |
|---|---|---|
mode |
"build" |
"build" for normal guarded operation or "reviewer" for read-only operation. These are permission modes, not additional built-in agents. |
instructions |
"" |
Trusted profile instructions, appended to the harness context. They do not grant extra permissions. |
model |
omitted | Optional {provider, id} model reference on profile activation. Omission inherits workspace, then global defaults. |
description |
"" |
Description shown to the model and agent picker. |
tools |
omitted | Tool-name array; omission inherits, [] permits no tools. |
denied_tools |
[] |
Additional tool-name denials. |
allowed_agents |
omitted | Delegation target-name array; [] disables delegation. |
user_invocable |
true |
Boolean controlling user selection. |
subagent_available |
true |
Boolean controlling delegation eligibility. |
A model reference names an existing global or workspace connection; the agent
does not define credentials or its own provider. Native Markdown rejects scalar
model values and separate provider fields.
{
"agent": "audit",
"profiles": {
"audit": {
"mode": "reviewer",
"instructions": "Report bugs with file references and explain missing tests."
},
"implementation": {
"mode": "build",
"instructions": "Make the smallest correct change and verify it."
}
}
}
Activate with --agent audit or /agent audit; Tab normally cycles profiles.
A nonempty profile model is applied when the harness activates that profile,
after top-level model loading, so it can also supersede the value supplied by
--model. Leave a profile's model empty if you want top-level model selection
to govern it. In-process /model changes are runtime state, not edits to JSON.
Merge and replacement rules¶
Native same-name definitions merge their supplied fields, including individual
live keys. Missing files or keys inherit; restoring inheritance removes the
key, with no persisted inherit sentinel. An empty prompt, tools: [], or
live.enabled: false is an explicit value.
JSON profiles merge by name, with whole-profile replacement. Different names
from different files remain available, but a later profiles.audit entry
constructs a new profile and replaces the earlier audit completely. Omitted
fields in that JSON replacement return to the profile defaults.
For example, if global JSON defines audit with mode: reviewer and a model,
then a trusted project file containing only:
replaces it with a build-mode profile and an empty model override. It does
not inherit mode: reviewer. Repeat the intended mode when redefining a
read-only profile. An empty "profiles": {} mapping does not clear previously defined
profiles, and no profile deletion syntax is provided.
Delegation defaults to agent, rather than silently forcing every child into
reviewer. Child authority can never exceed the parent's effective permissions:
a reviewer parent cannot create a build-capable child by selecting agent,
build, or a custom profile. Depth limits count the root as zero. Profile
instructions cannot bypass approvals, depth limits, or the permission ceiling.
MCP servers and live reload¶
Both ngn serve and ngn run load MCP tools through the same harness. Configure
stdio servers in the user config or an explicitly trusted project config:
{
"mcp_servers": {
"docs": {
"command": "python",
"args": ["/opt/my-mcp-server.py"],
"cwd": ".."
}
}
}
cwd resolves relative to the configuration file; omitted cwd uses the workspace.
command and args are executed directly, without a shell. Servers inherit the
ngn process environment; optional env entries override it. Keep secret values
in the deployment environment instead of committing them to configuration.
Remote HTTP/SSE transports are not supported by this stdio loader.
The harness rereads the trusted configuration sources, tool selections, discovered
skills and applicable instructions after every completed model response, even
when files are unchanged and even for a final answer. It reloads Python extension
source and reuses healthy MCP connections whose declaration, direct script source,
and effective process environment are unchanged. A server's tools/list_changed
notification triggers fresh discovery on the same connection at the next boundary.
Added, changed and removed definitions become
available without restarting the UI or losing conversation history. User-message
boundaries also refresh. A changed server can briefly have overlapping old and new
instances while calls finish. The tool-batch boundary ensures that a tool's own
configuration/source edits are visible to the immediately following model request.
Tool calls returned by a response execute against that response's original implementation and schema. Its old MCP process stays alive until those calls and approvals finish; current permissions still apply. Saved tool allowances match captured source/configuration/schema identities, so unchanged reloads preserve permissions and changed implementations require approval again. Changes to project instructions invalidate old file-edit snapshots. Configuration parsing and Python extension errors retain the last working generation and produce a warning. MCP startup and discovery failures are isolated per server: other healthy tools, including newly added servers, stay available. An unavailable server is skipped at later response, tool, and message boundaries until its configuration, direct script source, or effective environment changes, or an operator explicitly retries. Environment values enter only a private digest; diagnostics never expose them. New configuration owners and parallel chat runtimes inherit known failures so saving settings or opening a chat does not silently retry a failed process. Cancellation/shutdown closes owned processes. Offline demo starts no MCP servers, and read-only profiles cannot launch custom server subprocesses. Native child agents do not inherit parent MCP servers.
A newly created <workspace>/.ngn/config.json does not become trusted just because
it was written from the web chat. Without --trust-project or an explicit selection
of that file, the running harness ignores it. Server logs report the trusted reload
locations; Tools → MCP discovery and ngn doctor show the ignored source.
An operator can merge the specifically approved MCP declaration into an
already trusted user/host configuration, preserving its other settings. Preserve
relative path semantics when moving a declaration: an explicit absolute cwd is
useful. Restart with --trust-project only when trusting the entire project
configuration is intended.
Reload locations preserve their logical paths. For example, a process started with
--config /etc/ngn/config.json follows a replacement Kubernetes ConfigMap ..data
symlink on its next reload instead of retaining an obsolete timestamped target.
Relative provider files, data directories, Python plugin paths, and MCP working
directories in an explicit symlink config retain their target-directory meaning.
Each extension reload resolves that logical source again and reads the same target
used as its relative-path base. Startup-only settings still require their normal
restart or settings action.
ngn serve logs an MCP discovery summary at startup and on every reload, including
unchanged settings and zero configured servers. The summary includes configured
and connected server counts, registered/available tool counts, logical ngn config
paths and their read/trust status, and the effective MCP source. ngn doctor and
the web Tools → MCP discovery section show the same metadata. When a reload
fails as a whole, the counts and source list describe the retained working generation
and the failure is reported separately. A partially available generation lists each
unavailable server with its safe category and recovery guidance. Retry in
Tools → MCP discovery attempts that server again; during active work it queues
the attempt for the next safe boundary. Healthy connections remain open, and
settings stay available while a retry is waiting. An attempt can still fail; its
warning remains visible until recovery or removal from the trusted configuration.
A higher-priority "mcp_servers": {} still clears
earlier declarations; the effective source makes that precedence visible. Warnings distinguish configuration parsing, MCP
startup and tool discovery failures. Tool-call authorization failures are separate
from registration. Diagnostics do not echo server arguments, environment values,
request/response bodies or credentials.
Startup provider/configuration details are logged once when the harness initializes
and remain available through ngn doctor. They are not repeated in chat or Live
delegation responses. New resource reload failures still produce an actionable
conversation warning; their current status remains visible in MCP discovery.
Workspace .vscode/mcp.json and opencode.json files produce an ignored-config
server log and appear in MCP discovery when present. ngn checks their existence
without reading or importing their contents. Add only the approved mcp_servers
declarations to a trusted ngn config;
foreign files do not grant project trust. An explicitly selected --config path
still follows ngn's configuration schema, regardless of its filename.
Verify activation in the running web Tools catalog and a subsequent model
request. A successful connection from a separate MCPManager or CLI process only
proves that separate process can discover the server. Tool discovery also does not
prove that the server is authorized to call GitHub or another external service.
Reloading never expands trusted paths or replaces provider/login, session storage, permission ceilings, task ownership, or host approval handlers. Newly created files are discovered only at the trusted paths selected at startup. Changes to those host settings still use their existing settings/restart mechanisms.
Plugins¶
Function tools can use .agents/tools/<module>.py with @tool, without a
plugins entry. Workspace code requires --trust-project before imports;
read-only agents do not import these modules. See automatic tools.
The declarations below configure broader behavior extensions and lifecycle hooks.
The setup name must be a Python identifier. Installed module names must be
dot-separated identifiers. References are checked when loading configuration;
Python import and setup happen when the harness initializes and at each model
response boundary, not during JSON parsing. A setup function may be synchronous or asynchronous and may return an
AgentPlugin or None.
JSON plugin lists replace the previous list, including "plugins": [] to clear
lower-priority entries. Repeated --plugin flags append to the final JSON
list in CLI order. There is no automatic deduplication of plugin references;
listing one twice can invoke setup twice and can fail on duplicate registrations.
ngn --config /path/to/settings.json --plugin /path/to/extension.py:setup
ngn --plugin examples/harness/runtime/commands.py:setup
Plugins are fully trusted Python code, not a sandbox or just prompt text. They
can access the network and filesystem during import/setup. ngn doctor normally
initializes them too, so it is not a safe way to inspect unknown Python code.
ngn doctor --demo skips plugin imports but still validates configuration and
initializes local demo state. Subagents do not re-import parent plugin files.
See Python extensions for the actual hook and
command interfaces.
Provider recipes¶
These snippets are provider entries under providers.json → providers.NAME;
the active name belongs in that file's active field. Set reusable chat model
defaults in assistant.md or the model selector; config.json can supply an
explicit startup model. Put API-key values in your shell or secret
manager, not in these files, URLs, or command arguments.
OpenAI API key¶
For eligible ChatGPT/Codex access instead, leave base_url unset, use
"auth": "auto" or "chatgpt", and follow device login.
That route can select a different account-supported default model.
OpenRouter¶
{
"kind": "openrouter",
"api": "chat_completions",
"auth": "api-key",
"api_key_env": "OPENROUTER_API_KEY"
}
The default endpoint is https://openrouter.ai/api/v1; no base_url override is
needed. Set the referenced key in your launcher environment. Choose a model your
OpenRouter account exposes and check that it supports tools. An explicit
environment-file launch through uv is shown in the
installation guide.
Anthropic¶
Native Gemini¶
LiteLLM gateway¶
{
"kind": "litellm",
"base_url": "http://127.0.0.1:4000/v1",
"api": "chat_completions",
"auth": "api-key",
"api_key_env": "LITELLM_API_KEY"
}
Configure the base URL and choose a model alias for your running server; the example
does not start a gateway or guarantee a route exists. For a server exposing
Responses or Messages, choose responses or messages and the corresponding
API base. The library also exposes legacy Completions, but ngn rejects that
text-only route during harness setup. Gateway authentication uses the
referenced LITELLM_API_KEY, never an ngn ChatGPT OAuth token. Legacy Completions
remains text-only, not a promise of coding-tool support.
LiteLLM 1.100.0 has a legacy streaming usage-frame serialization issue. On that one provider/route combination, ngn does not request the optional extra usage frame; it still parses usage if the gateway supplies it. Error envelopes and incomplete streams remain errors, not successful responses.
Another OpenAI-compatible endpoint¶
{
"kind": "openai_compatible",
"base_url": "http://127.0.0.1:8000/v1",
"auth": "api-key",
"api_key_env": "LOCAL_MODEL_API_KEY"
}
Use the endpoint's required key in that environment variable. The harness still expects a nonempty referenced key for a live API-key request; do not assume it detects anonymous local servers automatically.
Inspect and diagnose¶
ngn doctor --demo provides local configuration diagnostics without model calls
or Python plugin imports. /context shows effective runtime context, and
/plugins shows configured/loaded extensions. A real ngn doctor loads trusted
plugins, which can perform arbitrary I/O. These commands can create local state;
they are not side-effect-free JSON parsers.
If a setting is unexpected, check the global file, the workspace selected with
-C, whether project trust was granted, the explicit file, and CLI flags in that
order. Also check profile-specific models and runtime /model or /agent
changes. Do not attach credential files, session databases, .env contents, or
literal API keys to a diagnostic report.