Agents
An agent is a versioned document: a model, instructions, tool grants, limits and, optionally, a workflow.
On this page
In Argus an agent is data, not code. It is a Markdown file with YAML front matter, named namespace/name, in the format argus.agent/v1. Because it is a document, it can be reviewed, diffed, versioned, applied from a repository and edited in the Studio.
A definition
---
apiVersion: argus.agent/v1
name: showcase/assistant
description: A plain, helpful assistant.
model:
default: { id: anthropic/claude-haiku-5-5, reasoning_effort: low }
limits:
max_steps: 10
max_cost_usd_per_run: 0.25
---
# Role
You are a helpful assistant. Answer plainly and say when you are not sure.
# Rules
- Keep answers short.
- Ask before doing anything that changes something.The front matter holds the settings and the body holds the instructions. The body may use {{variable}} placeholders, filled per session.
What a definition can say
| Field | Meaning |
|---|---|
model |
The default model and reasoning effort, optional fallbacks, optional per-call rules (model.select) and optional prompt caching (model.cache). A workflow step can name its own model. See A different model for each step, A different model for each call and Prompt caching. |
instructions and include |
The body text, plus shared instruction fragments pinned by version and composed in order. |
variables |
Template variables, each described by a JSON Schema. A session that omits a required one is refused. |
inputs |
What a session accepts besides text. inputs: { images: true } lets people attach pictures to a message; it needs a model that can read them. See Images. |
tools |
Tool grants per source: allow, ask or nothing. Default-deny. See Tools and approvals. |
limits |
max_steps, max_cost_usd_per_run, max_tokens_per_run, timeout, max_concurrent_runs. |
context |
What one model call sends: a ceiling in tokens (max_input_tokens_per_step), how many earlier turns to see (history), compaction of old tool results, session artifacts to read, and what to do when a long conversation passes the ceiling (strategy). See Long conversations. |
output |
A JSON Schema the final answer must match, or a named artifact it produces. |
routes |
Choose a different model, step limit, extra instructions and a narrower tool list per kind of request. See Routes. |
subagents |
Other agents this one may call, each by label. |
workflow |
Declared steps for multi-agent work: agents, judges, loops and human steps. |
evals |
The eval suite for this agent and the gate that guards its labels: a minimum pass rate, the most it may regress, and optionally a pairwise criterion. See Evals. |
metadata |
Free-form labels for search and grouping. |
Unknown fields are rejected, and the API can validate a definition without storing it (POST .../agents/validate), which is how the Studio shows problems before you save.
Long conversations
Every model call carries the whole conversation: the instructions, the earlier turns of the session and what the run has done so far. An agent can set a ceiling on that, context.max_input_tokens_per_step, which Argus checks before each call. What happens when a call would pass it is the agent's context.strategy:
context:
max_input_tokens_per_step: 24000
strategy: summarize # or truncate, the default
keep_last: 3 # earlier turns always sent whole (default 2)
summary_model: anthropic/claude-haiku-5-5 # optional; default is the model of the step| Strategy | When a call would pass the ceiling |
|---|---|
truncate (the default) |
The run fails with the error context_ceiling. Nothing is dropped behind your back. history.turns can still limit how many earlier turns a run sees. |
summarize |
The oldest earlier turns, all but the last keep_last, are replaced by one summary written by a model, and the run goes on. The instructions, the last keep_last turns and the run's own work are never summarised. |
A summary is written once and reused. It is recorded in the session as a context.summarized event that holds the summary text, the turns it covers, the estimated tokens before and after, and what the call cost. The next step and the next run send the same summary without calling a model, and a run that is replayed or resumed on another runner sends exactly the same request. If the conversation grows past the ceiling again, the next summary folds the old one together with only the turns that have aged out since.
The summary call is a model call like the others: it is attributed to the run, counted in its cost and in the ledger, and it uses the project's own provider key when its model is a bring-your-own-key model. The app shows it as a quiet item, "Earlier turns summarised (4 turns, 1,234 → 321 tokens)", in the timeline and on the run map, and the item's details show the summary text.
summarize needs a ceiling to react to and cannot be combined with history.turns (which already drops older turns before they can be summarised). If summarising does not make room, because the turns kept whole and the current message are too large or there is nothing older to summarise, the run fails with the error context_overflow and says what to change: a smaller keep_last or a higher ceiling. The run never summarises twice for one step, so it cannot loop. Evals run the agent through the same runner, so a suite exercises the agent's strategy and its cost includes the summaries.
Prompt-cache warnings
Model providers keep the leading part of a request (the system prompt, then the tool list) and reuse it on the next request when it is byte-for-byte the same, which makes a long prompt cheaper and quicker to start. Anything that changes that leading part from one run, or one version, to the next throws the saved copy away. Validating a definition checks for the usual causes and reports them as warnings: the definition is still valid and still saves, it just costs more and starts slower than it could. Each warning has a rule, the reason and a fix.
| Rule | What it means | Fix |
|---|---|---|
cache-volatile-early |
A date or time, a UUID, a phrase such as "today is", or a variable named like now, date, timestamp, current_*, *_id or *_at sits in the first half of the instructions, so everything after it is new on every run. |
Move it to the last lines, or send the value in the user message. |
cache-dynamic-prefix |
The prompt is longer than the model's cache minimum, but its first {{variable}} comes early, so less than half of it can be cached (providers cache only from a minimum size; the lint uses the one of the agent's default model: 512 tokens for the Claude 5.5 models, 1,024 for an unknown model). |
Put the fixed instructions first and the variables last, or move the variable text into the user message. |
cache-tools-reordered |
The tool sources, or a source's tools, are the same as in the agent's latest version but listed in a different order. The tool list is part of what is cached. | Keep the order of the previous version. |
The warnings show in the Studio above the instructions, with the line, and in argus validate -f agents/, which prints each warning with its fix and exits 0 unless a definition has an error. The tokens.cached_prefix figure of the validate answer is the part of the instructions before the first variable.
Prompt caching
An agent can ask Argus to use the provider's prompt cache. It is off unless you opt in, and the operator must also have it switched on, so no existing agent changes by itself.
model:
default: anthropic/claude-sonnet-5-5
cache:
mode: auto # off (the default when the field is absent) or auto
ttl: auto # auto (the default), 5m or 1hWith mode: auto, and the platform's models.prompt-caching flag on, the runner marks the tool list, the system prompt, the earlier turns and the latest step as cacheable on a model that supports it (Anthropic's Claude 5.5 models today). The next step of a tool loop then reads most of its prompt from the cache instead of paying the full input price. Caching is requested only when a request has tools or earlier turns, because a one-step run with neither would pay the write premium and never read it back. A prompt shorter than the model's minimum (512 tokens for the Claude 5.5 models) is not cached.
What it costs, in plain terms. The first request of a prefix is a cache write, and a write costs more than plain input: 1.25 times the input price for a 5 minute lifetime and 2 times for a 1 hour lifetime. A later request that reads the prefix pays far less (0.05 times the input price for Claude Sonnet 5.5 and Haiku 5.5). A 5 minute write pays for itself after one read; a 1 hour write pays from its second read. So caching saves money on agents that take several steps within the lifetime, and costs a little more on an agent that runs once and is not touched again.
ttl: auto picks 1 hour only when the agent can wait for a person (a tool granted with an ask list, the argus.human.ask tool, a tool a client executes, or an untrusted source allowed by a wildcard), because a step after a wait may come after more than 5 minutes. Otherwise it picks 5 minutes. The choice is made once per run. An agent that is marked 1 hour but never waits pays the higher write price for nothing, so pin ttl: 5m if that is you.
Two side effects. Tools are always offered in name order. And with caching on, compaction of old tool results (tool_results_after_steps) advances in batches of that many steps instead of every step, so the cached prefix stays the same for a while. With caching off, compaction is exactly as before.
You can see it working: each model.completed event has a cache record (mode, lifetime, breakpoints placed and left out, with reasons), its usage shows cached_tokens and cache_write_tokens, and argus usage shows the share of input read from the cache. Token budgets (max_tokens_per_run) count cached and written tokens in full, so caching does not relieve a token limit; dollar limits do benefit. The summary, judge, scoring and eval calls never use the cache.
Workflows
A workflow is a list of steps the runner executes, so the control flow is in the definition rather than in a prompt. The showcase writer shows the idea:
- a
draftstep runs a drafting agent; - a
checkstep has a judge (another agent) answer pass or fail against a rubric; - on failure, a
reviseloop runs the drafting agent again, up to a maximum number of iterations; - a final human step asks a person to approve before anything is published.
Each step becomes a card on the run map.
A different model for each step
Every step that runs an agent can name the model that agent runs on, with an optional model next to agent. The called agent runs its whole child run on that model instead of its own model.default. It still has the same tools, instructions and limits, and its own declared fallbacks still follow the model you named. The model goes through the same checks as model.default: a trial project may use only the trial models, a byok-* model needs the project's key, and a model on your own key is never followed by a platform model.
workflow:
steps:
- id: draft
agent: demo/writer
model: { id: anthropic/claude-haiku-5-5, reasoning_effort: low } # cheap first pass
- id: review
agent: demo/writer
model: { id: anthropic/claude-sonnet-5-5, reasoning_effort: high } # careful second passThe same field exists on each item of a parallel step, on map, on loop and on judge.llm; it is not valid on a human step or on a step with only tool checks, and it is refused when the called agent runs on your own runners (runs_on) or is itself a workflow (put the model on that workflow's own steps). Saving cannot know the child, so that refusal comes when the step starts, after the steps before it have run. A step's model always wins over what the called agent would pick for itself. The child's model.started events show selection: step, so you can see which model ran and why.
Routes
An agent can behave differently for different requests: a quick lookup on a small model with a few tools, a long analysis on a bigger one. Declare the kinds of request as routes. With router: rule, Argus picks one route when a run starts, by the first match that is true, and the run keeps that route to the end (it is written to the run's first event, so a resumed run does not choose again).
tools:
- { source: game, allow: [search, lookup, plan_build] }
routes:
router: rule
default: analyze
routes:
- name: lookup
match: 'input.text.startsWith("where") || input.text.startsWith("what is")'
model: { id: anthropic/claude-haiku-5-5 }
max_steps: 4
tools:
- { source: game, allow: [search] }
- name: analyze
model: { id: anthropic/claude-sonnet-5-5, reasoning_effort: high }
max_steps: 12
instructions: Work through the question step by step and show your numbers.match is a CEL expression that must give true or false. It can read input.text (the user's message), input.vars (the variables sent with that message) and session.vars (the agent's variables), and nothing else: not a model's answer, not a tool result and not the cost. Treat input.text and input.vars as untrusted. Whoever can send a message to the agent, an end user with a client token included, chooses them, so never gate a dearer model, a wider route or a tool on input.vars.premium == true or on words in the message. Put trust decisions on session.vars, which only your server sets, or on what the route narrows. For speed, strings are cut to 4 KB before a match or rule reads them, and matches() needs its pattern written in the expression as a string, not taken from a variable. A misspelt name such as input.txt is refused when you save. If a match fails to run when a request arrives (for example it reads a variable the message did not send) it counts as not matching and the next route is tried. When no route matches, default is used if it names a route; otherwise the run uses the agent's own settings.
A route can only narrow what the agent already has:
| Field | What it does |
|---|---|
model |
The model the run uses instead of model.default. The agent's fallbacks still follow it. It goes through the same checks as model.default. A workflow step's own model wins over it. |
max_steps |
Lowers the step limit for this route. It never raises the agent's own limit. |
instructions |
Added after the agent's instructions. |
tools |
Narrows the agent's tool grants to the ones listed. A tool the agent does not grant is refused when you save, and a tool the agent asks about still asks. |
A called agent (a sub-run) sees an empty input.text and no input.vars, because that text belongs to its caller. router: decision and router: model are accepted but are not executed yet: the agent runs on model.default with all its tools, and validate warns about it. Routes on a workflow agent have no effect either (put a model on the steps instead). In a run's events, run.started.route and each model.started show the route, and model.started.selection reads route:<name> when the route chose the model.
A different model for each call
An agent can also choose its model call by call. A tool loop makes many calls: the first one plans, and the ones that follow a tool result often only read the result and write a line. model.select is a short list of rules. Each rule has a when and a use; the first rule whose when is true for a call runs that call on its use model. When no rule is true, or a rule fails to run, the call runs on the model the run already has.
---
apiVersion: argus.agent/v1
name: demo/helper
model:
default: { id: anthropic/claude-sonnet-5-5, reasoning_effort: high } # the plan call
fallbacks: [{ id: anthropic/claude-haiku-5-5 }]
select:
- name: after_tool
when: 'call.after_tool && run.cost_usd < 0.50'
use: { id: anthropic/claude-haiku-5-5, reasoning_effort: low } # reading a tool result is cheap work
tools:
- { source: game, allow: [search] }
---
You help players find things.Here the first call runs on the larger model at high effort, and every call that follows a tool result runs on the smaller one at low effort, as long as the run has spent less than fifty cents. Once it has spent more, no rule is true and the calls go back to the default.
when is a CEL expression of at most 500 characters that must give true or false. It can read these variables, and nothing else (this is version 1 of the environment, select_env: 1, which is the default):
| Variable | Type | Meaning |
|---|---|---|
call.index |
int | How many calls the run has made so far; 0 for the first. |
call.after_tool |
bool | The latest message is a tool result. |
call.last_finish |
string | Why the previous call stopped: stop, tool_calls, length and so on; empty for the first call. |
run.cost_usd |
double | What the run has spent so far, at list price. |
run.elapsed_ms |
int | Time since the run started. |
context.tokens |
int | Argus's estimate of the size of the request about to be sent. |
route |
string | The route the run took, empty for none. |
node |
string | The call's name, such as step:2. |
input.vars |
map | The variables sent with the user's message; empty in a sub-run. Untrusted: the sender chooses them. |
session.vars |
map | The agent's variables as the instructions see them. |
A rule never sees what a model or a tool said: there is no variable for it, so a model or a tool result cannot steer the choice. A misspelt name such as call.indx is refused when you save. A rule that fails to run when a call is made (for example it reads a variable that was not sent) is skipped, and the next one is tried. Later versions of the environment can only add variables; a rule written for version 1 keeps working.
A few more things to know:
- Who wins. A workflow step's own
model(see above) pins the whole child run, so no rule applies to it. Otherwise the first true rule wins, then the route'smodel, thenmodel.default. - What follows the chosen model. The chosen model is tried first and your declared
fallbacksfollow it; one that is exactly the same model with the same settings is dropped. When nothing chose the model (it ismodel.default), yourfallbacksrun exactly as you wrote them, so listing the default again at a lowerreasoning_effortstill works as a retry. The agent's default is not put back in after it: a fallback is the list you wrote for when something breaks, never a quiet way back to a model that may cost more. A model on your own key (byok-*) is never followed by a platform model. - Same checks. A chosen model goes through the same checks as the default: the trial allow-list, the project's provider key, images and the budget of the call's own payer. A trial project whose rule picks a model off the list gets an error that names the allowed models; it is never swapped for another one without telling you.
- What you can see. When a rule changes the model, Argus writes a
model.routedevent just before that call'smodel.started, andmodel.started.selectionreadsrule:<name>. A run that crashes between the choice and the call replays the recorded choice, even if the cost has changed since. A rule that fails to run is listed inmodel.routed.rule_errorswith a short reason (eval_error,not_boolorcost_limit). Calls no rule chose write nothing new. Client tokens never seemodel.routed. - Validate.
argus validatewarns about a rule that can never run because an earlier one is always true, a rule that picks the same model and settings as the default, and a rule that moves the call after a tool result to another model (prompt caching and thinking state do not carry across models, so that call pays for the whole conversation again, and a model that keeps its reasoning does not get its earlier reasoning handed to another model: the turn continues without it). It also warns about a fallback on another model than the default when the agent has tools, for the same reason. A workflow agent has no model loop, somodel.selecthas no effect there; put amodelon its steps. - Up to 8 rules. Names are unique and show up in
selection.
A whole flow on different models
Every node of a flow can run on its own model: a workflow step, a route, and each call inside a tool loop. This pair of agents (shipped as mixed-models.agent.md and mixed-models-planner.agent.md in the examples) uses all of it. The workflow drafts on a small model at low effort, runs two branches side by side on two different models, and reviews on a larger model at high effort:
---
apiVersion: argus.agent/v1
name: demo/mixed-models
model:
default: { id: anthropic/claude-sonnet-5-5 }
workflow:
steps:
- id: draft
agent: demo/writer
model: { id: anthropic/claude-haiku-5-5, reasoning_effort: low }
- id: perspectives
parallel:
- agent: demo/writer
model: { id: anthropic/claude-haiku-5-5, reasoning_effort: medium }
- agent: demo/planner
model: { id: anthropic/claude-sonnet-5-5, reasoning_effort: medium }
- id: review
agent: demo/writer
model: { id: anthropic/claude-sonnet-5-5, reasoning_effort: high }
---demo/planner is a tool-loop agent. It plans on the larger model and reads each tool result on the smaller one, with a model.select rule:
---
apiVersion: argus.agent/v1
name: demo/planner
model:
default: { id: anthropic/claude-sonnet-5-5, reasoning_effort: high }
fallbacks: [{ id: anthropic/claude-haiku-5-5 }]
select:
- name: after_tool
when: 'call.after_tool && run.cost_usd < 0.50'
use: { id: anthropic/claude-haiku-5-5, reasoning_effort: low }
tools:
- { source: game, allow: [search] }
---Three things to know about how the layers fit together:
- A step's model pins the called agent for that run. In the flow above, when the
perspectivesbranch callsdemo/plannerwith amodel, the planner's whole child run uses that model. Its ownselectrule and its own routes do not change the model for that run (a route may still narrow its tools, steps and instructions). When a step names no model, the called agent's own rules and routes apply, then itsmodel.default. - What a rule can see. A
selectrule (and a route'smatch) reads a small, fixed set of variables, listed above. It never sees a model's answer or a tool result. - A model the project cannot use fails the run, and nothing is sent. If a step, route or rule names a model that a trial project may not use, a
byok-*model with no key on the project, or a model that cannot read the images in the request, the call is refused before anything goes to a provider, with the same plain error as formodel.default. Argus never swaps in a different model without telling you. A model on your own key is never followed by a platform model.
When a model fails, and what a model must have
model.fallbacks is the list of models a call moves to when something breaks. Which failures count is one table:
| Failure | Moves to the next model? |
|---|---|
model_unavailable (5xx, overloaded, a timeout) and rate_limited |
Yes. |
platform_auth (the provider refused Argus's own credential) |
Yes, but only to a model of another provider; Argus's operator is alerted. |
context_exceeded (the prompt is too long for the model) |
Only when you list it, and only to a model whose context window is known and larger. |
Everything else: invalid_request, permission, model_access_denied, provider_spend_limit, request_too_large, a missing or rejected key, an empty or cut-off answer |
No. The call stops with that error. |
model.fallback_on changes which of the four failures in the first rows move on; the list replaces the default (model_unavailable, rate_limited, platform_auth). A model on your own key is never followed by a platform model, whatever the list says.
model.requires and model.prefers say what a model must or should be able to do. The features are images, thinking, reasoning_effort and prompt_caching. A model known to lack a required feature is skipped before anything is sent (and model.routed lists the skip); if every model lacks it, the run fails with capability_unsupported, which costs nothing. A model Argus has no facts about is given the benefit of the doubt. A preferred feature that a model lacks only shows up as degraded on model.started; the call is sent anyway. Saving fails when model.default, a select rule or a route names a model that is known to lack a required feature; argus validate warns about a fallback that does, and about a model it has not probed.
model:
default: { id: anthropic/claude-sonnet-5-5 }
fallbacks: [{ id: openai/gpt-5.5 }, { id: anthropic/claude-haiku-5-5 }]
requires: [images] # never run on a model that cannot read the user's images
prefers: [prompt_caching] # fine without it; the event shows when a model lacks it
fallback_on: [model_unavailable, context_exceeded] # a refused Argus credential is not in this list: it will not move onArgus sets no deadline of its own on an attempt: every attempt keeps the run's own timeout (limits.timeout). A cut in the middle of a stream would have been billed by the provider and then paid for again by the fallback, so a per-attempt deadline is not built yet.
Fragments and schemas
Instructions that several agents share are stored as fragments, and output formats as schemas. Both are versioned like agents, and a definition that includes one pins its version, so a change to a shared fragment cannot silently change an agent that did not opt in.
Applying definitions from files
The CLI applies a folder of definitions idempotently: a version is created only for files whose content changed. See Command line and SDK.