docs/pkg/service/config.md
pkg/service/config service configuration
This package owns typed config.yaml, layered loading, XDG paths, provider/model
validation, and the separate auth-file boundary. Use the
configurator to edit layers.
Layers and project trust
LoadLayered applies the embedded baseline, user config, then
<cwd>/.ez-agent/config.yaml. Missing user/project files are allowed. The
configurator writes an overlay, not materialized effective config;
provider_defaults.yaml is catalog input, not a runtime layer.
Before merging overlays, the loader filters the embedded services map against
the installed programs. Each shipped service must have an executable regular
file at its configured relative path beside the physical loading executable.
Symlinks to that executable are resolved first; PATH and the launch symlink's
directory do not supply missing programs. Missing files, non-executable files,
directories and broken symlinks are omitted from the baseline rather than
registered as lazy services.
This applies to all shipped services, not just the tunnel provider. Other
embedded defaults are unchanged. User and project service entries are merged
after filtering and are never removed by this availability check, even when
their programs are missing. Saved configuration files are not rewritten.
Project config is quarantined until the user answers the exact
path-and-SHA-256 project_config_trust question. Pending/rejected leaves continue
with builtin plus user config. Trust applies only to the matching byte snapshot;
changed path or bytes create a new undecided identity. Unsafe or malformed trust
state remains quarantined and is never silently replaced.
Trust decisions are daemon-owned and fan out complete snapshots to matching
loaded/followed leaves. Trust also refreshes later-operation config and starts
newly approved on_start services. Exact file, fingerprint, and fanout mechanics
belong to config.go and tests.
Merge rules
- Mappings deep-merge; scalars replace; null removes an inherited mapping key.
- Ordinary scalar lists append with first-occurrence deduplication;
~valueremoves an inherited value. - Named entries match on
name;_removed: trueremoves an inherited entry. Provider models deep-merge, while other named entries replace. services.<name>.argsis opaque and replaces exactly.skills.pathsappends/deduplicates; leading~is literal there.
Repeated non-provider sections within a layer, such as defaults, merge in
source order using these same rules. Provider validation does not change that
behavior: repeated providers declarations, duplicate provider names, and
duplicate fields within a provider are rejected before merging can hide an
ambiguous route. Root key aliases are resolved before checking for duplicate
provider declarations or filtering project ownership. Filtering resolves YAML
aliases and << merges without changing unrelated configuration's layering
rules or editing shared alias targets.
The builtin default activates and routes run-cmd (Bash); it does not provide a
bash alias. Existing user and project entries are not rewritten, so an explicit
bash entry remains configured as written. Project bytes and trust identities
are unchanged by the builtin default change.
For example, a project overlay can remove one inherited tool and add another without copying the rest of the effective configuration:
| 1 | defaults: |
| 2 | tools: |
| 3 | - "~builtin.old-tool" |
| 4 | - project.new-tool |
Modes and flags
mode_flags is a scalar-list catalog of flag names. Each named modes entry
contains name, optional model-facing description, and optional flags.
The catalog supplies configurator choices; each mode's list attaches flags.
Code must implement the meaning of a flag. Declaring one is not an automatic
permission check or a sandbox for third-party capabilities.
The builtin plan attaches safer_bash and write_docs_only; build has no
flags. To add a flag to Plan in an overlay, append its name to mode_flags,
copy the complete currently effective plan entry into modes, and append
the flag to that entry's flags. Preserve its description and all prior flags.
Named-mode replacement does not merge partial descriptions or flag arrays.
Removing a catalog name does not detach it from every mode.
The active mode is separate leaf config under builtin.mode. Defining modes
does not select one. Fresh independent leaves have no mode; CLI children can
inherit a parent's selection and resumes retain the saved mode. Clearing the
selection uses defaults.flags, an optional scalar list, for builtin flag
checks. With no configured default flags it supplies none, not an implicit
Build or Plan. These flags apply only with no selected mode; named modes use
only their own flags and do not inherit defaults.flags. Unknown selected names
do not fall back to defaults. Default flags follow normal scalar-list layering,
including ~flag removals. They do not provide mode instructions.
There is no default_mode configuration setting. The configurator's Modes
screen exposes defaults.flags as <<default>>, not as a synthetic mode. Its
separate Flags and Modes screens are described in the
guide.
Installed agents can read embed:skills/reflection/references/modes.md for
editing and embed:skills/ruby/references/mode-flags.md for caller-specific
lookup. A tool owns its missing-mode, config-error, and failed-read policy.
Schema outline
Top-level configuration includes providers/models and defaults, optional
small/audit models, user-global default_model_source and sharing, tool
overrides, named services, daemon options, modes and flags, skills paths, and
auth_file. Model metadata may carry limits, thinking,
headers, listing, Responses features, ZDR requirements, and stream-inactivity
policy. Unknown top-level settings survive merge/re-encode; nested unknown-key
behavior is schema-specific.
Reasoning summary, prompt-cache routing, timeout fields, and Wafer ZDR are
model/provider policy. Their exact request behavior belongs to
service/agent; shipped defaults belong to
builtin.yaml and
provider_defaults.yaml.
All OpenAI Responses requests use the public Responses API and send store: false.
There is no dialect selection or model-specific protocol roster. API-key and
subscription requests share developer instructions and the public
additional_tools field. The routes differ only in bearer authentication,
authorization and admission, endpoint enforcement, and the subscription exception
for max_output_tokens. Before strict runtime decoding, the loader removes only
dialect, api_key_dialect, subscription_dialect, and remote_response_storage
from resolved provider and model responses maps in the merged in-memory YAML,
including aliased settings and settings inherited through << merges. The YAML
decoder resolves these mappings with its normal merge and explicit-override
precedence. Cleanup edits detached node maps, not source layers or shared alias
targets. The YAML decoder also rejects cyclic aliases. Other unknown fields still
fail strict validation. Saved YAML is unchanged, and the configurator preserves
these retired keys as opaque metadata.
HTTP sends full canonical history. Canonical first-party API-key and subscription
routes prefer WebSocket unless responses.websocket: false opts out. WebSocket
uses only connection-local in-memory continuation, with full history on reconnect
or missing context. prompt_cache_key remains a separate warm prompt-prefix
routing hint and does not enable retrievable Response-object storage.
responses.send_max_output_tokens defaults to true for non-subscription
Responses profiles. When enabled, a positive effective max_tokens is sent as
max_output_tokens; an explicit false omits it. Model values override provider
values. Subscription requests always omit the field regardless of this setting.
The configurator exposes Send output token limit for type: openai
provider/model editors. This is a per-response limit, not a session spending cap.
Supported timeout overrides remain editable.
The configurator groups supported subscription tuning under Advanced
settings, while ordinary providers keep those fields in their main editor.
Subscription provider and model forms omit max_tokens. The subscription route
does not send it as an output cap. Saved values remain as local model metadata
and are preserved when editing other settings. Subscription forms also omit
Send output token limit. Remote response storage controls are retired for all
Responses profiles.
Remote provider descriptors and export policy
User-global sharing controls provider-wide exports. Its mode is none,
all, or selected. All is a persistent policy that includes future local
providers and their configured models. None withdraws exports without deleting
providers or saved selections. Selected shares every configured model of each
selected provider. Profiles such as openai-cheap and openai-expensive provide
the selection granularity; there is no per-model ACL.
| 1 | sharing: |
| 2 | mode: selected |
| 3 | providers: [openai-cheap] |
The configurator manages this under Global User Config → Model sources &
sharing. With no sharing policy, existing per-provider remote_eligible
values retain their behavior. This legacy policy does not automatically share
future providers, even if all current providers are eligible. No providers are
shared by default. Only openai, openai_oauth, openai_compatible, anthropic,
ollama, wafer, and external can be exported. Remote descriptors cannot be
re-exported. Project configuration cannot change sharing policy or connections.
A consumer's type: remote entry is a host connection descriptor, not a vendor
adapter. It requires exactly one absolute Unix socket path or an ssh mapping
with destination and an absolute remote socket path.
default_model_source optionally names one user-global remote descriptor. An
empty or absent value keeps local routing. When a remote is the default source,
its entire discovered catalog is available as ordinary provider/model refs.
Model listings also use those ordinary names for saved favorites and role refs,
without duplicate source-prefixed rows. Local overrides and source-name conflicts
retain an explicit remote entry so either route can be selected. Explicitly typed
source refs and existing session selections remain valid and keep their original
identity; hiding a browser alias does not change routing or thinking metadata.
No model allowlist or copied catalog belongs in the consumer configuration:
| 1 | providers: |
| 2 | main: |
| 3 | type: remote |
| 4 | socket: /run/user/1000/ez-agent-host/ez-agent.sock |
| 5 | default_model_source: main |
| 6 | default_model: oai-export/careful |
| 7 | small_model: compatible/org/model/v2 |
An exact configured local provider/model entry wins over the default source,
even if that local adapter is unavailable or its credentials fail. A provider
profile alone does not shadow the host's remaining models. With a remote default,
role refs in default_model, small_model, and audit_model do not implicitly
create local overrides; those require an entry in the local provider's models.
An explicit main/provider/model ref always selects main, bypassing both the
default source and local overrides. Explicit refs remain valid when the default
source changes or is cleared, without a saved model entry. There is no failover
between local and remote routes, sources, or models.
Additional remote descriptors can retain saved provider/model browser favorites,
not dispatch allowlists. Every source permits explicit references to its exported
models. The saved favorite format also works without a default remote source:
| 1 | providers: |
| 2 | main: |
| 3 | type: remote |
| 4 | ssh: |
| 5 | destination: user@provider-host |
| 6 | socket: /run/user/1000/ez-agent/ez-agent.sock |
| 7 | models: |
| 8 | - name: oai-export/careful |
| 9 | - name: compatible/org/model/v2 |
| 10 | default_model: main/oai-export/careful |
| 11 | small_model: main/compatible/org/model/v2 |
| 12 | |
| 13 | # For direct AF_UNIX access, replace ssh with: |
| 14 | # socket: /run/user/1000/ez-agent-main/ez-agent.sock |
Every discovered non-default source lists its exports with explicit
source/provider/model refs, even without saved favorites. Favorites retain rows
through discovery failure or export withdrawal; they are not required to select
a healthy model. The default source lists ordinary names without duplicate
source-prefixed rows and needs no saved model list.
Duplicate host aliases within a YAML provider mapping are errors, including a
local profile and a remote host with the same name. Remote host and exported provider names must
be nonempty and contain no slash, whitespace, or control character. These rules
do not restrict upstream model IDs. Configured remote aliases reserve their first
path segment for explicit source selection. Choose aliases distinct from exported
provider names to use every ordinary name. If an export collides with a source
alias, model browsers show its explicit source/provider/model form rather than
selecting a different route or hiding the model.
Remote descriptors cannot be exported and cannot contain local adapter settings
such as endpoints, headers, commands, process options, timeouts, capabilities, or
model aliases. Remote model selections contain only name; host metadata is
separate. Config validation bypasses consumer auth policy for remote entries,
and GetAPIKey and GetOAuthCredentials return no credentials for them. Local
providers retain their endpoint and authentication validation.
Connection settings, default_model_source, sharing policy, and additional
remote favorites are user-global. Project overlays cannot change the default
source or sharing policy, add remote descriptors, alter or delete existing remote
entries, or set remote_eligible, socket, or ssh. These restrictions apply
after resolving YAML aliases and merge keys, even to trusted projects. A project
can still choose a model from the default remote source or use an explicit source
reference in default_model, small_model, or audit_model, and configure exact
local model overrides. Auth reload, CloneWithReloadedAuth, project localization,
and config save/load preserve the default source, destination and selections.
Configuration loading performs no discovery, network probe, SSH launch, or LLM
login. Missing hosts do not invalidate a saved selection or remove it. Transport
and discovery owners keep refreshed availability separate from saved YAML.
Opening remote model setup or a daemon-backed model browser refreshes the live
macro inventory and LIST catalogs with bounded work. The daemon's list_models
combines configured refs with the default source's discovered models as ordinary
provider/model refs. Exact local entries retain their own metadata. Additional
sources contribute only their saved refs. Selected default/small/audit refs remain
visible even when missing from discovery; existing flags mark not-found after
a successful refresh with a missing provider or model, and unavailable when
discovery fails. Dynamic catalog entries disappear when no longer advertised,
without changing the role selections or YAML. Neither condition permits fallback
to another route. Setup
creates no leaf and performs no inference, bridge launch or credential lookup.
See the configurator workflow.
SSH transport requires already-working keys or SSH-agent identities, destination
authorization, and verified host trust in the daemon's environment. Socket access
grants full host daemon access, not a provider-only API; do not expose a forwarded
socket to an environment that should not have that access.
Config.ParseModel still splits at the first slash. ParseRemoteModel splits
the remaining selection once more, so main/compatible/org/model/v2 retains
org/model/v2 as the provider-local model ID. ConfiguredModelRoute returns a
ModelRoute containing the full selected Ref, remote Host, host Provider,
and provider-local Model. Local routes have an empty Host and keep their
existing provider/model interpretation. This helper checks saved configuration
only. The agent's RemoteProviders.Resolve performs bounded discovery and
resolves the actual adapter before cycle dispatch. See
consumer routing.
Thinking-level normalization preserves a remote selection's requested value until runtime metadata is available. The resolved cycle validates it against the host's advertised levels, just as a local cycle does. The saved descriptor itself does not acquire capability metadata or consumer credentials.
RemoteProviderMetadata and RemoteModelMetadata define a separate non-secret
catalog shape for transport owners. They include model alias targets, effective
limits, thinking/ZDR metadata, access programs, Responses capabilities, and
provider stream timeouts. They cannot carry URLs, headers, process settings, or
auth. Before publishing metadata, provider adapters must resolve endpoint-based
WebSocket and prompt-cache defaults explicitly instead of letting a consumer
infer them from a synthetic endpoint. Catalog decoding and runtime route
resolution are not performed by this configuration package.
The macro namespace tunnel.llmprovider and all its dot-prefixed descendants
are reserved for daemon-owned exports. Config rejects these names in
services.*.macros and defaults.triggers. IsReservedProviderExportMacro
provides the same check for inbound registration owners;
ProviderExportMacroName and ParseProviderExportMacro validate exact names and
provider suffixes. These config helpers do not register exports or filter
runtime announcements themselves.
Provider-local model aliases
A configured model may set base_model to the real request model ID in the
same provider. name remains the selected identity in defaults, model listings,
sessions, subagents, and workflows. For example:
| 1 | providers: |
| 2 | my-openai: |
| 3 | type: openai |
| 4 | base_url: https://api.openai.com/v1 |
| 5 | models: |
| 6 | - name: careful |
| 7 | base_model: gpt-6.1-sol |
| 8 | thinking_levels: [high] |
| 9 | responses: |
| 10 | reasoning_summary: false |
| 11 | default_model: my-openai/careful |
Only provider adapters resolve careful to gpt-6.1-sol for requests. This
works for OpenAI API-key and subscription profiles, OpenAI-compatible endpoints,
Anthropic, Wafer, and Ollama. Without base_model, behavior is unchanged.
base_model is a literal model ID, not another configured alias or a
provider/model reference. It does not need a separate configured entry;
EzAgent does not chase alias chains or test model availability while loading.
Runtime loading and configurator displays share alias metadata precedence via
ResolveAliasModelMetadata, using the caller's provider catalog. Absent alias
limits, thinking levels, ZDR settings, and Responses capabilities inherit builtin
metadata for base_model under that provider type. Display defaults do not
become saved YAML overrides. Subscription profiles use OpenAI metadata.
Explicit alias settings win, including false booleans and an empty
thinking_levels list.
Other configured entries with matching names do not supply metadata. Unknown
base models retain provider-type defaults where available; configure their
model-specific limits explicitly.
Create general aliases by editing the appropriate YAML layer, directly or with
agent assistance. The configurator creates the access-program subset described
below, not arbitrary aliases. Its editors preserve saved names and base_model,
and discovery does not remove saved aliases that the provider does not list.
Access programs
OpenAI API-key and subscription models can set access_programs, a mapping of
program categories to explicit selections. Both HTTP and WebSocket Responses
requests send this mapping. The cyber category accepts standard,
daybreak_blue, or daybreak_red. Other categories are passed through for
future programs. Categories and selections must be nonempty strings.
Absent or empty mappings omit the entire HTTP access_programs field. This is
Auto, which leaves selection to OpenAI and does not force standard safeguards.
EzAgent does not restrict programs by model or authentication mode. OpenAI owns
eligibility and access checks. Rejections retain the API's error code; EzAgent
does not retry with a different program.
| 1 | providers: |
| 2 | openai: |
| 3 | type: openai |
| 4 | base_url: https://api.openai.com/v1 |
| 5 | models: |
| 6 | - name: gpt-6.1-sol |
| 7 | - name: gpt-6.1-sol-BLUE |
| 8 | base_model: gpt-6.1-sol |
| 9 | access_programs: |
| 10 | cyber: daybreak_blue |
This is model metadata, not a provider default, and requires type: openai or
type: openai_oauth. Each enabled variant is a normal selectable model entry,
so defaults and sessions can select openai/gpt-6.1-sol-BLUE independently.
Mappings deep-merge across layers. Override individual categories or use
access_programs: null to remove an inherited mapping and restore Auto. An
empty mapping does not clear inherited categories.
The configurator groups the single-category cyber aliases by explicit
base_model and access_programs, never by their names. Its Auto, Standard,
Blue and Red checkboxes preserve existing matching YAML names and duplicate
same-program entries. New names use -STANDARD, -BLUE and -RED in the same
provider, adding a numeric suffix with a notice when a name is already in use.
Unchanged checkboxes do not rewrite variants. The grouped editor's base settings
apply to Auto and newly created variants; Edit variant settings edits one saved
variant at a time without changing its peers. Entries with multiple or future
categories and general aliases remain outside this subset. Use YAML to manage
them. Deactivation keeps a removal record with variant metadata for reactivation.
Dormant identity is read from the merged layers, so sparse removal records retain
inherited program identity and customized names while keeping local writes sparse.
External provider configuration
An external provider profile starts an owned --stdio subprocess lazily for
an Agent execution and reuses it across that execution's model steps. This is
the generic host integration. For the native Muse executable and its limits,
see the Muse bridge guide.
| 1 | providers: |
| 2 | example: |
| 3 | type: external |
| 4 | command: example-provider |
| 5 | args: [--verbose] |
| 6 | pass_env: [EXAMPLE_SETTING] |
| 7 | startup_timeout: 15s |
| 8 | first_output_timeout: 10m |
| 9 | stream_idle_timeout: 5m |
| 10 | options: |
| 11 | endpoint: https://example.invalid |
| 12 | models: |
| 13 | - name: alias |
| 14 | base_model: backend-model |
| 15 | default_model: example/alias |
command is required and must be a PATH basename or an absolute path, not a
relative path. args is an argument list, not a shell command. pass_env names
environment variables; do not put their values in configuration. options is
a JSON-compatible object for the provider. Do not put secrets in options or
arguments. An explicit startup_timeout must be a positive Go duration, as must
the existing stream timeout settings. Model aliases and metadata work as for
other provider profiles. External profiles do not accept base_url,
extra_headers, or provider-level responses settings. The existing API-key
auth validation applies; subscription auth is not accepted.
The launcher passes an absolute XDG_DATA_HOME through to external providers;
when unset or relative, it is omitted so programs can use the HOME-based XDG
default. All XDG variable names remain reserved from pass_env.
In layered configuration, provider args and pass_env replace the lower
layer's entire list; options maps merge normally, while arrays within options
replace the lower layer's arrays. Layered map nulls remove inherited keys, so the
editor rejects a JSON null value when that value cannot survive the merge.
Arguments and option values are literal data: leading tildes and _removed
inside options are not configuration removal markers.
The configurator offers
explicit, cancellable model discovery, which does not run on opening the
editor or write configuration by itself. See the configurator model guide.
The child receives the selected provider's API key in private startup auth,
if configured. It runs in private scratch with isolated XDG cache, state and
runtime directories, while retaining the user's HOME and XDG configuration
directory for native login resolution. Only explicitly listed additional
environment variables are inherited. Stderr
is discarded. First-output and idle timeouts count semantic output, not status
messages. The child is retired on execution end or provider identity change.
Switching to a non-external provider also retires it; switching back starts a
new process with a full context replacement. Agent error diagnostics omit
provider-controlled error messages and protocol values.
Authentication and validation
auth_file names separate user-global credentials. Project config cannot change
that path. Credential files must satisfy ownership, type, and permission checks;
diagnostics reveal no contents. OAuth persistence refuses to overwrite static
API-key configuration.
Credential-bearing destinations require absolute HTTPS URLs. Credential-free local-compatible profiles may explicitly use HTTP until credentials or extra headers make them credential-bearing. Supported provider types and exact OpenAI API-key/OAuth pairing are validated before request construction; there is no authentication fallback between profiles.
OpenAI Responses has two deterministic provider modes. type: openai uses only
the same-named auth profile's api_key_env when set and nonempty, or api_key,
and requires an HTTPS base_url. Relay base paths are preserved, so
https://relay.example/openai/v1 routes Responses to /openai/v1/responses.
The URL may not contain userinfo, a query, or a fragment. type: openai_oauth
selects a SIWC registration through the same-named type: openai_chatgpt auth
profile and uses canonical public OpenAI subscription endpoints. It rejects
base_url. Legacy type: oauth records are retained for reconnection guidance
but are never used for discovery, refresh, or inference.
Subscription auth and API-key credentials cannot coexist in an auth profile.
Legacy type: oauth or flat access, refresh, expires, and account_id
keys are detected without decoding their token values or expiry. They require
reconnection through a separate type: openai_oauth provider with no base_url;
keep API keys on an API-key provider. A mixed record fails closed, including a
record falsely labeled api_key or openai_chatgpt. A missing or unavailable
credential fails the selected profile rather than borrowing another route.
API-key environment variables take precedence over the static key within that
one profile. Provider-independent fallback_models selection, where configured
by a caller, is unaffected. Every effective api_key_env name is also removed
from configured service subprocess environments, regardless of whether the name
follows a conventional credential suffix.
OAuth login and refresh persistence also refuse to overwrite an existing
api_key or api_key_env; migrate the key first, and the rejected auth entry
remains unchanged.
OpenAI extra_headers cannot replace or introduce Authorization or
ChatGPT-Account-Id; the selected mode owns those headers on HTTP and WebSocket
requests. Exact OAuth flow rules are owned by pkg/oauth.
After loading, callers must check ConfigError. Effective config requires an
existing provider and provider/model default. Service entries require a path;
startup_timeout defaults to 10 seconds and must be positive. Daemon vacuum
bounds must validate. Loading returns a usable *Config while recording decode,
auth-load, or validation failures. Credential availability is checked when the
selected profile starts a model cycle. Legacy direct_connections is rejected
in favor of services.
ChatGPT accounts and renewable credentials
auth.yaml has one reserved _chatgpt entry containing a registrations map.
Each key is the SHA-256 of the JSON array of validated client ID, issuer and
subject, as returned by OAuthCredentials.RegistrationKey(). Email is display
information, never an identity or workspace key. Provider entries contain
type: openai_chatgpt, selected_registration, and selection_generation.
Multiple provider profiles can explicitly select the same registration without
copying its tokens. There is no automatic account rotation or API-key fallback.
A registration retains the issued client ID, verified issuer/subject, necessary
email display information, ID/access/refresh tokens, bearer type, granted scopes,
millisecond expiry, and session ID. background_authorized: true and
consent_version: 1 record affirmative acceptance of the configurator's privacy
and background-work notice. A complete identity without direct-plan permission
may stay signed in but cannot invoke subscription models. Missing local acceptance
also disables the connection. Sign-out clears tokens, expiry and session ID and
withdraws background authorization, retaining identity, issued client mappings,
selection and _chatgpt.welcome_shown.
EnsureSubscriptionHostID(ctx) shares a stable opaque UUIDv4 URI between the
configurator and daemon. Its protected installation.yaml is always under
ConfigDir(), independent of auth_file and every project/user configuration
overlay. Projects cannot supply, override or clear it. A malformed or unsafe
saved identity fails closed instead of silently generating another host. Keep
the file across normal container restarts; independently provisioned or cloned
installations need distinct identities. Runtime consumers must use this shared
function, not a host value from configuration extensions.
Config.ResolveSubscriptionAdmission(ctx, providerName) is the shared
credential owner for agent inference. Its request-local SubscriptionAdmission
captures credentials, provider profile and selection generation together.
CheckSubscriptionSession checks that same admission before network work and
during the authorization watcher. A switch away and back invalidates it even
if the registration and session match again between polls. Token renewal alone
does not change the selection generation or invalidate existing admissions.
ResolveSubscriptionCredentials retains its credential-only signature for
configurator discovery and delegates to the same resolver.
The resolver rereads protected disk state rather
than trusting a captured leaf's auth snapshot. Near expiry it acquires a
registration/session-specific cross-process refresh lock, rereads again, and
skips renewal if another owner already renewed. Different sessions are not
blocked by one session's network wait. A separate auth.yaml.mutation.lock
covers only fresh-read/merge/write through MutateAuthFile. Every writer uses
that boundary. Lock files are durable and must not be removed while users of
the installation are running. Their parent directory must be owner-controlled.
Session-lock waiting remains cancellable. After the locked reread and a final request-cancellation check, renewal owns a separate 65-second context through refresh and validation, including mocked operations. Caller cancellation cannot interrupt response delivery after token consumption. Only pre-submission OpenID discovery failures receive the resolver's bounded automatic retry.
Renewal replaces tokens, expiry and scopes together. Persistence compares the shared registration, session and tokens, independently of the initiating provider's selection. A validated rotation is saved under a bounded 10-second context independent of caller cancellation, while the session lock remains held. The canceled request receives no admission, but later work can use the replacement instead of retrying a consumed refresh token. If provider A switches accounts while renewing a registration also selected by B, the rotation is saved for B but A cannot use it. A's selection generation is checked again before admitting the renewed credentials, including a switch away and back. Sign-out or replacement prevents a late renewal from restoring an obsolete session. Withdrawal retains any rotation of its still-current session while preserving the withdrawn local acceptance, so it cannot re-enable requests or lose the rotating token.
A token-refresh POST transport failure or temporary status retains credentials
without an immediate automatic replay, since the token may have been consumed.
A truly lost provider response needs server support to recover. This failure
adds no disabled or recovery flag; later deliberate requests may retry. A refresh
invalid_grant also preserves the entire login and selection without an immediate
automatic retry. It fails that request, but later inference or explicit model
discovery can retry renewal without forced sign-in. The rejection alone does not
invalidate previously admitted work. Explicit token-expiry, invalidation, and
reuse errors, and the separate local refresh_response_invalid result
after an unvalidated rotation, clear tokens but keep the registration. Cleanup
is bounded and still runs after caller cancellation; the consumed token is not
re-POSTed. invalid_client requires fixing client configuration, not repeated
sign-in. Persistence failure is surfaced without publishing a token set to
leaves. Reduced scopes are persisted as a disabled connection. No mutation lock
covers network work.
GetOAuthCredentials returns only a copy of selected SIWC state. Callers must
check UsableSubscription(); inference must use the resolver to obtain current,
renewed credentials. The dead token-only PersistOAuthCredentials and
UpdateOAuthCredentials helpers were removed. AuthProvider no longer contains
flat legacy Access, Refresh, Expires, or AccountID fields. Opaque YAML
still survives writes until explicit replacement or removal.
Browser login calls StageSubscriptionLogin before authorization, for both new
and returning registrations. The attempt owns one provider selection/generation
and a copy of the chosen registration. SaveSubscriptionLoginAttempt compares
both under the mutation lock. A newer account selection, successful login,
withdrawal, or sign-out defeats the older browser attempt. A rejected transaction
cannot silently select its account again. The configurator attempts bounded
revocation of its uncommitted token set outside the writer lock. It never revokes
a token set already committed locally. The unused synchronous
SaveSubscriptionLogin wrapper was removed; all callers use the staged APIs.
SelectSubscriptionAccount merges only type, selected_registration, and
selection_generation into the current provider mapping. Explicit legacy
migration removes known flat legacy token fields, not opaque provider metadata.
Other registrations and opaque metadata survive selection/login writes.
SignOutSubscription first withdraws authorization under the short mutation
lock and increments the provider generation. Active inference observes that
withdrawal and newly prepared requests fail closed before sign-out waits for the
session refresh lock. The session identity and rotating tokens remain available
so an in-flight renewal can persist its latest token without restoring acceptance.
After acquiring the session lock, sign-out checks provider selection/generation
and session again, rereads the latest rotating token, and clears locally before
bounded remote revocation. A newer selection returns ErrSubscriptionChanged,
not a false successful sign-out of another account; it neither clears nor revokes
the former registration after that change. Retry the explicit action for the
desired selected account. A replacement session is never cleared.
If the bounded lock wait fails, cleanup clears only the still-matching session and selection without revoking an obsolete token. Unconfirmed revocation directs the user to disconnect EzAgent in ChatGPT settings. Withdrawal also increments the provider generation, blocks new requests, and is observed by admitted inference. Abort or stop running work through the client when needed; protected polling cannot undo an inference request the service has already processed.
Subscription model defaults
Live discovery uses the selected account's authenticated
GET https://api.openai.com/v1/models. The configurator parses .models, keeps
visibility: "list", preserves server order, shows display_name, and saves
slug. The daemon consumes configured choices without discovering on every
inference. A discovery omission does not establish that a model is unusable;
OpenAI's inference admission decides access.
provider_defaults.yaml is the single maintained source of known models and
editable metadata. Subscription pickers supplement live discovery with its
non-unlisted openai entries. unlisted: true keeps metadata without offering
general suggestions; discovered or explicitly configured names still work.
Known names are trusted configuration choices, not an authorization grant or
runtime allowlist. Names outside both catalogs can also be entered manually.
New slugs remain selectable with generic thinking options and no
invented context/output limits. All models use the same public Responses API;
the catalog provides editable settings, not protocol selection.
Discovery failure retains saved and known model choices,
never as proof of authorization. Missing/withdrawn credentials still prevent
inference, and a rejected model request is reported without account rotation,
legacy auth, or API-key billing fallback.
Model tool-call batching
responses.parallel_tool_calls is an optional provider/model boolean. It defaults
to true for the public Responses API. An explicit model value overrides the
provider value, including an explicit false to disable batching for
compatibility. This allows the model to return multiple independent calls in
one response; it does not grant permission to execute tools concurrently.
The bounded live acceptance procedure is in the
provider reference.
Configured services and reload
Direct services may launch lazily as daemon-owned stdio JSONL processes;
on_start services launch eagerly after readiness or project trust. Capability
names remain daemon-global, and a live provider wins over configured loading
fallback. Use unique service/capability names for implementations that must
coexist.
Non-direct services cannot route tools/plugins/macros. Executable resolution
uses explicit absolute/home-relative paths or paths relative to the daemon
binary, never PATH or project config location. Arguments are literal;
ruby: true uses the sibling Ruby launcher. Runtime behavior belongs to the
service and process_pool.go.
Reload publishes replacement global snapshots and invalidates project caches.
An active Agent keeps its admitted runtime config until idle. Auth-only reloads
replace credentials and rerun provider/auth validation without erasing unrelated
config errors. An absent auth file is authoritative empty state: removed API keys
and SIWC records are not copied from a cached snapshot. A read/security/YAML error
instead fails reload without publishing an empty or partially read map.
Introducing mixed credentials publishes a configuration error; correcting an
auth-related error clears it without requiring a full config.yaml reload.
Authority
- Schema, merge, validation, paths:
config.go. - SIWC credential ownership, auth mutations and host identity:
subscription.go,subscription_host.go. - Effective baseline:
builtin.yaml. - Catalog:
provider_defaults.yaml. - Shared opaque model response metadata:
model_metadata.go. - Edge cases:
config_test.go,merge_provider_defaults_test.go, skills, service, and auth tests. - Capability ownership: service rules.