Sub-agents
A sub-agent is a tool call the host answers by running a child loop; these are the decisions (ADR 0066). spawn(parent, call, share): share must be 1–100 (else "share: 1 to 100 percent"); the call's arguments must be JSON with a string task (else "tool call {id}: arguments are not JSON" / "tool call {id}: arguments have no task"). The child's budget is floor(parent's tool-calls · share / 100), the same for turns, and for tool-bytes floor(b / 100) · share + floor((b mod 100) · share / 100); the parent keeps the remainder of each. The child's messages are one system message: the parent's system messages' contents in order joined by "\n\n", then (after "\n\n" when there were any) the text "You are a sub-agent. Do the task below and answer with its result; nobody can approve anything for you."; its policy is deny = parent's deny followed by parent's ask, ask = [], allow = parent's allow, fallback = deny("needs a person") when the parent's is ask, else the parent's; status idle, nothing pending or awaiting, the parent's context-tokens, no outcome. The result is {parent: the parent with its reduced budget and nothing else changed, child, task}. finish(child, call): a tool result for call.id: completed(text) → {output: text, ok: true}; cancelled → {"cancelled", false}; failed(why) → {"failed: {why}", false}; no outcome → {"failed: the sub-agent did not finish", false}. refund(parent, child): the parent's budget plus the child's, field by field, saturating.
From your terminal
npm i -g https://liberas.dev/cli/liberas.tgzexport LIBERAS_URL=https://liberas.devliberas init agent-delegate --lang rustcd agent-delegate && 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-delegate: 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)97 lines›
package root:component;
world root {
import liberas:agent/types@0.1.0;
export liberas:agent/delegate@0.1.0;
}
package liberas:agent@0.1.0 {
interface types {
enum role {
system,
user,
assistant,
tool,
}
record tool-call {
id: string,
name: string,
arguments: string,
}
record message {
role: role,
content: string,
tool-call-id: option<string>,
tool-calls: option<list<tool-call>>,
extra: option<string>,
}
record budget {
tool-calls: u32,
turns: u32,
tool-bytes: u64,
}
variant decision {
allow,
deny(string),
ask,
}
record policy {
deny: list<string>,
ask: list<string>,
allow: list<string>,
fallback: decision,
}
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 tool-result {
tool-call-id: string,
output: string,
ok: bool,
}
record spawned {
parent: state,
child: state,
task: string,
}
}
interface delegate {
use types.{state, tool-call, budget, tool-result, spawned};
spawn: func(parent: state, call: tool-call, share: u32) -> result<spawned, string>;
finish: func(child: state, call: tool-call) -> tool-result;
refund: func(parent: budget, child: budget) -> budget;
}
}
Test vectors17›
[
{
"fn": "spawn",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{\"task\":\"summarize a.txt\"}"
},
"share": 50,
"parent": {
"budget": {
"turns": 7,
"tool-bytes": 1234,
"tool-calls": 10
},
"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
},
{
"role": "user",
"content": "do it",
"tool-call-id": null
},
{
"role": "system",
"content": "Second system note.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"fn": "spawn",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{\"task\":\"x\"}"
},
"share": 1,
"parent": {
"budget": {
"turns": 7,
"tool-bytes": 1234,
"tool-calls": 10
},
"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
},
{
"role": "user",
"content": "do it",
"tool-call-id": null
},
{
"role": "system",
"content": "Second system note.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"fn": "spawn",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{\"task\":\"x\"}"
},
"share": 100,
"parent": {
"budget": {
"turns": 7,
"tool-bytes": 1234,
"tool-calls": 10
},
"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
},
{
"role": "user",
"content": "do it",
"tool-call-id": null
},
{
"role": "system",
"content": "Second system note.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"fn": "spawn",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{\"task\":\"x\",\"extra\":1}"
},
"share": 33,
"parent": {
"budget": {
"turns": 7,
"tool-bytes": 1234,
"tool-calls": 10
},
"policy": {
"ask": [],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "deny",
"val": "closed"
}
},
"status": "idle",
"outcome": null,
"pending": [],
"awaiting": [],
"messages": [
{
"role": "user",
"content": "no system",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"fn": "spawn",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{\"task\":\"x\"}"
},
"share": 99,
"parent": {
"budget": {
"turns": 0,
"tool-bytes": 99,
"tool-calls": 0
},
"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
},
{
"role": "user",
"content": "do it",
"tool-call-id": null
},
{
"role": "system",
"content": "Second system note.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"fn": "spawn",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{\"task\":\"x\"}"
},
"share": 0,
"parent": {
"budget": {
"turns": 7,
"tool-bytes": 1234,
"tool-calls": 10
},
"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
},
{
"role": "user",
"content": "do it",
"tool-call-id": null
},
{
"role": "system",
"content": "Second system note.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"fn": "spawn",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{\"task\":\"x\"}"
},
"share": 101,
"parent": {
"budget": {
"turns": 7,
"tool-bytes": 1234,
"tool-calls": 10
},
"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
},
{
"role": "user",
"content": "do it",
"tool-call-id": null
},
{
"role": "system",
"content": "Second system note.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"fn": "spawn",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{nope"
},
"share": 50,
"parent": {
"budget": {
"turns": 7,
"tool-bytes": 1234,
"tool-calls": 10
},
"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
},
{
"role": "user",
"content": "do it",
"tool-call-id": null
},
{
"role": "system",
"content": "Second system note.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"fn": "spawn",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{\"task\":5}"
},
"share": 50,
"parent": {
"budget": {
"turns": 7,
"tool-bytes": 1234,
"tool-calls": 10
},
"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
},
{
"role": "user",
"content": "do it",
"tool-call-id": null
},
{
"role": "system",
"content": "Second system note.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"fn": "spawn",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{\"job\":\"x\"}"
},
"share": 50,
"parent": {
"budget": {
"turns": 7,
"tool-bytes": 1234,
"tool-calls": 10
},
"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
},
{
"role": "user",
"content": "do it",
"tool-call-id": null
},
{
"role": "system",
"content": "Second system note.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"fn": "finish",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{}"
},
"child": {
"budget": {
"turns": 3,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "finished",
"outcome": {
"tag": "completed",
"val": "a.txt says hi"
},
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"fn": "finish",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{}"
},
"child": {
"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
}
}
},
{
"fn": "finish",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{}"
},
"child": {
"budget": {
"turns": 3,
"tool-bytes": 400,
"tool-calls": 4
},
"policy": {
"ask": [
"write*"
],
"deny": [
"shell*"
],
"allow": [
"read*"
],
"fallback": {
"tag": "ask"
}
},
"status": "finished",
"outcome": {
"tag": "failed",
"val": "budget: turns: 1 asked, 0 left"
},
"pending": [],
"awaiting": [],
"messages": [
{
"role": "system",
"content": "You are a careful assistant.",
"tool-call-id": null
}
],
"context-tokens": 200
}
}
},
{
"fn": "finish",
"args": {
"call": {
"id": "d1",
"name": "delegate",
"arguments": "{}"
},
"child": {
"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
}
}
},
{
"fn": "refund",
"args": {
"child": {
"turns": 1,
"tool-bytes": 34,
"tool-calls": 2
},
"parent": {
"turns": 3,
"tool-bytes": 600,
"tool-calls": 5
}
}
},
{
"fn": "refund",
"args": {
"child": {
"turns": 0,
"tool-bytes": "18446744073709551615",
"tool-calls": 1
},
"parent": {
"turns": 0,
"tool-bytes": 1,
"tool-calls": 4294967295
}
}
},
{
"fn": "refund",
"args": {
"child": {
"turns": 0,
"tool-bytes": 0,
"tool-calls": 0
},
"parent": {
"turns": 0,
"tool-bytes": 0,
"tool-calls": 0
}
}
}
]Versions (units)1›
- v1by davef0da82497cstable 5.1.0latestconfirmed10/24/2026
Verification7›
- Outputs must match the private reference implementation bit for bit.
- Cases are the spec's 17 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.
- Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
- A remote call may execute up to 200,000,000 instructions.
- 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%.