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

OpenAI chat completions: response, with provider turns

A new version of agent-openai-response (it supersedes it): exactly its rules, and the result's extra is some(the first choice's message object as compact JSON, object keys in ascending byte order of their UTF-8 at every level) (ADR 0064).

From your terminal

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

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

  export liberas:agent/wire-response@0.1.0;
}
package liberas:agent@0.1.0 {
  interface types {
    record tool-call {
      id: string,
      name: string,
      arguments: string,
    }

    record model-output {
      text: string,
      tool-calls: list<tool-call>,
      extra: option<string>,
    }
  }
  interface wire-response {
    use types.{model-output};

    parse: func(body: string) -> result<model-output, string>;
  }
}
Test vectors17›
agent-openai-response-2.cases.json
[
  {
    "args": {
      "body": "{\"id\":\"chatcmpl-1\",\"choices\":[{\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":\"Hello.\"},\"finish_reason\":\"stop\"}]}"
    }
  },
  {
    "args": {
      "body": "{\"choices\":[{\"message\":{\"role\":\"assistant\",\"content\":null,\"tool_calls\":[{\"id\":\"call_1\",\"type\":\"function\",\"function\":{\"name\":\"read-file\",\"arguments\":\"{\\\"path\\\": \\\"a\\\"}\"}},{\"id\":\"call_2\",\"type\":\"function\",\"function\":{\"name\":\"f\",\"arguments\":\"{}\"}}]}}]}"
    }
  },
  {
    "args": {
      "body": "{\"choices\":[{\"message\":{\"role\":\"assistant\",\"content\":\"with text\",\"tool_calls\":[{\"id\":\"call_1\",\"type\":\"function\",\"function\":{\"name\":\"f\",\"arguments\":\"{}\"}}]}}]}"
    }
  },
  {
    "args": {
      "body": "{\"error\":{\"message\":\"Rate limit reached\",\"type\":\"rate_limit_error\"}}"
    }
  },
  {
    "args": {
      "body": "{\"error\":\"a string\"}"
    }
  },
  {
    "args": {
      "body": "nope"
    }
  },
  {
    "args": {
      "body": "{\"choices\":[]}"
    }
  },
  {
    "args": {
      "body": "{\"choices\":[{\"message\":{\"content\":5}}]}"
    }
  },
  {
    "args": {
      "body": "{\"choices\":[{\"message\":{\"content\":\"\",\"tool_calls\":[{\"id\":\"c\",\"function\":{\"name\":\"f\"}}]}}]}"
    }
  },
  {
    "args": {
      "body": "{\"choices\":[{\"message\":{\"content\":\"\",\"tool_calls\":[{\"function\":{\"name\":\"f\",\"arguments\":\"{}\"}}]}}]}"
    }
  },
  {
    "args": {
      "body": "{\"choices\":[{\"message\":{}}]}"
    }
  },
  {
    "args": {
      "body": "{\"choices\":[{\"message\":{\"content\":\"first\"}},{\"message\":{\"content\":\"second\"}}]}"
    }
  },
  {
    "args": {
      "body": "{\"choices\":[{\"message\":{\"content\":\"\",\"tool_calls\":[]}}]}"
    }
  },
  {
    "args": {
      "body": "{\"choices\":[{\"message\":{\"content\":\"é 한글\",\"tool_calls\":[{\"id\":\"a\",\"type\":\"function\",\"function\":{\"name\":\"f\",\"arguments\":\"not json but passed through\"}}]}}]}"
    }
  },
  {
    "args": {
      "body": "{\"choices\":[{\"message\":{\"content\":null,\"tool_calls\":null}}]}"
    }
  },
  {
    "args": {
      "body": "{\"choices\":[{\"message\":{\"content\":\"x\",\"refusal\":null,\"tool_calls\":[{\"id\":\"a\",\"function\":{\"name\":\"f\",\"arguments\":\"{}\"}},{\"id\":\"b\",\"function\":{\"name\":\"g\",\"arguments\":\"{\\\"k\\\":[1]}\"}}]}}]}"
    }
  },
  {
    "args": {
      "body": "{\"choices\":[{\"message\":{\"role\":\"assistant\",\"content\":null,\"reasoning_content\":\"thought\",\"tool_calls\":[{\"id\":\"c1\",\"type\":\"function\",\"function\":{\"name\":\"f\",\"arguments\":\"{}\"}}]}}]}"
    }
  }
]
Versions (units)1›
  1. v1by davec604fde2d0stable 5.1.0latestconfirmed10/23/2026
Verification8›
  • 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.
  • A remote call may execute up to 200,000,000 instructions.
  • A new version of agent-openai-response: its reference answers every case of agent-openai-response as it does. Once this and everything it imports are built, it runs in place of agent-openai-response, 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%.