Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
agent / agent-budgetBuilt by davevia claude-codeRuns on Liberas

Budget

All or nothing. charge(current, calls): let count be the number of calls and bytes the sum of the UTF-8 length of their arguments; if count > current.tool-calls the error is "tool calls: {count} asked, {left} left", else if bytes > current.tool-bytes it is "tool bytes: {bytes} asked, {left} left" (checked in that order, nothing is charged), else the result is current with tool-calls − count and tool-bytes − bytes, turns unchanged. turn(current): "turns: 1 asked, 0 left" when turns is 0, else current with turns − 1.

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init agent-budget --lang rust
cd agent-budget && 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).

Interface (WIT)30 lines›
agent-budget.wit
package root:component;

world root {
  import liberas:agent/types@0.1.0;

  export liberas:agent/budget@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,
    }
  }
  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>;
  }
}
Test vectors12›
agent-budget.cases.json
[
  {
    "fn": "charge",
    "args": {
      "calls": [
        {
          "id": "a",
          "name": "read",
          "arguments": "{\"path\":\"a\"}"
        }
      ],
      "current": {
        "turns": 2,
        "tool-bytes": 100,
        "tool-calls": 3
      }
    }
  },
  {
    "fn": "charge",
    "args": {
      "calls": [
        {
          "id": "a",
          "name": "read",
          "arguments": "{}"
        },
        {
          "id": "b",
          "name": "read",
          "arguments": "{}"
        },
        {
          "id": "c",
          "name": "read",
          "arguments": "{}"
        }
      ],
      "current": {
        "turns": 2,
        "tool-bytes": 100,
        "tool-calls": 3
      }
    }
  },
  {
    "fn": "charge",
    "args": {
      "calls": [
        {
          "id": "a",
          "name": "read",
          "arguments": "{}"
        },
        {
          "id": "b",
          "name": "read",
          "arguments": "{}"
        },
        {
          "id": "c",
          "name": "read",
          "arguments": "{}"
        }
      ],
      "current": {
        "turns": 2,
        "tool-bytes": 100,
        "tool-calls": 2
      }
    }
  },
  {
    "fn": "charge",
    "args": {
      "calls": [
        {
          "id": "a",
          "name": "read",
          "arguments": "{\"path\":\"abcdefgh\"}"
        }
      ],
      "current": {
        "turns": 2,
        "tool-bytes": 10,
        "tool-calls": 3
      }
    }
  },
  {
    "fn": "charge",
    "args": {
      "calls": [
        {
          "id": "a",
          "name": "read",
          "arguments": "12345"
        },
        {
          "id": "b",
          "name": "read",
          "arguments": "12345"
        }
      ],
      "current": {
        "turns": 2,
        "tool-bytes": 10,
        "tool-calls": 3
      }
    }
  },
  {
    "fn": "charge",
    "args": {
      "calls": [
        {
          "id": "a",
          "name": "read",
          "arguments": "12345"
        },
        {
          "id": "b",
          "name": "read",
          "arguments": "123456"
        }
      ],
      "current": {
        "turns": 2,
        "tool-bytes": 10,
        "tool-calls": 3
      }
    }
  },
  {
    "fn": "charge",
    "args": {
      "calls": [],
      "current": {
        "turns": 2,
        "tool-bytes": 100,
        "tool-calls": 0
      }
    }
  },
  {
    "fn": "charge",
    "args": {
      "calls": [
        {
          "id": "a",
          "name": "read",
          "arguments": "한"
        }
      ],
      "current": {
        "turns": 0,
        "tool-bytes": 3,
        "tool-calls": 1
      }
    }
  },
  {
    "fn": "charge",
    "args": {
      "calls": [
        {
          "id": "a",
          "name": "read",
          "arguments": "한"
        }
      ],
      "current": {
        "turns": 0,
        "tool-bytes": 2,
        "tool-calls": 1
      }
    }
  },
  {
    "fn": "turn",
    "args": {
      "current": {
        "turns": 1,
        "tool-bytes": 1,
        "tool-calls": 1
      }
    }
  },
  {
    "fn": "turn",
    "args": {
      "current": {
        "turns": 0,
        "tool-bytes": 1,
        "tool-calls": 1
      }
    }
  },
  {
    "fn": "turn",
    "args": {
      "current": {
        "turns": 7,
        "tool-bytes": 0,
        "tool-calls": 0
      }
    }
  }
]
Versions (units)1›
  1. v1by davea55fc9b988stable 5.1.0latestconfirmed10/23/2026
Verification7›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 12 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 100,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%.