Skip to main content

Module agent_env

Module agent_env 

Source
Expand description

The extra environment variables a definition launches with: the env content blob (agent_content, content_type = "env"), one KEY=VALUE per line, # comments and blank lines allowed. The launch reads it the way classify does (frontend/app/view/agent/agent-model.ts): a line that isn’t a comment and has no valid KEY= is skipped.

The operator edits the blob freely in My Agents. An agent edits it through Agents env_set (server/app_api/agent_env.rs), and these rules bound what it may write: no name AgentMux itself sets or that points a provider at another home or credential, no value that looks like a secret, and a small size. The one exception is the model endpoint of a Claude Code agent (ENDPOINT_NAMES): an agent may point another agent at a server of its own (a local model), on the terms in endpoint_value_problem and with the notice and undo window of server/app_api/agent_env.rs. Everything an agent reads back has the values of names it may not set hidden.

Structs§

Change
What an edit did, by name. Values of credential-looking names are HIDDEN.
ValueChange

Enums§

Line
How one line reads at launch.

Constants§

CONTENT_TYPE
The content_type of the blob.
ENDPOINT_NAMES
The Claude Code variables that choose the server and the model an agent talks to. An agent may set them, which is why they are spelled out here and not left to the reserved patterns (_BASE_URL, a credential ending): the notice, the undo window and the launch rules of spawn_env/endpoint.rs stand where the refusal stood. Other harnesses have no verified endpoint variable (providers: base_url_env_var is Claude’s alone), so nothing else is in the list.
HIDDEN
What stands for a value an agent isn’t shown.
MAX_BYTES
The most bytes an agent may write.
MAX_LINES
The most lines (comments and blanks included) an agent may write.
VAULT_REF_PREFIX
The prefix of a value that names a Vault entry: vault:<entry id>.

Functions§

check_size
text within the size an agent may write.
classify
How the launch reads raw: trimmed, # starts a comment, the key is everything before the first = and must be a valid name (not trimmed, so KEY = v is skipped), the value everything after it.
diff
What changed in the variables the launch gets from old to new.
edit
current with set applied and unset removed, every other line (and comment) as it was. A name already there has its value replaced where it stands, a new one goes at the end.
effective
The variables the launch ends up with: a name given twice has its last value.
endpoint_value_problem
Why value is not acceptable for the endpoint variable name, if it is not. A server address is plain http(s)://host[:port][/path]: no sign-in in it, no query, no fragment. A key is a reference to a Vault entry (vault:<id>; whether the agent may use that entry is the caller’s to check) or one of a few placeholder words for a server that ignores it (Ollama’s “ollama”); a real secret is never stored in the environment, where every agent that can read it would see it. The rest are numbers and model names.
is_anthropic_url
Whether url (a ANTHROPIC_BASE_URL value) is Anthropic’s own API: the one place a person’s Claude sign-in may go. Anything else, a LAN server, a proxy or another vendor, is not.
is_credential_name
Whether name looks like it holds a credential.
is_endpoint_name
Whether name is one of ENDPOINT_NAMES (any case).
is_placeholder
is_valid_name
^[a-zA-Z_][a-zA-Z0-9_]*$.
looks_like_secret
Whether value has the shape of a secret (a token with a known prefix, a private key, a JWT, …).
name_problem
Why an agent may not set or remove name, if it may not. A pattern, not a list of names: a variable that runs code or redirects traffic in the tools another agent launches is refused whatever it is called.
points_at_own_server
Whether the environment in text points the agent at a server of its own: an ANTHROPIC_BASE_URL that is not Anthropic’s. Only then does the launch ask for the model ANTHROPIC_MODEL names (endpoint_model); anywhere else it passes the model its pane’s runtime chose, which that variable cannot change.
points_at_own_server_with
points_at_own_server for an agent with a definition: the launch puts its structured model_vendor_base_url into the environment first, and it wins over an ANTHROPIC_BASE_URL line of the text, so a set one decides alone.
redacted
text as an agent is shown it: the values of names it may not set hidden, a comment that may hold a secret and a skipped line as # [hidden], every other line as written.
resolve_lines
The text an agent proposes as the whole environment (lines), with the lines it can’t write kept. It is within the size, and every line is a comment, a blank or a KEY=VALUE it may write; a line that would be skipped at launch is refused rather than kept silently. A name in current that the agent may not write (a credential, a reserved name, a hidden value) stays as the operator wrote it: where the agent kept the line as env_get showed it (NAME=[hidden], or unchanged), the operator’s line goes back in that place, and one the agent left out goes at the end.
value_problem
Why an agent may not give a variable value, if it may not.
vault_ref
The Vault entry id in value, if it is a reference to one.