[PR #1032] [CLOSED] serve: add opt-in bounded Responses history and continuation #2979

Closed
opened 2026-11-04 02:04:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1032
Author: @mdwsk88
Created: 10/6/2026
Status: ❌ Closed

Base: main ← Head: codex/responses-state


📝 Commits (10+)

  • fa16567 setup: an earlier config that does not parse is skipped, not a crash; configs are written atomically (#459)
  • 749d957 setup (--backend hip): a system ROCm without the HIP development files falls back to the wheels (#446)
  • 5a30024 calibrate: the engine's arguments come from the server's engine_args; a failed tuning says why (#447)
  • 9f60d13 serve, setup: name the small split card that caps the prompt chunk; setup recommends the big card alone (#448)
  • eb8da1d /metrics: each request's speculative draft counts, and their sums in the totals (#457)
  • 6a09387 setup (--gguf-dir): GGUFs Strata cannot run are named as such, with the --family/--model to use (#444)
  • d6a91e2 docs: the Coder is weaker outside code, Chinese/CJK text included; the unpruned sizes for that (#438)
  • d8d4ad3 Merge branch 'f-135-eng' into rel-0.1.35
  • 7b600d5 Merge branch 'f-135-small' into rel-0.1.35
  • d9ab843 Engine 0.1.35: Windows AMD uses its bundled HIP runtime (#468 #461), the low-RAM resident mode on Windows 32 GB PCs (#467), fixes #460 #459 #446 #447 #457 #448 #444; setup requires it

📊 Changes

8 files changed (+579 additions, -26 deletions)

View changed files

📝 docs/AI_SETUP.md (+2 -1)
📝 docs/DETAILS.md (+39 -5)
➕ serve/response_store.py (+112 -0)
📝 serve/responses.py (+19 -10)
📝 serve/runconfig.py (+2 -0)
📝 serve/server.py (+70 -10)
➕ serve/test_response_store.py (+326 -0)
📝 serve/test_runconfig.py (+9 -0)

📄 Description

Clients written against OpenAI's Responses API continue a conversation with previous_response_id and read or
delete results by ID (responses.retrieve, responses.delete). On Strata today these requests are refused
(previous_response_id is a 400, the ID routes are 404), so such a client has to be rewritten to resend the whole
conversation. I ran into this running Strata on Windows.

This adds optional, bounded storage to the existing Responses adapter: create a response, send only the next input
with previous_response_id, then retrieve or delete the stored result.

Off by default, and off means unchanged. Without --responses-store-mib (or "responses_store_mib" in the
config), status codes and response fields are the same as on main: store is not looked at (the answer says
store: false) and previous_response_id is refused as before (test_disabled_keeps_the_stateless_behavior).

When on (--responses-store-mib 64, the config key, or the web page's Model settings):

  • previous_response_id continues a stored response through the existing generation path, including function-call
    outputs and streaming. Top-level instructions, tools and generation settings are not inherited, as in OpenAI's API.
  • GET /v1/responses/{id} and DELETE /v1/responses/{id}; other routes under it (input_items, cancel) answer
    "not supported".
  • Requests are stored unless they say store: false. Completed and incomplete responses are saved before their final
    event; failed, cancelled and in-progress ones are not.
  • Bounded: the MiB budget counts the serialized UTF-8 JSON including replay history, at most 256 records, 3,600 s
    lifetime (responses_store_ttl_s), oldest evicted first. A record that cannot fit is HTTP 413 (response.failed
    once streaming has started); a replay that alone exceeds the budget is refused before the model runs.
  • Each child stores its own history, so branching works and deleting a parent does not break its children.
  • The same API key, Host, browser-Origin and CORS checks as the other routes (a DELETE has no body, so it does not
    need the JSON content type a POST does).

The conversation cache. A continuation reads token for token the same prompt as a client that sends the whole
conversation, and the previous turn's prompt is its start
(test_a_continuation_reads_the_same_prompt_as_the_whole_history), so the cache is reused as it is for Codex.

Process memory only, lost on restart, and separate from the engine's KV cache. Builds on the stateless
implementation from #451; the inference engine is unchanged.

Measured on Windows, RX 7900 XT (HIP), Qwen3.8-Flash-Next IQ2_XS, 32K context, 4 MiB store, with the first
revision of this commit: the OpenAI SDK flow create → continue → retrieve → stream → delete → 404 passed, as did
continuing a child after its parent was deleted, and store: false. A run of this revision, with the continuation's
cached_tokens, follows.

Tests: 292 run, 0 failed, 7 skipped (environment-dependent; macOS, mock engine). 24 are new: CRUD,
continuation, the replayed prompt, branching, tool results, expiry, byte/count limits, concurrency, validation,
failures, auth/CORS, the unchanged default, the Settings key and an optional OpenAI SDK round trip (openai==3.24.0).

python -m unittest serve.test_responses serve.test_response_store serve.test_runconfig
python -m unittest serve.test_server serve.test_security serve.test_structured serve.test_lifecycle serve.test_parallel serve.test_monitor serve.test_mcp serve.test_detok serve.test_winjob serve.test_vram

This is one self-contained commit on current main. If you would rather land your own version, cherry-picking it
keeps the tests and docs together.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1032 **Author:** [@mdwsk88](https://github.com/mdwsk88) **Created:** 10/6/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `codex/responses-state` --- ### 📝 Commits (10+) - [`fa16567`](https://github.com/Niko1221/Strata/commit/fa165679f9860552ac97ebd07118bb8db286be4a) setup: an earlier config that does not parse is skipped, not a crash; configs are written atomically (#459) - [`749d957`](https://github.com/Niko1221/Strata/commit/749d957a1790b1a171dd4a01ab3e31b3882c9892) setup (--backend hip): a system ROCm without the HIP development files falls back to the wheels (#446) - [`5a30024`](https://github.com/Niko1221/Strata/commit/5a3002446dbb9dfcabb7d0bd9f113da90cc2f3c0) calibrate: the engine's arguments come from the server's engine_args; a failed tuning says why (#447) - [`9f60d13`](https://github.com/Niko1221/Strata/commit/9f60d13246e46b02b1dd0841980b4d18b0faaea7) serve, setup: name the small split card that caps the prompt chunk; setup recommends the big card alone (#448) - [`eb8da1d`](https://github.com/Niko1221/Strata/commit/eb8da1d8c26ec41e6ffb084fdf579dba7cad10bd) /metrics: each request's speculative draft counts, and their sums in the totals (#457) - [`6a09387`](https://github.com/Niko1221/Strata/commit/6a093874fe037020f49bd5cf053879ff6a133c21) setup (--gguf-dir): GGUFs Strata cannot run are named as such, with the --family/--model to use (#444) - [`d6a91e2`](https://github.com/Niko1221/Strata/commit/d6a91e2d1770d0f469d6ec15890acc7ee93e764c) docs: the Coder is weaker outside code, Chinese/CJK text included; the unpruned sizes for that (#438) - [`d8d4ad3`](https://github.com/Niko1221/Strata/commit/d8d4ad337d3c98ba21d3bd0af1a16e9177e112b6) Merge branch 'f-135-eng' into rel-0.1.35 - [`7b600d5`](https://github.com/Niko1221/Strata/commit/7b600d55ff801caaaa11542af1523050992e049b) Merge branch 'f-135-small' into rel-0.1.35 - [`d9ab843`](https://github.com/Niko1221/Strata/commit/d9ab8435f654c368c586340d490915f6addf56a3) Engine 0.1.35: Windows AMD uses its bundled HIP runtime (#468 #461), the low-RAM resident mode on Windows 32 GB PCs (#467), fixes #460 #459 #446 #447 #457 #448 #444; setup requires it ### 📊 Changes **8 files changed** (+579 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `docs/AI_SETUP.md` (+2 -1) 📝 `docs/DETAILS.md` (+39 -5) ➕ `serve/response_store.py` (+112 -0) 📝 `serve/responses.py` (+19 -10) 📝 `serve/runconfig.py` (+2 -0) 📝 `serve/server.py` (+70 -10) ➕ `serve/test_response_store.py` (+326 -0) 📝 `serve/test_runconfig.py` (+9 -0) </details> ### 📄 Description Clients written against OpenAI's Responses API continue a conversation with `previous_response_id` and read or delete results by ID (`responses.retrieve`, `responses.delete`). On Strata today these requests are refused (`previous_response_id` is a 400, the ID routes are 404), so such a client has to be rewritten to resend the whole conversation. I ran into this running Strata on Windows. This adds optional, bounded storage to the existing Responses adapter: create a response, send only the next input with `previous_response_id`, then retrieve or delete the stored result. **Off by default, and off means unchanged.** Without `--responses-store-mib` (or `"responses_store_mib"` in the config), status codes and response fields are the same as on main: `store` is not looked at (the answer says `store: false`) and `previous_response_id` is refused as before (`test_disabled_keeps_the_stateless_behavior`). **When on** (`--responses-store-mib 64`, the config key, or the web page's Model settings): - `previous_response_id` continues a stored response through the existing generation path, including function-call outputs and streaming. Top-level `instructions`, tools and generation settings are not inherited, as in OpenAI's API. - `GET /v1/responses/{id}` and `DELETE /v1/responses/{id}`; other routes under it (`input_items`, `cancel`) answer "not supported". - Requests are stored unless they say `store: false`. Completed and incomplete responses are saved before their final event; failed, cancelled and in-progress ones are not. - Bounded: the MiB budget counts the serialized UTF-8 JSON including replay history, at most 256 records, 3,600 s lifetime (`responses_store_ttl_s`), oldest evicted first. A record that cannot fit is HTTP 413 (`response.failed` once streaming has started); a replay that alone exceeds the budget is refused before the model runs. - Each child stores its own history, so branching works and deleting a parent does not break its children. - The same API key, Host, browser-Origin and CORS checks as the other routes (a DELETE has no body, so it does not need the JSON content type a POST does). **The conversation cache.** A continuation reads token for token the same prompt as a client that sends the whole conversation, and the previous turn's prompt is its start (`test_a_continuation_reads_the_same_prompt_as_the_whole_history`), so the cache is reused as it is for Codex. Process memory only, lost on restart, and separate from the engine's KV cache. Builds on the stateless implementation from #451; the inference engine is unchanged. **Measured** on Windows, RX 7900 XT (HIP), Qwen3.8-Flash-Next IQ2_XS, 32K context, 4 MiB store, with the first revision of this commit: the OpenAI SDK flow create → continue → retrieve → stream → delete → 404 passed, as did continuing a child after its parent was deleted, and `store: false`. A run of this revision, with the continuation's `cached_tokens`, follows. **Tests:** 292 run, 0 failed, 7 skipped (environment-dependent; macOS, mock engine). 24 are new: CRUD, continuation, the replayed prompt, branching, tool results, expiry, byte/count limits, concurrency, validation, failures, auth/CORS, the unchanged default, the Settings key and an optional OpenAI SDK round trip (`openai==3.24.0`). python -m unittest serve.test_responses serve.test_response_store serve.test_runconfig python -m unittest serve.test_server serve.test_security serve.test_structured serve.test_lifecycle serve.test_parallel serve.test_monitor serve.test_mcp serve.test_detok serve.test_winjob serve.test_vram This is one self-contained commit on current main. If you would rather land your own version, cherry-picking it keeps the tests and docs together. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:04:39 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2979
No description provided.