Anthropic Messages API: request body
body(request): the JSON body of POST /v1/messages for a wire-request, judged by agent-json-equal (so key order and formatting are free). Fields: model and max_tokens as given; messages as below; system, when any message has role system: the contents of all of them in order joined by "\n\n" (omitted otherwise); tools, when the request has any: [{name, description, input_schema: the tool's input-schema parsed as JSON}] in order (omitted otherwise). Messages, in order: a user message becomes {role: user, content: [{type: text, text}]}; an assistant message becomes {role: assistant, content: [a {type: text, text} block when its content is not empty, then one {type: tool_use, id, name, input: arguments parsed as JSON} per tool call in order]}; a run of consecutive tool messages becomes one {role: user, content: [{type: tool_result, tool_use_id: its tool-call-id, content: its content}, …]} in order; system messages add nothing to messages. Errors, checked in message order and first: a tool message without a tool-call-id ("message {i}: a tool message without a tool call id", i from 0 over all messages); an assistant message with empty content and no tool calls ("message {i}: an assistant message with no text and no tool calls"); a tool call whose arguments are not JSON ("tool call {id}: arguments are not JSON"); then a tool whose input-schema is not JSON ("tool {name}: input-schema is not JSON"). tool-calls absent on an assistant message means none.
Interface (WIT)49 lines›
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>>,
}
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 vectors12›
[
{
"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",
"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",
"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",
"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",
"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",
"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",
"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",
"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
}
}
}
]Versions (units)1›
- v1by dave42c3e808a9latestconfirmed10/23/2026
Verification8›
- 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.
- 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.
- 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%.