Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
agent / agent-anthropic-request-2Built by davevia claude-codeRuns on Liberasnew version of agent-anthropic-request

Anthropic Messages API: request body, with provider turns

A new version of agent-anthropic-request (it supersedes it): exactly its rules, except that an assistant message with extra becomes {role: assistant, content: extra parsed as JSON}, whatever its content and tool calls (ADR 0064): the provider's own turn, reasoning blocks and signatures included, replayed unchanged. extra that is not JSON is the error "message {i}: extra is not JSON", checked where that message's other errors would be.

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init agent-anthropic-request-2 --lang rust
cd agent-anthropic-request-2 && 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)50 lines›
agent-anthropic-request-2.wit
package root:component;

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

  export liberas:agent/wire-request-body@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 tool-def {
      name: string,
      description: string,
      input-schema: string,
    }

    record wire-request {
      model: string,
      max-tokens: u32,
      messages: list<message>,
      tools: list<tool-def>,
    }
  }
  interface wire-request-body {
    use types.{wire-request};

    body: func(request: wire-request) -> result<string, string>;
  }
}
Test vectors17›
agent-anthropic-request-2.cases.json
[
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [],
        "messages": [
          {
            "role": "user",
            "content": "hi",
            "tool-call-id": null
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [
          {
            "name": "read-file",
            "description": "Reads a file.",
            "input-schema": "{\"type\":\"object\",\"properties\":{\"path\":{\"type\":\"string\"}},\"required\":[\"path\"],\"additionalProperties\":false}"
          }
        ],
        "messages": [
          {
            "role": "system",
            "content": "Be brief.",
            "tool-call-id": null
          },
          {
            "role": "user",
            "content": "hi",
            "tool-call-id": null
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [
          {
            "name": "read-file",
            "description": "Reads a file.",
            "input-schema": "{\"type\":\"object\",\"properties\":{\"path\":{\"type\":\"string\"}},\"required\":[\"path\"],\"additionalProperties\":false}"
          },
          {
            "name": "write-file",
            "description": "Writes a file.",
            "input-schema": "{\"type\":\"object\",\"properties\":{\"path\":{\"type\":\"string\"},\"text\":{\"type\":\"string\"}},\"required\":[\"path\",\"text\"],\"additionalProperties\":false}"
          }
        ],
        "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"
          },
          {
            "role": "assistant",
            "extra": null,
            "content": "a says alpha; b is missing.",
            "tool-calls": [],
            "tool-call-id": null
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [],
        "messages": [
          {
            "role": "system",
            "content": "one",
            "tool-call-id": null
          },
          {
            "role": "user",
            "content": "hi",
            "tool-call-id": null
          },
          {
            "role": "system",
            "content": "two",
            "tool-call-id": null
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [],
        "messages": [
          {
            "role": "user",
            "content": "hi",
            "tool-call-id": null
          },
          {
            "role": "assistant",
            "extra": null,
            "content": "",
            "tool-calls": [
              {
                "id": "c1",
                "name": "read-file",
                "arguments": "{}"
              }
            ],
            "tool-call-id": null
          },
          {
            "role": "tool",
            "content": "",
            "tool-call-id": "c1"
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [],
        "messages": [
          {
            "role": "user",
            "content": "hi",
            "tool-call-id": null
          },
          {
            "role": "assistant",
            "extra": null,
            "content": "",
            "tool-calls": [],
            "tool-call-id": null
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [],
        "messages": [
          {
            "role": "user",
            "content": "hi",
            "tool-call-id": null
          },
          {
            "role": "assistant",
            "extra": null,
            "content": "ok",
            "tool-calls": null,
            "tool-call-id": null
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [],
        "messages": [
          {
            "role": "user",
            "content": "hi",
            "tool-call-id": null
          },
          {
            "role": "tool",
            "content": "x",
            "tool-call-id": null
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [],
        "messages": [
          {
            "role": "user",
            "content": "hi",
            "tool-call-id": null
          },
          {
            "role": "assistant",
            "extra": null,
            "content": "",
            "tool-calls": [
              {
                "id": "c1",
                "name": "read-file",
                "arguments": "{not json"
              }
            ],
            "tool-call-id": null
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [
          {
            "name": "t",
            "description": "d",
            "input-schema": "{oops"
          }
        ],
        "messages": [
          {
            "role": "user",
            "content": "hi",
            "tool-call-id": null
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-haiku-5-5",
        "tools": [],
        "messages": [
          {
            "role": "user",
            "content": "안녕 \"quoted\" \\ back",
            "tool-call-id": null
          },
          {
            "role": "assistant",
            "extra": null,
            "content": "답",
            "tool-calls": [
              {
                "id": "c1",
                "name": "f",
                "arguments": "{\"n\":1.5,\"s\":\"é\",\"l\":[null,true]}"
              }
            ],
            "tool-call-id": null
          },
          {
            "role": "tool",
            "content": "r",
            "tool-call-id": "c1"
          },
          {
            "role": "user",
            "content": "next",
            "tool-call-id": null
          }
        ],
        "max-tokens": 0
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [],
        "messages": [
          {
            "role": "tool",
            "content": "a",
            "tool-call-id": "c1"
          },
          {
            "role": "tool",
            "content": "b",
            "tool-call-id": "c2"
          },
          {
            "role": "user",
            "content": "u",
            "tool-call-id": null
          },
          {
            "role": "tool",
            "content": "c",
            "tool-call-id": "c3"
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [
          {
            "name": "read-file",
            "description": "Reads a file.",
            "input-schema": "{\"type\":\"object\",\"properties\":{\"path\":{\"type\":\"string\"}},\"required\":[\"path\"],\"additionalProperties\":false}"
          }
        ],
        "messages": [
          {
            "role": "system",
            "content": "sys",
            "tool-call-id": null
          },
          {
            "role": "user",
            "content": "read a",
            "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"
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [],
        "messages": [
          {
            "role": "user",
            "content": "hi",
            "tool-call-id": null
          },
          {
            "role": "assistant",
            "extra": "[]",
            "content": "",
            "tool-calls": [],
            "tool-call-id": null
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [],
        "messages": [
          {
            "role": "user",
            "content": "hi",
            "tool-call-id": null
          },
          {
            "role": "assistant",
            "extra": "[{\"type\":\"text\",\"text\":\"kept\"}]",
            "content": "ignored",
            "tool-calls": [
              {
                "id": "x",
                "name": "y",
                "arguments": "{}"
              }
            ],
            "tool-call-id": null
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [],
        "messages": [
          {
            "role": "user",
            "content": "hi",
            "tool-call-id": null
          },
          {
            "role": "assistant",
            "extra": "{not json",
            "content": "",
            "tool-calls": [],
            "tool-call-id": null
          }
        ],
        "max-tokens": 16000
      }
    }
  },
  {
    "args": {
      "request": {
        "model": "claude-opus-5-5",
        "tools": [],
        "messages": [
          {
            "role": "user",
            "content": "hi",
            "tool-call-id": null
          },
          {
            "role": "tool",
            "content": "x",
            "tool-call-id": null
          },
          {
            "role": "assistant",
            "extra": "{not json",
            "content": "",
            "tool-calls": [],
            "tool-call-id": null
          }
        ],
        "max-tokens": 16000
      }
    }
  }
]
Versions (units)1›
  1. v1by dave487c8bd959stable 5.1.0latestconfirmed10/23/2026
Verification9›
  • 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.
  • Outputs are judged by agent-json-equal's reference instead of bit equality: a produced value passes when it accepts it next to the reference's (a lossy encoder, an approximate numeric).
  • A remote call may execute up to 200,000,000 instructions.
  • A new version of agent-anthropic-request: its reference answers every case of agent-anthropic-request as it does. Once this and everything it imports are built, it runs in place of agent-anthropic-request, 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%.