writ gate
Govern an external agent at the model API boundary.
writ gate <file> [flags]The gate serves the wire protocol of the holder on a local address. It sends each permitted request to the configured provider.
The provider API key stays in the registrar. The agent receives a run token and the local base URL.
| Flag | Purpose |
|---|---|
--addr <address> |
Set the local address. The default is localhost:8787. |
--set <name>=<value> |
Give a placeholder a value. |
--config <path> |
Use the engagement configuration at this path. |
--idle-timeout <duration> |
End the session after this quiet period. There is no default timeout. |
The address must resolve to the local machine. The gate does not serve a remote address.
The writ for a gate
Section titled “The writ for a gate”The writ needs a tools grant. The grant names tools that can cross the model
API.
writ: support-agentmandate: "Resolve the support request."
grants: - tools: names: [support.search, support.reply]
bounds: iterations: 20 cost: $1.00 wall_clock: 30mThe gate removes each tool definition that no pattern permits. It records one denied entry for each removed definition.
A * permits each tool name. Use that pattern only when the agent needs each
tool that a provider can add.
Start the gate
Section titled “Start the gate”-
Set the provider API key that the engagement configuration names.
-
Start the gate.
Terminal window writ gate support-agent.yaml -
Copy the gate URL and token from standard error.
gate: http://localhost:8787 (anthropic protocol)token: wrt_run_01J9X4... -
Give the URL and token to the agent process.
For an Anthropic client, use the token as the API key. Set the base URL to the printed gate URL.
For an OpenAI client, use the token as the API key. Set the base URL to the
printed URL with /v1 at the end.
The gate replaces the run token with the provider API key. It never sends the run token to the provider.
Request checks
Section titled “Request checks”The gate makes these checks in order:
- It checks the run token.
- It checks the wall-clock, iteration, and cost bounds.
- It changes the requested model to the configured model.
- It removes tool definitions that the
toolsgrant does not permit. - It rejects a tool result for a tool that the grant does not permit.
- It sends the request to the provider.
- It charges the token usage in the provider response.
- It writes the turn to the record.
The gate supports normal JSON responses and event streams for both protocols.
Coverage
Section titled “Coverage”Gateway mode covers model iterations, model cost, and tool identity that crosses the model API.
The gate warns about each clause that it cannot enforce. It also writes each ignored clause in the issuance entry.
Gateway mode supports halt and inform for bound and invariant remedies.
An unsupported remedy action produces a warning, and the gate uses halt.
End the session
Section titled “End the session”Press Control-C to end the session. An idle timeout can also end it.
The record ends with gate session ended. A breach that halts the gate gives
exit code 1. An invalid writ gives code 2. A configuration error gives code 3.
Read the result with writ record <name>.