Skip to content

Don't attach a conversation to stateless /v1/responses requests - #3190

Merged
tisnik merged 1 commit into
lightspeed-core:mainfrom
owtaylor:stateless-responses-no-conversation-main
Nov 10, 2026
Merged

tisnik merged 1 commit into
lightspeed-core:mainfrom
owtaylor:stateless-responses-no-conversation-main

Conversation

@owtaylor

@owtaylor owtaylor commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

A /v1/responses request with store=false and no conversation or previous_response_id comes from a stateless client that resends the full history as input on every request (e.g. a Chat Completions to Responses proxy). lightspeed-stack still auto-created a conversation and passed it to OGX, which then copied the entire input into the conversation after the response. OGX adds those items with a single AddItemsRequest, which is limited to 20 items, so once the history grew past that every request failed after streaming the output:

  1 validation error for AddItemsRequest
  items
    List should have at most 20 items after validation, not 22

For such requests, set omit_conversation so the conversation parameter isn't sent to OGX, and skip topic summary generation, whose result is only used when the turn is stored.

PendingTurn.for_request() treated any request with omit_conversation as compacted and required its original input; accept a store=false request without one, since its turn is never stored.

Note:

  • that this does not fix requests with store: true that add more than 20 items at once. That would be a separate thing, and would require a change to OGX.
  • not creating a conversation at all would require making conversation optional in many places.

Type of change

  • Bug fix

Tools used to create PR

Identify any AI code assistants used in this PR (for transparency and review context)

  • Generated by: Claude Opus 5.5

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • New unit tests: test_stateless_request_omits_conversation_and_topic_summary
    (tests/unit/app/endpoints/test_responses.py) and
    test_stateless_request_without_conversation_stores_nothing
    (tests/unit/utils/test_pending_turn.py). Existing unit tests pass.
  • To reproduce manually:
    • Stand up a lightspeed-stack instance
    • POST to /v1/responses with store: false, no conversation/previous_response_id,
      and 20+ input items (e.g. a user message plus 10 function_call/function_call_output pairs)
    • Before: the stream ends with 1 validation error for AddItemsRequest ... at most 20 items;
      after: response.completed
  • Not tested against live inference on main. The equivalent change on release/0.6 was
    tested with Vertex AI (Gemini) and Ollama backends, with up to 82 input items. The only
    functional difference on main is the PendingTurn change, which is covered by the new unit test.

Summary by CodeRabbit

  • Bug Fixes
    • Requests made with storage disabled and no conversation or previous response ID now remain stateless: they are not stored or attached to a conversation.
    • Topic summaries are not generated for these requests.
    • Stateless requests can complete without original input, while other requests that lack it continue to be rejected.

A /v1/responses request with store=false and no conversation or
previous_response_id comes from a stateless client that resends the full
history as input on every request (e.g. a Chat Completions to Responses
proxy). lightspeed-stack still auto-created a conversation and passed it
to OGX, which then copied the entire input into the conversation after
the response. OGX adds those items with a single AddItemsRequest, which
is limited to 20 items, so once the history grew past that every request
failed after streaming the output:

  1 validation error for AddItemsRequest
  items
    List should have at most 20 items after validation, not 22

For such requests, set omit_conversation so the conversation parameter
isn't sent to OGX, and skip topic summary generation, whose result is
only used when the turn is stored.

PendingTurn.for_request() treated any request with omit_conversation as
compacted and required its original input; accept a store=false request
without one, since its turn is never stored.
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

For /v1/responses requests with store=false and no conversation identifiers, the endpoint disables topic-summary generation and omits the conversation from validated parameters. PendingTurn.for_request now creates an unstored turn from params.input when original_input is absent.

Changes

Stateless Responses handling

Layer / File(s) Summary
Identify stateless requests
src/app/endpoints/responses.py, src/models/common/responses/responses_api_params.py, tests/unit/app/endpoints/test_responses.py
The endpoint identifies requests with storage disabled and no conversation identifiers. It disables topic-summary generation and sets omit_conversation. The test covers these requests and non-stateless cases.
Create unstored turns
src/utils/pending_turn.py, tests/unit/utils/test_pending_turn.py
When original_input is absent and storage is disabled, PendingTurn.for_request creates a turn using params.input. The test checks that the turn settles without client writes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Suggested labels: python, risk/low, Review effort 2/5

Suggested reviewers: tisnik, asimurka

Merge Risk: Minimal · up to 6b53f

The change is ready to merge after normal checks. Stateless requests omit conversation input as intended, and no attributable user-facing failure is established.

Pre-merge checks: Passed 7

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: stateless /v1/responses requests do not attach a conversation.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Performance And Algorithmic Complexity Passed PASSED. The changes add constant-time checks and skip topic-summary generation and turn storage for stateless requests. They introduce no identified performance regression under the check criteria.
Security And Secret Handling Passed No listed security violation was introduced. The endpoint retains authentication and authorization. Stateless requests omit the conversation from OGX calls, and unstored turns do not write conversatio…
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 5 files.

Full details: Security And Secret Handling

Explanation

No listed security violation was introduced. The endpoint retains authentication and authorization. Stateless requests omit the conversation from OGX calls, and unstored turns do not write conversation data. The PR does not change Kubernetes or RH Secrets.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Simplify code

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a29801b and 6b53fda.

Files selected for processing: 5

  • src/app/endpoints/responses.py
  • src/models/common/responses/responses_api_params.py
  • src/utils/pending_turn.py
  • tests/unit/app/endpoints/test_responses.py
  • tests/unit/utils/test_pending_turn.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details

