Skip to content

test(e2e): cover /v1/responses openai basic nonstream and stream - #33830

Merged
ishaan-berri merged 4 commits into
litellm_internal_stagingfrom
litellm_e2e_responses_openai_basic
Jul 18, 2026
Merged

test(e2e): cover /v1/responses openai basic nonstream and stream#33830
ishaan-berri merged 4 commits into
litellm_internal_stagingfrom
litellm_e2e_responses_openai_basic

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Relevant issues

Linear ticket

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Screenshots / Proof of Fix

Video proof of the live run (docker compose stack, liveliness check, pytest run of both tests, and a live curl against /v1/responses showing a response.output_text.delta event and the final response.completed) is embedded under the QA runbook below. Captured at commit fb20177; the follow-up commits only tightened the termination assertion and moved the event-type model, and the same two tests were re-run green against the live stack at 8a62280

Type

✅ Test

Changes

PR 1 of a 4-PR series adding e2e coverage for the /v1/responses endpoint. It closes exactly two registry cells that already exist in tests/e2e/coverage_registry/llm_conversational.yaml: llm.responses.openai.basic.nonstream.works and llm.responses.openai.basic.stream.works

The existing smoke test TestResponses::test_responses_returns_completion now carries the nonstream marker; its assertion is unchanged (parses the body as ResponsesResult and asserts non-empty output text). A new test_responses_streaming_returns_completion registers an openai/gpt-4o-mini deployment at runtime, calls /v1/responses with stream: true through the shared transport, and asserts the stream carried at least one response.output_text.delta event with non-empty text and that the final raw SSE event (excluding the [DONE] sentinel) has type response.completed; a stream with no text deltas fails

To support this, e2e_http.py now preserves the raw SSE data: payloads on StreamingResponse.stream_events, and endpoints_client.py gains stream: bool = False on the responses call plus typed ResponsesOutputTextDeltaEvent / ResponsesStreamEventType models. No raw dicts or Any

coverage_registry.collector --strict passes with both markers resolving; make lint-e2e-basedpyright reports zero errors

QA runbook

  1. cd tests/e2e and create .env with OPENAI_API_KEY (plus the other provider keys the compose file references)
  2. docker compose up -d and wait for curl -fs http://localhost:4000/health/liveliness to return "I'm alive!"
  3. Live curl of the same behavior: curl -sN http://localhost:4000/v1/responses -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" -d '{"model": "gpt-5.5", "input": "reply with one word", "stream": true}' and watch a response.output_text.delta event followed by response.completed
  4. uv run pytest llm_translation/test_responses_e2e.py -v and expect both tests to pass

Video of the full live run: https://app.devin.ai/attachments/70280648-11bb-4993-8c25-09124b02aadc/rec-5424436e-bc2b-4bc2-9c8b-a1160cc4d08b-edited.mp4

  • tests/e2e/llm_translation/test_responses_e2e.py::TestResponses::test_responses_returns_completion - a runtime-registered openai deployment answers /v1/responses with real output text
    • POST /model/new with the master key and openai/gpt-4o-mini
    • POST /v1/responses non-streaming with a generated key and expect non-empty output[].content[].text
    • Sanity check: this test makes sense to add and is not hand-wavey (asserts real output text, not a status code) or potentially flaky
  • tests/e2e/llm_translation/test_responses_e2e.py::TestResponses::test_responses_streaming_returns_completion - the same deployment streams real text deltas and terminates cleanly
    • POST /v1/responses with "stream": true and consume the SSE stream
    • Expect at least one response.output_text.delta event with non-empty delta and a final response.completed event
    • Sanity check: this test makes sense to add and is not hand-wavey (a stream that opens but yields no text deltas fails) or potentially flaky

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Link to Devin session: https://app.devin.ai/sessions/b4e79c562b4a4187ba6cefec54f92d5a
Requested by: @ishaan-berri

Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>
@ishaan-berri ishaan-berri self-assigned this Jul 18, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds e2e test coverage for the /v1/responses endpoint (non-streaming and streaming) via two new/updated test cases in tests/e2e/. Supporting infrastructure changes populate StreamingResponse.stream_events with raw data: SSE payloads and plumb a stream flag through EndpointsClient.responses().

  • e2e_http.py gains stream_events: list[str] on StreamingResponse and fills it during SSE consumption; the change is purely additive and doesn't affect non-streaming callers.
  • endpoints_client.py adds typed streaming event models (ResponsesOutputTextDeltaEvent, ResponsesCompletedEvent) with Literal type constraints and forwards stream to both the request body and the HTTP transport.
  • test_responses_e2e.py registers openai/gpt-4o-mini at runtime, drives the responses API in both modes, and asserts real output text / non-empty deltas plus a response.completed terminator.

Confidence Score: 4/5

All changes are confined to the tests/e2e/ directory; no production code is touched and the modifications are purely additive.

The termination assertion in the streaming test checks that the last recognized (delta or completed) event is response.completed, but silently discards other SSE event types — so trailing events of unknown type would not be caught. This does not affect the happy-path test result but slightly overstates the strictness of the check.

tests/e2e/llm_translation/test_responses_e2e.py — specifically the isinstance(parsed_events[-1], ResponsesCompletedEvent) assertion and the _parse_stream_event filtering logic.

Important Files Changed

Filename Overview
tests/e2e/e2e_http.py Adds stream_events: list[str] to StreamingResponse and populates it with raw data: payloads during SSE streaming; logic is correct and non-breaking for non-streaming callers.
tests/e2e/llm_translation/endpoints_client.py Adds stream parameter to ResponsesRequest and responses(), adds typed streaming event models with Literal type constraints; no issues found.
tests/e2e/llm_translation/test_responses_e2e.py Adds streaming e2e test with SSE event parsing; termination assertion checks last recognized event rather than the absolute last SSE line in the stream.

Reviews (1): Last reviewed commit: "test(e2e): cover /v1/responses openai ba..." | Re-trigger Greptile

Comment on lines +72 to +74
assert completed_events and isinstance(parsed_events[-1], ResponsesCompletedEvent), (
"responses stream did not terminate with response.completed"
)

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.

P2 Termination check operates on filtered events only

parsed_events contains only response.output_text.delta and response.completed events — all other SSE event types (e.g. response.output_text.done, response.output_item.done, response.done) are silently dropped to None by _parse_stream_event. So isinstance(parsed_events[-1], ResponsesCompletedEvent) confirms that no recognized event arrived after response.completed, not that response.completed was the absolute final line in the stream. If OpenAI or LiteLLM ever appends a trailing event of an unrecognized type, the assertion continues to pass even though the stream did not literally end on response.completed. Consider also capturing the raw final data: line and asserting its content, or extending _parse_stream_event to return a sentinel for any non-None parsed event.

@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_e2e_responses_openai_basic (8a62280) with litellm_internal_staging (010b200)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (fdf380d) during the generation of this report, so 010b200 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>
devin-ai-integration Bot and others added 2 commits July 18, 2026 18:48
Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>
Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>

@ishaan-berri ishaan-berri 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

@ishaan-berri
ishaan-berri merged commit a1fb07f into litellm_internal_staging Jul 18, 2026
83 checks passed
@ishaan-berri
ishaan-berri deleted the litellm_e2e_responses_openai_basic branch July 18, 2026 20:25
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.

2 participants