Skip to main content

Module agent_runtime

Module agent_runtime 

Source
Expand description

The runtime flags a pane’s CLI is given, decided in srv.

The runtime menu shows agent:runtime block meta; the process runs on cmd:args. The frontend keeps the two in step (buildPaneArgs), but agent.open — MCP OpenAgent, layouts, agent.define + open — builds a pane without the frontend. It wrote cmd:args from the catalog alone and no agent:runtime, so the pane’s CLI ran on its own default model (Opus 5.5 / medium on current CLIs) while the menu fell back to Sonnet / high. A pane with a session on file spawns eagerly at open, before any message, so nothing ever corrected it. docs/retro/RETRO_RESUMED_AGENT_SPAWNS_WITHOUT_RUNTIME_FLAGS_2026_09_30.md, docs/reports/REPORT_AGENT_RUNTIME_BINDINGS_2026_09_30.md (G3).

Two entry points, one decision, for the two providers whose model the menu wires (Claude, Codex):

  • seed_launch — a pane agent.open is creating.
  • with_runtime_flags — a pane that already exists, at the moment it spawns. srv never reads agent:runtime otherwise, and a persistent process never re-reads cmd:args, so a pane saved before the fixes (or written by any path that forgets) would run on the CLI default for its whole life. This is the backstop that makes srv authoritative at the one moment it matters.

The defaults are duplicated from the frontend by necessity and pinned to its by providers/runtime-defaults-consistency.test.ts.

Structs§

AgentRuntimeEvent
The agentruntime event’s payload (mps_events::AgentRuntime). An absent value is omitted, not null; what the CLI reported is sent only while a process runs.
EffectiveRuntime
What the running CLI says it is ACTUALLY using, from its get_settings answer (applied): the alias on the command line resolved to a concrete model, and the effort in force. None for a field the CLI reports as null (Haiku has no effort).
Remembered
What the user last picked in the Runtime menu for an agent (last_runtime on db_agents), already validated. Each setting is optional: only what was picked is here, and the rest keeps coming from the definition.
RuntimeChoice
What Agents update with model or effort writes to a pane: the same two keys the Runtime menu writes (frontend/app/view/agent/runtime-apply.ts).
SeededLaunch
SpawnRuntime
What an agent process was actually spawned with: the runtime flags in its final argv. The Runtime menu shows what was REQUESTED (agent:runtime); this is what the process was GIVEN, so the menu can say when they differ. None for a flag the argv does not carry — the CLI then uses its own default.

Constants§

SETTINGS_REQUEST_PREFIX
Prefix of the request_id of our get_settings requests, so the answer can be told from the answers to anything else.

Functions§

agent_runtime_event
The agentruntime event for one pane (persisted, so a menu that mounts late still gets the latest). running is None when no process is alive — then there is nothing for the menu to compare against. effective is what the CLI reported using, when it has (see EffectiveRuntime).
apply_remembered
Lay what the user last picked over the definition, the way the frontend’s launch does (resolveLaunchRuntime): the remembered setting beats the definition’s flag for it, and that flag is taken out of the pane’s copy.
apply_to_meta
Write the three keys that must travel together into a new pane’s meta: cmd:args (what runs), agent:runtime (what the menu shows) and agent:provider_flags (what the frontend’s per-send rebuild reapplies — it starts from the catalog and would drop the definition’s flags on the first send otherwise, #2872). One call, so no caller can write one without the others.
effective_from_control_response
The effective runtime in a get_settings answer, or None for any other frame, an error answer (a CLI that has no get_settings) or one without applied. The shape is {type: control_response, response: {subtype: success, request_id, response: {applied: {model, effort, ...}}}}.
endpoint_model
The model a Claude Code agent pointed at a custom server (ANTHROPIC_BASE_URL in its cmd:env that is not Anthropic’s) asks it for: ANTHROPIC_MODEL, else the alias (sonnet, opus, haiku) the CLI maps to that tier’s ANTHROPIC_DEFAULT_*_MODEL. None where the agent is not on a custom server, or names no model.
flags_pin
provider_flags_pin for the definition’s flags as stored (AgentDefinition::provider_flags), which an agent with no pane open has only here.
is_claude_effort
The efforts a Claude agent takes.
is_claude_model_name
Whether model is one a Claude agent can be given: an alias (opus, sonnet, haiku) or a concrete id (claude-fable-5-2), with no space or control character in it.
provider_flags_pin
Whether the agent definition’s own provider flags (agent:provider_flags) carry a model and an effort: that is the operator’s choice, which a runtime pick does not override (with_runtime_flags).
publish_agent_runtime
runtime_choice
The pane’s runtime once model and effort (each only when given) are changed. keep_effort_flag leaves a --effort in the argv alone (the definition’s own provider flags carry one).
runtime_over_stale_flags
A one-shot pane’s (a container agent’s) cmd:args with the --model and --effort the pane’s runtime picker has since moved past taken out, so that with_runtime_flags lays the runtime’s own over them. The picker records a container agent’s choice in agent:runtime only (each turn reads cmd:args again, and no process restarts), but with_runtime_flags never overrides a flag already there, so a --model stored at launch kept the turns on the old model while the pane said the new one. The definition’s own flags are the operator’s choice and stay (provider_flags_pin), and a pane with no runtime choice keeps the flags it has.
seed_launch
Build cmd:args and agent:runtime for a freshly opened pane.
settings_request_line
The control request asking a running Claude CLI what it is using. Observed on CLI 2.1.285 to be answered straight after spawn, with no account and no message (docs/specs/SPEC_RUNTIME_MENU_REMAINING_GAPS_2026_10_01.md §7.3).
spawn_runtime_from_args
The runtime flags in args. The LAST occurrence of a repeated flag wins, which is how the CLI is expected to read them (unverified; it matters only when provider_flags repeats a flag the runtime already set). --dangerously-skip-permissions reads as bypass; --permission-mode X as X.
with_runtime_flags
args as stored in cmd:args, plus any runtime flag it lacks, taken from the pane’s agent:runtime (or the defaults when it has none).