Context from checks skipped due to timeout: 16

  • GitHub Check: E2E: server / ci / authorized
  • GitHub Check: E2E: library / ci / skills
  • GitHub Check: E2E: library / ci / other
  • GitHub Check: E2E: library / ci / default
  • GitHub Check: E2E: server / ci / skills
  • GitHub Check: E2E: server / ci / default
  • GitHub Check: E2E: library / ci / authorized
  • GitHub Check: E2E: server / ci / other
  • GitHub Check: E2E: library / ci / shields
  • GitHub Check: E2E: library / ci / rbac
  • GitHub Check: E2E: server / ci / tls
  • GitHub Check: E2E: library / ci / mcp
  • GitHub Check: E2E: server / ci / shields
  • GitHub Check: E2E: server / ci / rbac
  • GitHub Check: E2E: server / ci / mcp
  • GitHub Check: Konflux kflux-prd-rh02
CI failures not shown inline: 2

GitHub Actions: PR Title Checker / 0_check.txt: Don't attach a conversation to stateless /v1/responses requests

Conclusion: failure

View job details

##[group]Run thehanimo/pr-title-checker@v1.4.3
 with:
   GITHUB_***REDACTED_SECRET_ASSIGNMENT***
   pass_on_octokit_error: false
   configuration_path: .github/pr-title-checker-config.json
 ##[endgroup]
 Using config file .github/pr-title-checker-config.json from repo lightspeed-core/lightspeed-stack [ref: a29801b6778442f7ed1f0a44ea49a9016fefe2a6]
 (node:2078) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
 (Use `node --trace-deprecation ...` to show where the warning was created)
 (node:2078) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
 Creating label (title needs formatting)...
 Label (title needs formatting) already created.
 Adding label (title needs formatting) to PR...
 HttpError: Resource not accessible by integration
 ##[error]Failed to add label (title needs formatting) to PR

GitHub Actions: PR Title Checker / check: Don't attach a conversation to stateless /v1/responses requests

Conclusion: failure

View job details

##[group]Run thehanimo/pr-title-checker@v1.4.3
 with:
   GITHUB_***REDACTED_SECRET_ASSIGNMENT***
   pass_on_octokit_error: false
   configuration_path: .github/pr-title-checker-config.json
 ##[endgroup]
 Using config file .github/pr-title-checker-config.json from repo lightspeed-core/lightspeed-stack [ref: a29801b6778442f7ed1f0a44ea49a9016fefe2a6]
 (node:2078) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
 (Use `node --trace-deprecation ...` to show where the warning was created)
 (node:2078) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
 Creating label (title needs formatting)...
 Label (title needs formatting) already created.
 Adding label (title needs formatting) to PR...
 HttpError: Resource not accessible by integration
 ##[error]Failed to add label (title needs formatting) to PR
Additional context used

Code guidelines: 2

CLAUDE.md — auto-discovered
AGENTS.md — auto-discovered
Path-based instructions: 6

Source excerpt: **Required**: Use pytest for all unit and integration tests Source excerpt: **Forbidden**: Do not use unittest - pytest is the standard for this project Source excerpt: **Coverage**: Unit tests require 60% coverage, integrat...

CodeRabbit inference engine (CLAUDE.md)

Files:

  • tests/unit/utils/test_pending_turn.py
  • tests/unit/app/endpoints/test_responses.py
Source excerpt: Use absolute imports for internal modules: `from authentication import get_auth_dependency` Source excerpt: FastAPI dependencies: `from fastapi import APIRouter, HTTPException, Request, status, Depends` Source excerpt: OGX i...

CodeRabbit inference engine (AGENTS.md)

Files:

  • tests/unit/utils/test_pending_turn.py
  • src/models/common/responses/responses_api_params.py
  • tests/unit/app/endpoints/test_responses.py
  • src/utils/pending_turn.py
  • src/app/endpoints/responses.py
Source excerpt: **Required**: Use pytest for all unit and integration tests **Forbidden**: Do not use unittest - pytest is the standard for this project Source excerpt: **Coverage**: Unit tests require 60% coverage, integration 10%

CodeRabbit inference engine (AGENTS.md)

Files:

  • tests/unit/utils/test_pending_turn.py
  • tests/unit/app/endpoints/test_responses.py
Source excerpt: **Fixtures**: Use `conftest.py` for shared fixtures Source excerpt: **Mocking**: `pytest-mock` for AsyncMock objects

CodeRabbit inference engine (AGENTS.md)

Files:

  • tests/unit/utils/test_pending_turn.py
  • tests/unit/app/endpoints/test_responses.py
Source excerpt: **Mocking**: `pytest-mock` for AsyncMock objects Source excerpt: **Auth Mock**: `MOCK_AUTH = ("mock_user_id", "mock_username", False, "mock_token")`

CodeRabbit inference engine (CLAUDE.md)

Files:

  • tests/unit/utils/test_pending_turn.py
  • tests/unit/app/endpoints/test_responses.py
Source excerpt: **Async tests**: Use marker `pytest.mark.asyncio`

CodeRabbit inference engine (AGENTS.md)

Files:

  • tests/unit/utils/test_pending_turn.py
  • tests/unit/app/endpoints/test_responses.py
Additional comments: 5

src/app/endpoints/responses.py: 1

637-649: LGTM!

src/models/common/responses/responses_api_params.py: 1

136-139: LGTM!

tests/unit/app/endpoints/test_responses.py: 1

369-435: LGTM!

src/utils/pending_turn.py: 1

119-129: LGTM!

tests/unit/utils/test_pending_turn.py: 1

153-177: LGTM!

@asimurka asimurka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tisnik tisnik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tisnik

tisnik commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

/ok-to-test

@fullsend-ai-review fullsend-ai-review Bot mentioned this pull request Nov 10, 2026
1 task
@tisnik
tisnik merged commit bb755e0 into lightspeed-core:main Nov 10, 2026
93 of 100 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants