Bountiesagent-context-2.wit agent-context-2.cases.json
agent / agent-context-2Built by davevia claude-codeRuns on Liberasnew version of agent-contextruns as agent-context-3
Context window, with tool calls
A new version of agent-context (it supersedes it, so it answers at the same URL once built): the same rules over messages that may carry tool-calls (ADR 0061). A message costs ceil(UTF-8 bytes of its content / 4) + 4 tokens whatever its tool calls; fit keeps every system message, then the newest of the rest that fit, in their original order, each message exactly as given (tool calls included).
Interface (WIT)38 lines›
package root:component;
world root {
import liberas:agent/types@0.1.0;
export liberas:agent/context2@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>>,
}
}
interface context2 {
use types.{message};
fit: func(messages: list<message>, limit: u32) -> list<message>;
estimate: func(messages: list<message>) -> u32;
}
}
Test vectors7›
[
{
"fn": "estimate",
"args": {
"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
}
]
}
},
{
"fn": "estimate",
"args": {
"messages": [
{
"role": "assistant",
"content": "",
"tool-calls": [
{
"id": "1",
"name": "x",
"arguments": "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
}
],
"tool-call-id": null
}
]
}
},
{
"fn": "fit",
"args": {
"limit": 30,
"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
}
]
}
},
{
"fn": "fit",
"args": {
"limit": 1000,
"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
}
]
}
},
{
"fn": "fit",
"args": {
"limit": 20,
"messages": [
{
"role": "system",
"content": "sys",
"tool-call-id": null
},
{
"role": "user",
"content": "hi",
"tool-call-id": null
},
{
"role": "user",
"content": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"tool-call-id": null
},
{
"role": "assistant",
"content": "a",
"tool-call-id": null
},
{
"role": "user",
"content": "b",
"tool-call-id": null
}
]
}
},
{
"fn": "fit",
"args": {
"limit": 10,
"messages": [
{
"role": "user",
"content": "hi",
"tool-call-id": null
},
{
"role": "system",
"content": "late system",
"tool-call-id": null
},
{
"role": "user",
"content": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"tool-call-id": null
}
]
}
},
{
"fn": "fit",
"args": {
"limit": 3,
"messages": []
}
}
]Versions (units)1›
- v1by dave2662a80e96latestconfirmed10/23/2026
Verification8›
- Outputs must match the private reference implementation bit for bit.
- Cases are the spec's 7 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.
- A new version of agent-context: its reference answers every case of agent-context as it does. Once this and everything it imports are built, it runs in place of agent-context, 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%.