Files
leleka/docs/api-contract.md
T

2.5 KiB

Responses contract status

The Rust control plane has a POST /v1/responses route and a reusable response trace builder. The route parses a subset of Responses requests and returns OpenAI-shaped JSON errors. It returns 503 worker_not_ready until the engine handshake completes. With a configured native tokenizer it can execute a narrow, non-streaming text preview with reasoning.effort: "none", string input, and no tools or structured output. Unsupported live features return 501 unsupported_live_feature; a ready worker without tokenizer returns 501 inference_adapter_missing. This preview has a synthetic worker test, not a real-model quality result.

The offline trace builder accepts text fragments, function-call argument fragments, and token usage. It assembles a non-streaming response or an ordered SSE stream ending in response.completed. Tool arguments must form a JSON object. text.format supports text, json_object, and json_schema validation in the offline builder. External schema references are rejected. The synthetic fixture at benchmarks/fixtures/responses/structured-tool.json demonstrates text plus a tool call; it is not evidence of live Codex compatibility.

control-plane/src/wire.rs encodes the upstream GEN request line and parses the current T, PP, DONE, and ERR output lines. The supervisor accepts an internal token-ID generation command, checks its context budget, sends it to a resident worker, and collects output through DONE. Native Qwen prompt assembly matches eight pinned upstream golden cases byte-for-byte; the tokenizer and worker queue are connected to the restricted HTTP preview. The current command collects a whole result; HTTP cancellation and incremental streaming remain to be implemented.

Current request parsing supports model, string or array input, stream, instructions, max_output_tokens, previous_response_id, parallel_tool_calls, reasoning, text, named function tools, tool_choice, temperature, top_p, truncation, metadata, and store: false. Unknown fields and store: true are rejected. Parsing support does not imply execution support. The body limit is 16 MiB.

Before switching the testing runtime, map all engine stop conditions and tool calls; return live SSE incrementally with backpressure and cancellation; test the real tokenizer and model on Linux GPU; and compare sanitized real Codex replays against the upstream Python server. Do not mark Gate A complete based on synthetic fixtures.