Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
agent / agent-openai-deltaBuilt by davevia claude-codeRuns on Liberas

OpenAI chat completions: text as it streams

delta(event): some(choices[0].delta.content) when the event's data is JSON, choices is a non-empty array and that content is a string; none otherwise, including for data that is not JSON or is [DONE]. What a host shows as the stream arrives (ADR 0065).

From your terminal

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

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

  export liberas:agent/streaming-text@0.1.0;
}
package liberas:agent@0.1.0 {
  interface types {
    record sse-event {
      event: string,
      data: string,
    }
  }
  interface streaming-text {
    use types.{sse-event};

    delta: func(event: sse-event) -> option<string>;
  }
}
Test vectors10›
agent-openai-delta.cases.json
[
  {
    "args": {
      "event": {
        "data": "{\"id\":\"chatcmpl-1\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"gpt-5\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"finish_reason\":null}]}",
        "event": "message"
      }
    }
  },
  {
    "args": {
      "event": {
        "data": "{\"id\":\"chatcmpl-1\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"gpt-5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"On \"},\"finish_reason\":null}]}",
        "event": "message"
      }
    }
  },
  {
    "args": {
      "event": {
        "data": "{\"id\":\"chatcmpl-1\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"gpt-5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"it.\"},\"finish_reason\":null}]}",
        "event": "message"
      }
    }
  },
  {
    "args": {
      "event": {
        "data": "{\"id\":\"chatcmpl-1\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"id\":\"call_1\",\"type\":\"function\",\"function\":{\"name\":\"read-file\",\"arguments\":\"\"}}]},\"finish_reason\":null}]}",
        "event": "message"
      }
    }
  },
  {
    "args": {
      "event": {
        "data": "{\"id\":\"chatcmpl-1\",\"choices\":[],\"usage\":{\"prompt_tokens\":10,\"completion_tokens\":20,\"total_tokens\":30}}",
        "event": "message"
      }
    }
  },
  {
    "args": {
      "event": {
        "data": "[DONE]",
        "event": "message"
      }
    }
  },
  {
    "args": {
      "event": {
        "data": "{broken",
        "event": "message"
      }
    }
  },
  {
    "args": {
      "event": {
        "data": "{\"choices\":[{\"index\":0,\"delta\":{\"content\":null}}]}",
        "event": "message"
      }
    }
  },
  {
    "args": {
      "event": {
        "data": "{\"choices\":[{\"index\":0,\"delta\":{\"content\":\"é 한글\"}}]}",
        "event": "message"
      }
    }
  },
  {
    "args": {
      "event": {
        "data": "{\"choices\":[{\"index\":0,\"delta\":{\"content\":\"\"}}]}",
        "event": "message"
      }
    }
  }
]
Versions (units)1›
  1. v1by daved61907347cstable 5.1.0latestconfirmed10/24/2026
Verification7›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 10 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 100,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%.