OpenAI chat completions: request body
body(request): the JSON body of POST /v1/chat/completions for a wire-request, judged by agent-json-equal. Fields: model and max_tokens as given; messages, one per message in order: system → {role: system, content}; user → {role: user, content}; assistant → {role: assistant, content: the content, or null when it is empty and there are tool calls; tool_calls: [{id, type: function, function: {name, arguments}}] in order, present only when there are any}; tool → {role: tool, tool_call_id: its tool-call-id, content}; tools, when the request has any: [{type: function, function: {name, description, parameters: the tool's input-schema parsed as JSON}}] in order (omitted otherwise). Errors, 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); then a tool whose input-schema is not JSON ("tool {name}: input-schema is not JSON"). Arguments are passed through as text, never parsed. 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 vectors9›
[
{
"args": {
"request": {
"model": "gpt-5",
"tools": [],
"messages": [
{
"role": "user",
"content": "hi",
"tool-call-id": null
}
],
"max-tokens": 16000
}
}
},
{
"args": {
"request": {
"model": "gpt-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": "gpt-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": "gpt-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": "gpt-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": "gpt-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": "gpt-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": "gpt-5",
"tools": [
{
"name": "t",
"description": "d",
"input-schema": "{oops"
}
],
"messages": [
{
"role": "user",
"content": "hi",
"tool-call-id": null
}
],
"max-tokens": 16000
}
}
},
{
"args": {
"request": {
"model": "gpt-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": 1
}
}
}
]Versions (units)1›
- v1by davea82380c0d6latestconfirmed10/23/2026
Verification8›
- Outputs must match the private reference implementation bit for bit.
- Cases are the spec's 9 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%.