# 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 text, function-call, reasoning and validated structured-output preview. It accepts string input or a text-only array of messages and paired function calls/results. Non-streaming and live SSE paths are connected to the resident worker; ordinary unstructured streams with effort none send text deltas and complete, schema-validated function calls before worker `DONE`. Reasoning streams send live reasoning deltas and buffer final answer/tool items; structured text is validated before publication. Unsupported live features return `501 unsupported_live_feature`; a ready worker without tokenizer returns `501 inference_adapter_missing`. Text/tool JSON and SSE, continuation, cancellation and crash recovery have passed small real-model Linux GPU checks; full recorded-agent qualification remains open. 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 both live serving and 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, and sends it to a resident worker. It can return a buffered result or stream bounded token events. Dropping the SSE receiver cancels generation. Native Qwen prompt assembly matches pinned text-only and one representative tool golden case byte-for-byte. The live Qwen parser holds split call markers and rejects incomplete calls; it validates full argument objects before publishing function-call events. 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`. Unknown fields are rejected. Terminal responses are stored by default; `store: false` disables this. `previous_response_id` replays a stored response with the new input, including function calls and matching results. The store is process-local and bounded to 64 responses or 128 MiB, whichever is reached first; old IDs become unavailable after eviction or restart. Multimodal input remains unsupported. The body limit is 16 MiB. Before switching the testing runtime, exercise all engine stop conditions and tool calls with the real tokenizer and model on Linux GPU, and compare sanitized real Codex replays against the upstream Python server. Native reasoning now has its own output items, streaming events and continuation path. Do not mark Gate A complete based on synthetic fixtures. ## Engine prefix metadata The engine's `RESUME ` and `REUSED ` lines are validated as nonnegative prefix counts and treated as nonterminal metadata. Usage counters come from `DONE`. These lines must not fail or finish a generation; unknown wire tags and malformed counts still fail the protocol. ## Cancellation failure isolation Dropping a generation receiver sends `STOP` and drains that generation's output for at most 20 seconds. Tokens or progress emitted after `STOP` are discarded and do not extend the deadline. A terminal line before the deadline permits the next queued request. If the worker does not terminate in time, readiness is revoked, the process is killed and reaped, and queued receivers are closed. The supervisor never reuses an unaligned output stream. Both text and function-call SSE relays observe the HTTP consumer closing even while the engine produces no events. They then drop their generation receiver so cancellation reaches the supervisor immediately. A sanitized shell worker that consumes `STOP` without reporting `DONE` covers this failure path. This regression does not qualify full-model soak stability. ## Worker recovery policy After a failure of a worker that previously sent `READY`, the supervisor can start a fresh process. The default lifetime budget is three restarts, with delays of 2, 4 and 8 seconds. Set `engine.max_restarts` in the JSON config or `STRATA_MAX_WORKER_RESTARTS` to an integer from 0 through 3; zero disables recovery. Environment overrides the file. Successful requests do not replenish the lifetime budget. Initial or replacement startup failure stops recovery. An active failed generation is not retried. Queued commands are failed during recovery; requests arriving while restarting or starting are rejected. The worker reports `restarting` during backoff, then `starting`, with no context or readiness until a new positive `READY` handshake. Shutdown interrupts backoff. After the lifetime budget is exhausted, the runtime must be restarted by its operator. A real-model reload has passed; sustained soak remains open. ## Live structured text Requests may select `text.format.type` as `json_object` or `json_schema`. The runtime adds JSON-format instructions and, for schemas, the schema itself to the model prompt. Invalid schemas and external references are rejected before worker admission. Completed text must parse as an object and, in schema mode, pass the supplied schema. The same validation applies with `strict` true, false, or omitted. This implementation uses prompt guidance and final validation; it does not yet constrain next-token sampling with a JSON grammar and cannot guarantee successful generation for every schema. JSON requests return HTTP 502 if completed model output fails validation. Structured SSE sends `response.created` / `response.in_progress` immediately, then buffers output until engine DONE. Valid output is emitted with the normal item/text/terminal events. Invalid completed output emits `response.failed` without publishing text or function-call items. This buffering trades token-by- token structured output for validation before publication. Plain text streaming is unchanged. Disconnect still cancels the active generation while buffering. A token-budget stop returns `response.incomplete` with `incomplete_details.reason: "max_output_tokens"`; its partial text may be invalid JSON and must not be treated as a schema-valid completed result. Tool-only turns remain valid: their arguments are checked against the tool schema, while the text format applies to the eventual answer after tool results. History stores successful and incomplete responses, never schema-failed responses. Example format: ```json {"text":{"format":{"type":"json_schema","name":"answer","strict":true,"schema":{"type":"object","properties":{"answer":{"type":"integer"}},"required":["answer"],"additionalProperties":false}}}} ``` The field names and incomplete-result handling follow the [OpenAI structured output contract](https://developers.openai.com/api/docs/guides/structured-outputs). Recorded Codex/MCP replay remains a separate milestone. ## Native Qwen reasoning `reasoning.effort` accepts `none`, `low`, `medium`, `high`, or `xhigh`. Omitted/null effort uses upstream's `xhigh` default. The pinned model template maps `high` to its xhigh instruction; `none` closes the thinking block in the prompt. Effort is a template instruction, not a separate token budget. `max_output_tokens` includes both reasoning and answer tokens. Generated reasoning is returned as an output item with `type: "reasoning"`, `content: [{"type":"reasoning_text","text":"..."}]` and `summary: []`. SSE emits `response.reasoning_text.delta` during generation, followed by its text/content/item done events and the normal answer or function-call events. The current reasoning path buffers the final answer/tool items until DONE; structured answers are validated before publication. `effort: none` plain-text and tool streaming retain their incremental behavior. Disconnect during reasoning cancels the worker generation. The first Qwen `` marker separates reasoning from answer text, even when split over tokens. A normal stop without that marker fails; a token-budget stop while thinking returns an incomplete reasoning item and no invented final answer. `usage.output_tokens_details.reasoning_tokens` counts original emitted tokens up to and including the closing-marker token; if one token straddles the boundary it is assigned to reasoning. Truncated thinking counts all its tokens. EOS tokens remain in total output usage, not reasoning usage. Stored continuation and stateless replay preserve raw reasoning alongside assistant messages/tool calls in the Qwen template. Reasoning-only incomplete turns can precede a new user message. Summary-only and encrypted reasoning cannot reconstruct this local model's raw context and are rejected explicitly. `reasoning.summary: "auto"` or null is accepted, but no summarizer is implemented: summary remains empty, and raw text is never mislabeled as a summary. Explicit `concise`/`detailed` summaries are unsupported. The reasoning content and event shapes follow the [Responses raw-reasoning extension](https://developers.openai.com/cookbook/articles/gpt-oss/handle-raw-cot). This local Qwen implementation does not provide OpenAI encrypted reasoning.