Skip to content

Allow disabling chat completions persistence via null store - #1

Open
meffmadd wants to merge 9 commits into
mainfrom
disable-inference-store
Open

Allow disabling chat completions persistence via null store#1
meffmadd wants to merge 9 commits into
mainfrom
disable-inference-store

Conversation

@meffmadd

@meffmadd meffmadd commented Aug 5, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Allow operators to disable chat completion persistence by setting storage.stores.inference to null in a run config. When the reference is None, the auto-router factory in get_auto_router_impl skips constructing and initializing the InferenceStore entirely: no inference_store table is created and no background write workers are started, so no chat completion payload is ever persisted.

Behavior when persistence is disabled:

  • Chat completions continue to work for both streaming and non-streaming requests.
  • The history endpoints (list, retrieve, messages) raise NotImplementedError, which the exception mapping translates to HTTP 501 — rather than returning an empty list or a 404.
  • Other stores (responses, datasets, eval, files, prompts, vector_io) stay enabled, so disabling inference persistence is independent of the rest of the storage layer.
  • The default remains backward compatible: omitting the inference key keeps persistence enabled; only an explicit inference: null disables it.

This follows the same optional-store pattern the Responses store already uses.

Configuration

storage:
  stores:
    inference: null

Changes

  • src/ogx/core/routers/__init__.py — build/initialize the InferenceStore only when the reference is not None.
  • src/ogx/core/storage/README.md, src/ogx/distributions/README.md — document the opt-out and its runtime behavior.
  • Unit tests:
    • tests/unit/core/routers/test_inference_router.py — non-streaming and streaming completions with no store; list/get/messages raise NotImplementedError.
    • tests/unit/core/test_storage_references.py — omit-vs-null parsing: omitted key keeps the enabled default, null disables.
    • tests/unit/server/test_resolver.py — resolver does not construct/initialize an InferenceStore when the reference is None.
  • Integration test tests/integration/inference/test_inference_store_disabled.py (recorded responses from openai/gpt-4o) — end-to-end behavior over the full HTTP path, including asserting that no inference_store table exists in the SQL backend.

Test Plan

Unit tests

uv run pytest tests/unit/core/routers/test_inference_router.py \
  tests/unit/core/test_storage_references.py \
  tests/unit/server/test_resolver.py -q

Output:

.........................                                [100%]
============================= slowest 10 durations =============================
0.08s call     tests/unit/server/test_resolver.py::test_resolve_impls_basic

(9 durations < 0.005s hidden.  Use -vv to show these durations.)
25 passed in 0.18s

Integration tests (replay mode — no API keys required)

uv run --no-sync ./scripts/integration-tests.sh \
  --stack-config server:ci-tests --setup gpt \
  --file tests/integration/inference/test_inference_store_disabled.py

Output:

tests/integration/inference/test_inference_store_disabled.py::test_non_streaming_chat_completion_without_store PASSED [ 16%]
tests/integration/inference/test_inference_store_disabled.py::test_streaming_chat_completion_without_store PASSED [ 33%]
tests/integration/inference/test_inference_store_disabled.py::test_list_chat_completions_reports_not_configured PASSED [ 50%]
tests/integration/inference/test_inference_store_disabled.py::test_retrieve_chat_completion_reports_not_configured PASSED [ 66%]
tests/integration/inference/test_inference_store_disabled.py::test_list_chat_completion_messages_reports_not_configured PASSED [ 83%]
tests/integration/inference/test_inference_store_disabled.py::test_no_inference_store_table_when_persistence_disabled PASSED [100%]

======================== 6 passed, 2 warnings in 6.69s =========================

Both suites pass on this branch. The integration tests run in replay mode against the committed recordings, so they are deterministic and need no API keys.

…l store

Allow operators to disable chat completion persistence by setting
storage.stores.inference to null in a run config. When the reference is
absent of value None, the auto-router factory skips constructing and
initializing the InferenceStore entirely: no inference_store table is
created and no background write workers are started, so no chat completion
payload is ever persisted.

Chat completions continue to work for both streaming and non-streaming
requests. The history endpoints (list, retrieve, messages) raise
NotImplementedError, which the exception mapping translates to HTTP 501,
rather than returning an empty list or a 404. Other stores stay enabled, so
disabling inference persistence is independent of the rest of the storage
layer. This follows the same optional-store pattern the Responses store
already uses.

Signed-off-by: Matt, Matthias <matthias.matt@tuwien.ac.at>
Drop the formatting-only changes that were bundled into
'feat(inference): allow disabling chat completions persistence via
null store' so the feature diff is limited to the actual behavior
change:

- Restore the pre-existing formatting of the get_auto_router_impl
  signature in src/ogx/core/routers/__init__.py and of untouched lines
  in the touched unit tests.
- Normalize lines added by the feature (new tests and the recording
  generator script) with the pinned ruff 0.12.2 used by pre-commit.
- Add the project license header to the recording generator script and
  make it executable like the other scripts/ helpers, and add
  noqa: N802 markers to its BaseHTTPRequestHandler.do_GET/do_POST,
  matching precedent in tests/integration/telemetry/collectors/otlp.py.

No functional changes; all affected unit tests still pass.

Signed-off-by: Matt, Matthias <matthias.matt@tuwien.ac.at>
Signed-off-by: Matt, Matthias <matthias.matt@tuwien.ac.at>
@meffmadd
meffmadd force-pushed the disable-inference-store branch from 05ede32 to 775dd47 Compare August 11, 2026 08:02
meffmadd and others added 3 commits August 19, 2026 10:47
Signed-off-by: Matt, Matthias <matthias.matt@tuwien.ac.at>
Signed-off-by: Matt, Matthias <matthias.matt@tuwien.ac.at>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant