Your first Agentfile
An Agentfile is one YAML file that says what an agent may reach, call and receive, and what its priced tools may cost. Constle reads it once, when the run starts, and enforces it from outside the agent.
On this page
- What you'll get
- 011. Scaffold a file
- 022. Name the agent and its image
- 033. Write the network policy
- 044. Declare what crosses from your shell
- 055. Set the isolation floor
- 066. Bound the run
- 077. Validate, and read every warning
- Mistakes that look like controls
- Where to go next
- FAQ
- Is the Agentfile read again while the agent runs?
- Does a field I leave out default to something permissive?
- Can I validate an Agentfile in CI without the keys?
Note
Release status
The current source and its signed releases aren't public yet. More in Project status.
What you'll getLink to this section
- A minimal Agentfile that validates, for an agent that calls one model API.
- The sections most agents need, and the part of the runtime that enforces each one.
- The mistakes that make a control look real when it isn't, and what
constle validatesays about each.
The policy is data, not code: there is no rule language, and fields in the Agentfile's specification are labelled ENFORCED, VALIDATED, DECLARED or INFORMATIONAL. A DECLARED field parses and changes nothing. There are four, and constle validate names each one you write. More in The Agentfile.
1. Scaffold a fileLink to this section
constle init writes a starter agent.yaml in the current directory, with a comment explaining each field. Two of those comments are out of date: a written 0 for max_duration_seconds is refused, and an allowed host that shares a server with an MCP server can reach it past the gate (limitation 2).
constle init
constle validate agent.yamlA misspelt key is an error that names the line, lists the keys that section accepts and, when one is close, suggests it. A typo such as capabilties fails validation instead of quietly turning a control off.
2. Name the agent and its imageLink to this section
identity:
name: report-writer # names the audit log; no path separators, no leading "."
version: "1.0.0"
sandbox:
image: report-writer:1.0.0 # pin a digest or an immutable tag
memory_mb: 512 # the default; caps the agent's memoryOn Docker, the agent is an ordinary container image. sandbox.command replaces the image's command. It's a list, and each item reaches the agent as written: nothing expands it. Each agent writes one log file per UTC day: ~/.constle/logs/<name>-<date>.jsonl, named after identity.name.
3. Write the network policyLink to this section
sandbox:
network:
allowed_hosts:
- api.groq.com # the one host on the allowlistallowed_hosts is the proxy's whole allowlist. An empty or absent list admits no host at the proxy. Constle's own gates stay reachable, and on Docker so does Docker's embedded resolver. Entries are plain lowercase hostnames, with one optional leading . to include subdomains. A scheme, port, path or wildcard is rejected at validate time.
sandbox.network.egress is warned about and ignored (limitation 3). How the proxy enforces the list, and what it refuses besides undeclared names: Limit where an AI agent can send data.
4. Declare what crosses from your shellLink to this section
credentials:
- name: GROQ_API_KEY # the value comes from your shell; only the name is written here
- name: AGENT_TASK # non-secret input crosses the same wayThis list is complete and exclusive for host environment variables: the sandbox receives these and no other variable from your environment. Declare nothing and nothing from your shell crosses in. secret_ref reads the value from a differently named host variable, so two agents can both see GROQ_API_KEY with different values.
Declared values do enter the sandbox, as environment variables the agent can read. Constle doesn't broker credentials: a key you declare is readable by the agent (What Constle is not).
5. Set the isolation floorLink to this section
capabilities:
- external_api # outbound API calls: network isolation at leastcapabilities is a list of action classes, and its one enforced job is the isolation floor: read_file and write_file need process, web_search, external_api and send_email need network, and spawn_subagent, external_transfer and delete_records need kernel (a Firecracker microVM). Leave sandbox.isolation out and the runtime uses the floor. Write it and it must be at least as strong. It is not a permission system: nothing is blocked at run time because it is missing from this list. Backends and levels: Architecture.
6. Bound the runLink to this section
limits:
max_duration_seconds: 300 # the supervisor kills the agent at five minutesThe timer runs in the host process, not in the agent. When it fires, the run is stopped and the audit log records terminated_by_limit. Omit it for no limit. A written 0 is refused.
7. Validate, and read every warningLink to this section
constle validate agent.yamlValidation runs nothing. It prints the isolation level it resolved (and whether it was declared or inferred), and it tells you which rules you wrote it won't enforce: gates and spend caps that can't take effect, and each field you wrote that it accepts but does not enforce. The whole file so far:
apiVersion: constle.dev/v1alpha1
kind: AgentManifest
identity:
name: report-writer
version: "1.0.0"
sandbox:
image: report-writer:1.0.0
memory_mb: 512
network:
allowed_hosts:
- api.groq.com
capabilities:
- external_api
credentials:
- name: GROQ_API_KEY
- name: AGENT_TASK
limits:
max_duration_seconds: 300On a machine where GROQ_API_KEY and AGENT_TASK are not exported, validate warns that they are unavailable and constle run refuses to start until they are. The quickstart shows that output for an agent very like this one.
Mistakes that look like controlsLink to this section
| You wrote | What actually happens | What validate and run do |
|---|---|---|
egress: none |
Ignored. allowed_hosts decides. |
Warn: ⚠️ warning: declared, not enforced by this runtime: sandbox.network.egress (limitation 3). |
require_approval_for with enabled left out |
Nothing runs. | Refused at validate: gate entries need enabled written. |
require_approval_for with enabled: false |
None of the calls that pass through the gate waits for a yes. | Warn: human_gates.enabled is false — NO gate is enforced. |
| A gate entry that provably matches no tool of a declared MCP server | That entry holds none of the calls that pass through the gate. | Warn, naming the entries that run without approval. |
max_per_run_usd with no priced MCP server |
None of the calls that pass through the gate is metered, so nothing is capped. | Warn: spending limits are declared but NOT enforced. |
max_per_month_usd |
Parsed, never enforced. | Warn: ⚠️ warning: declared, not enforced by this runtime: spending.max_per_month_usd. |
max_per_run_usd: "0" |
Refused. | Validation error: omit the field to leave a cap unset. |
isolation: network beside external_transfer |
Weaker than the floor. | Validation error naming the capability. |
identity.did with no key on this machine |
No signing key. | validate warns, and run refuses to start. |
Where to go nextLink to this section
- MCP tool allowlists and Require human approval at the MCP gate add the
mcpandhuman_gatessections. - Give each AI agent a verifiable identity adds
identity.did. With it, every line of the audit log is signed.
FAQLink to this section
Is the Agentfile read again while the agent runs?Link to this section
No. The runtime reads it once, before the sandbox starts, and nothing inside the sandbox can change it. To change the policy, stop the run, edit the file and start a new run.
Does a field I leave out default to something permissive?Link to this section
With no allowed_hosts, the proxy admits no host. Constle's own gates stay reachable, and on Docker so does Docker's embedded resolver. No credentials means no host variables. Human gates default to off, spending caps to unset and max_duration_seconds to no limit, so write the ones you want. Gates and caps then apply to calls that pass through the gate.
Can I validate an Agentfile in CI without the keys?Link to this section
Yes. constle validate warns about credentials and identities that are not available on the machine, and does not fail on them, because validation is not execution. constle run is where they are required.