Bountiesterminal terminal prompt Hand it to a coding agent agent-step-3.wit agent-step-3.cases.json
One step of the loop, with provider turns
A new version of agent-step-2 (it supersedes it), through agent-budget, agent-policy and agent-context-3: exactly its rules, and every assistant message it appends carries extra: the model output's extra, as given (ADR 0064); the user and tool messages it appends carry none; messages already in the state are left as they are.
Depends onagent-budgetagent-policyagent-context-3
From your terminal
npm i -g https://liberas.dev/cli/liberas.tgzexport LIBERAS_URL=https://liberas.devliberas init agent-step-3 --lang rustcd agent-step-3 && liberas build && liberas submit
Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).
claude mcp add liberas -- npx -y https://liberas.dev/cli/liberas.tgz mcp
Take the Liberas bounty agent-step-3: read the spec with liberas_spec, scaffold it in Rust with liberas_init, implement it exactly, then liberas_build and liberas_submit until it passes.
Interface (WIT)139 lines›
package root:component;
world root {
import liberas:agent/types@0.1.0;
import agent-budget: liberas:agent/budget@0.1.0;
import agent-policy: liberas:agent/policy@0.1.0;
import agent-context-3: liberas:agent/context3@0.1.0;
export liberas:agent/step3@0.1.0;
}
package liberas:agent@0.1.0 {
interface types {
record budget {
tool-calls: u32,
turns: u32,
tool-bytes: u64,
}
record tool-call {
id: string,
name: string,
arguments: string,
}
variant decision {
allow,
deny(string),
ask,
}
record policy {
deny: list<string>,
ask: list<string>,
allow: list<string>,
fallback: decision,
}
enum role {
system,
user,
assistant,
tool,
}
record message {
role: role,
content: string,
tool-call-id: option<string>,
tool-calls: option<list<tool-call>>,
extra: option<string>,
}
enum status {
idle,
thinking,
acting,
waiting-approval,
finished,
}
variant outcome {
completed(string),
cancelled,
failed(string),
}
record state {
messages: list<message>,
budget: budget,
policy: policy,
status: status,
pending: list<tool-call>,
awaiting: list<string>,
context-tokens: u32,
outcome: option<outcome>,
}
record model-output {
text: string,
tool-calls: list<tool-call>,
extra: option<string>,
}
record tool-result {
tool-call-id: string,
output: string,
ok: bool,
}
record approval {
tool-call-id: string,
allowed: bool,
}
variant event {
user-message(string),
model-output(model-output),
tool-result(tool-result),
approval(approval),
cancel,
error(string),
}
variant command {
call-model(list<message>),
run-tool(tool-call),
ask-approval(tool-call),
finish(outcome),
}
record transition {
state: state,
commands: list<command>,
}
}
interface budget {
use types.{budget, tool-call};
charge: func(current: budget, calls: list<tool-call>) -> result<budget, string>;
turn: func(current: budget) -> result<budget, string>;
}
interface policy {
use types.{policy, tool-call, decision};
decide: func(current: policy, call: tool-call) -> decision;
}
interface context3 {
use types.{message};
fit: func(messages: list<message>, limit: u32) -> list<message>;
}
interface step3 {
use types.{state, event, transition};
step: func(current: state, event: event) -> result<transition, string>;
}
}
Test vectors24›
[
{
"args": {
"event": {
"tag": "user-message",
"val": "read a and write b"
},
"current": {
"budget": {
"turns": 3,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "idle",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "model-output",
"val": {
"text": "ok",
"tool-calls": [
{
"id": "c1",
"name": "read-file",
"arguments": "{\"path\":\"a\"}"
},
{
"id": "c2",
"name": "write-file",
"arguments": "{\"path\":\"b\"}"
},
{
"id": "c3",
"name": "shell",
"arguments": "{\"cmd\":\"rm\"}"
}
]
}
},
"current": {
"budget": {
"turns": 2,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "thinking",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
},
{
"role": "user",
"content": "go",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "model-output",
"val": {
"text": "all done",
"tool-calls": []
}
},
"current": {
"budget": {
"turns": 2,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "thinking",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
},
{
"role": "user",
"content": "go",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "model-output",
"val": {
"text": "two",
"tool-calls": [
{
"id": "c1",
"name": "read-file",
"arguments": "{}"
},
{
"id": "c2",
"name": "read-file",
"arguments": "{}"
}
]
}
},
"current": {
"budget": {
"turns": 2,
"tool-bytes": 400,
"tool-calls": 1
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "thinking",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "model-output",
"val": {
"text": "denied only",
"tool-calls": [
{
"id": "c1",
"name": "shell",
"arguments": "{}"
}
]
}
},
"current": {
"budget": {
"turns": 2,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "thinking",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "model-output",
"val": {
"text": "denied only, no turns",
"tool-calls": [
{
"id": "c1",
"name": "shell",
"arguments": "{}"
}
]
}
},
"current": {
"budget": {
"turns": 0,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "thinking",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "tool-result",
"val": {
"ok": true,
"output": "contents",
"tool-call-id": "c1"
}
},
"current": {
"budget": {
"turns": 2,
"tool-bytes": 390,
"tool-calls": 3
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "acting",
"outcome": null,
"pending": [
{
"id": "c1",
"name": "read-file",
"arguments": "{\"path\":\"a\"}"
}
],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "tool-result",
"val": {
"ok": false,
"output": "no such file",
"tool-call-id": "c1"
}
},
"current": {
"budget": {
"turns": 2,
"tool-bytes": 390,
"tool-calls": 3
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "acting",
"outcome": null,
"pending": [
{
"id": "c1",
"name": "read-file",
"arguments": "{\"path\":\"a\"}"
},
{
"id": "c2",
"name": "read-file",
"arguments": "{}"
}
],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "tool-result",
"val": {
"ok": true,
"output": "x",
"tool-call-id": "zzz"
}
},
"current": {
"budget": {
"turns": 3,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "acting",
"outcome": null,
"pending": [
{
"id": "c1",
"name": "read-file",
"arguments": "{}"
}
],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "approval",
"val": {
"allowed": true,
"tool-call-id": "c2"
}
},
"current": {
"budget": {
"turns": 3,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "waiting-approval",
"outcome": null,
"pending": [
{
"id": "c2",
"name": "write-file",
"arguments": "{}"
}
],
"awaiting": [
"c2"
],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "approval",
"val": {
"allowed": false,
"tool-call-id": "c2"
}
},
"current": {
"budget": {
"turns": 2,
"tool-bytes": 400,
"tool-calls": 3
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "waiting-approval",
"outcome": null,
"pending": [
{
"id": "c2",
"name": "write-file",
"arguments": "{}"
}
],
"awaiting": [
"c2"
],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "tool-result",
"val": {
"ok": true,
"output": "x",
"tool-call-id": "c2"
}
},
"current": {
"budget": {
"turns": 3,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "waiting-approval",
"outcome": null,
"pending": [
{
"id": "c2",
"name": "write-file",
"arguments": "{}"
}
],
"awaiting": [
"c2"
],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "approval",
"val": {
"allowed": true,
"tool-call-id": "c9"
}
},
"current": {
"budget": {
"turns": 3,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "waiting-approval",
"outcome": null,
"pending": [
{
"id": "c2",
"name": "write-file",
"arguments": "{}"
}
],
"awaiting": [
"c2"
],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "cancel"
},
"current": {
"budget": {
"turns": 3,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "acting",
"outcome": null,
"pending": [
{
"id": "c1",
"name": "read-file",
"arguments": "{}"
}
],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "error",
"val": "model unreachable"
},
"current": {
"budget": {
"turns": 3,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "thinking",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "user-message",
"val": "again"
},
"current": {
"budget": {
"turns": 3,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "finished",
"outcome": {
"tag": "cancelled"
},
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "user-message",
"val": "too early"
},
"current": {
"budget": {
"turns": 3,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "thinking",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "model-output",
"val": {
"text": "unasked",
"tool-calls": []
}
},
"current": {
"budget": {
"turns": 3,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "idle",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "user-message",
"val": "no turns"
},
"current": {
"budget": {
"turns": 0,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "idle",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "user-message",
"val": "new"
},
"current": {
"budget": {
"turns": 3,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "idle",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "s",
"tool-call-id": null
},
{
"role": "user",
"content": "older and longer message",
"tool-call-id": null
},
{
"role": "assistant",
"content": "a",
"tool-call-id": null
}
],
"context-tokens": 6
}
}
},
{
"args": {
"event": {
"tag": "tool-result",
"val": {
"ok": true,
"output": "alpha",
"tool-call-id": "c1"
}
},
"current": {
"budget": {
"turns": 2,
"tool-bytes": 380,
"tool-calls": 2
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "acting",
"outcome": null,
"pending": [
{
"id": "c1",
"name": "read-file",
"arguments": "{\"path\":\"a\"}"
},
{
"id": "c2",
"name": "read-file",
"arguments": "{\"path\":\"b\"}"
}
],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
},
{
"role": "user",
"content": "read a and tell me",
"tool-call-id": null
},
{
"role": "assistant",
"extra": null,
"content": "Reading.",
"tool-calls": [
{
"id": "c1",
"name": "read-file",
"arguments": "{\"path\":\"a\"}"
},
{
"id": "c2",
"name": "read-file",
"arguments": "{\"path\":\"b\"}"
}
],
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "model-output",
"val": {
"text": "a says alpha; b is missing.",
"tool-calls": []
}
},
"current": {
"budget": {
"turns": 2,
"tool-bytes": 380,
"tool-calls": 2
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "thinking",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
},
{
"role": "user",
"content": "read a and tell me",
"tool-call-id": null
},
{
"role": "assistant",
"extra": null,
"content": "Reading.",
"tool-calls": [
{
"id": "c1",
"name": "read-file",
"arguments": "{\"path\":\"a\"}"
},
{
"id": "c2",
"name": "read-file",
"arguments": "{\"path\":\"b\"}"
}
],
"tool-call-id": null
},
{
"role": "tool",
"content": "alpha",
"tool-call-id": "c1"
},
{
"role": "tool",
"content": "error: no such file",
"tool-call-id": "c2"
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "model-output",
"val": {
"text": "Reading.",
"extra": "[{\"type\":\"thinking\",\"thinking\":\"The file first.\",\"signature\":\"sig-1\"},{\"type\":\"text\",\"text\":\"Reading.\"},{\"type\":\"tool_use\",\"id\":\"c1\",\"name\":\"read-file\",\"input\":{\"path\":\"a\"}}]",
"tool-calls": [
{
"id": "c1",
"name": "read-file",
"arguments": "{\"path\":\"a\"}"
}
]
}
},
"current": {
"budget": {
"turns": 2,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "thinking",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
},
{
"role": "user",
"content": "go",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"args": {
"event": {
"tag": "model-output",
"val": {
"text": "done",
"extra": "[{\"type\":\"text\",\"text\":\"done\"}]",
"tool-calls": []
}
},
"current": {
"budget": {
"turns": 2,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "thinking",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
},
{
"role": "user",
"content": "go",
"tool-call-id": null
},
{
"role": "assistant",
"extra": "[{\"type\":\"thinking\",\"thinking\":\"The file first.\",\"signature\":\"sig-1\"},{\"type\":\"text\",\"text\":\"Reading.\"},{\"type\":\"tool_use\",\"id\":\"c1\",\"name\":\"read-file\",\"input\":{\"path\":\"a\"}}]",
"content": "Reading.",
"tool-calls": [
{
"id": "c1",
"name": "read-file",
"arguments": "{\"path\":\"a\"}"
}
],
"tool-call-id": null
},
{
"role": "tool",
"content": "alpha",
"tool-call-id": "c1"
}
],
"context-tokens": 200
}
}
}
]Versions (units)1›
- v1by dave548282471cstable 5.1.0latestconfirmed10/23/2026
Verification9›
- Outputs must match the private reference implementation bit for bit.
- Cases are the spec's 24 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
- Components may import nothing but specs: no files, no network, no clock.
- The reference imports agent-budget, agent-policy, agent-context-3. Yours may import those, other specs, or none: an import is named after its spec, and the platform links that spec's current component. A verified implementation of a spec is interchangeable with any other.
- Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
- A remote call may execute up to 500,000,000 instructions.
- A new version of agent-step-2: its reference answers every case of agent-step-2 as it does. Once this and everything it imports are built, it runs in place of agent-step-2, at the same URL.
- Already built: a component that passes and uses at most 0.9× the current one's fuel on the same cases replaces it, and earns the spec's shares in proportion to the saving.
- Found an input where the current component disagrees with the spec? Submit it as a case (API or `liberas case`): it joins the vectors for good and earns 10% of the spec's shares. A component that then passes replaces the broken one for 25%.