Skip to content

test(integration): cover responses endpoint contracts - #44733

Merged
mateo-berri merged 13 commits into
mainfrom
litellm_endpoint_contracts_responses
Oct 14, 2026
Merged

mateo-berri merged 13 commits into
mainfrom
litellm_endpoint_contracts_responses

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Responses integration coverage missed ownership and wire-contract edge cases
  • Cursor Chat assertions did not pin the full translated request and response

How it solves it:

  • Adds exact local-proxy assertions for lifecycle, ownership, metadata, and Cursor routes
  • Restores streamed-ID retrieval and proves the assertions with individual mutants

Screenshots / Proof of Fix

This PR changes test coverage only and has no user-visible before-and-after behavior. The local integration tests use a real proxy and scripted upstream to verify exact request and response contracts

What is covered

The tests exercise Responses ownership, lifecycle, compact, previous-response affinity, typed metadata, and Cursor request and response translation across the supported route aliases

The create test is test_allow_unmanaged_response_ids_forward_the_vendor_id_on_create. The streamed-ID test now retrieves the streamed ID, compares the full response, and checks the exact upstream GET

Tests and mutation proofs

Evidence and local runs below are at 1851524b67. Commit 94eebaec13 then made the Cursor and compact registrations wait for every worker, and both files passed again (38 passed, 5 BUG skips). Commit f98a4715d2 makes readiness track each worker by pairing /debug/memory/summary worker_pid with /model/info on one connection, and returns only when every worker reports the deployment

Mutant Node and assertion at this tip Observed failure
A, disable allow_unmanaged_response_ids test_allow_unmanaged_response_ids_forward_the_vendor_id_on_create, test_responses_id_ownership.py:351 HTTP 403, Forbidden. This response id was not issued by this proxy
B, remove previous_response_id from ResponsesAPIOptionalRequestParams Same create test, test_responses_id_ownership.py:388 Exact upstream-body assertion failed because previous_response_id was missing
C, use environment fallback credentials and base Same create test, test_responses_id_ownership.py:382 Decoy assertion failed after a request used synthetic-env-fallback-key
D, overwrite a retrieved response field test_retrieve_routes_to_the_deployment_that_created_the_response, test_responses_lifecycle_wire.py:173 Full response assertion got status: failed, expected status: completed
E1, remove the string-only metadata filter test_responses_metadata_reaches_the_provider_as_typed, test_responses_core_wire.py:371 All aliases forwarded integer, boolean, and nested values
E2, trim metadata to 15 keys Same metadata test, test_responses_core_wire.py:371 All aliases forwarded 15 keys instead of the expected first 16
F, keep only /v1/responses in the create-route set Previous-response test survived all six alias combinations. The streamed retrieve test killed this mutant only for the empty prefix at test_responses_lifecycle_wire.py:270 with HTTP 403, Forbidden. This response id was not issued by this proxy
G, omit Cursor Chat reasoning_effort injection test_cursor_messages_body_uses_chat_completions_wire[False--thinking-low-low], test_cursor_responses_wire.py:412 Exact upstream body omitted reasoning_effort: low
H, change translated completion_tokens to 99 test_cursor_messages_body_uses_chat_completions_wire[False--], test_cursor_responses_wire.py:384 Full response assertion got 99 completion tokens, expected 3

Each mutant was applied alone, the shared proxies were restarted, and the focused test failed at the listed assertion. The product mutation was restored before the green integration runs

The earlier Cursor suffix mutant failed at test_cursor_responses_wire.py:190, forwarding reasoning.effort: high instead of low. The reviewer also reported C1 failing with model=None no healthy deployments and B1, H1, K1, E1, F1, K2, and K3 killed at d2dae45

The streamed retrieve passed three consecutive runs for /v1, ``, and /openai/v1. The exact upstream request list includes the stream POST and retrieve GET

The unmanaged-create retrieve passed through allowed_gateway. Removing the unmanaged lifecycle skip made retrieve fail at test_responses_id_ownership.py:440 with HTTP 400, You passed in model=None. There are no healthy deployments for this model

The input-items include probe failed on all aliases because upstream received only limit=20&order=desc. Its assertion remains under the existing BUG skip

Cursor Chat suffix cases include empty, none, minimal, low, medium, high, and max. xhigh is excluded because GPT-5 returns 400 before the scripted upstream receives the request

Runs

  • Ownership: 4 passed, 7 skipped
  • Cursor: 34 passed, 2 skipped
  • Compact: 4 passed, 3 skipped
  • Responses core: 15 passed, 1 skipped
  • Responses lifecycle: 12 passed, 12 skipped
  • Ruff checks and make check passed

Type

Test

Caveats

Medium

  • test_compact_previous_response_id_is_scoped_to_the_issuing_user_and_team remains skipped for a cross-tenant product bug filed as its own internal P0 ticket
  • test_allow_unmanaged_response_id_lifecycle_route_reaches_provider remains skipped for unmanaged retrieve, delete, cancel, and input-items routes
  • test_retrieve_returns_the_id_the_client_holds and test_retrieve_query_reaches_the_provider remain skipped for ID equality and retrieve query forwarding
  • test_compact_previous_response_id_reaches_the_provider_as_the_raw_id remains skipped for compact previous-response forwarding
  • test_conversation_is_forwarded_as_a_separate_responses_parameter remains skipped because conversation is dropped
  • test_delete_returns_the_client_held_id_not_the_provider_id documents that delete returns the provider ID, which the green delete test accepts
  • test_input_items_pagination_query_reaches_the_provider remains skipped because pagination and include are dropped
  • test_cursor_stream_reports_usage_when_the_client_asks_for_it remains skipped because Cursor omits the usage chunk
  • test_cursor_responses_body_carries_no_proxy_metadata remains skipped because Cursor forwards proxy metadata, which the green Responses test filters
  • No Linear ticket id is included

Pre-Submission checklist

  • Meaningful integration tests were added
  • The five changed integration files pass locally
  • Ruff format and test-tree lint pass
  • make check passes
  • Required CI checks have not been run in this handoff
  • The change is limited to integration tests and their shared readiness helper
  • Review-bot confidence has not been checked in this handoff

Final Attestation

  • The tests check the request and response contracts covered by this change

Note

Low Risk
Test-only changes with no runtime or security behavior modifications; skipped tests document existing product bugs without altering the proxy.

Overview
Adds integration test coverage for LiteLLM proxy Responses API and Cursor routes, plus a shared wait_for_worker_readiness helper so deployments are visible on every proxy worker before assertions run.

New suites use scripted upstream wire servers to assert exact provider requests and client-facing responses: user/team response-id ownership (403 on cross-tenant access), lifecycle (retrieve affinity, delete/cancel, streamed IDs), compact routes and SDK bodies, previous_response_id raw-id forwarding and deployment affinity, metadata typing/limits, and Cursor translation (Responses vs chat-completions wire, suffixes, streaming).

Several cases stay pytest.skip with BUG notes for known gaps (compact ownership, unmanaged lifecycle routes, retrieve query params, conversation param, Cursor metadata/usage, etc.). No production code changes—tests and the readiness helper only.

Reviewed by Cursor Bugbot for commit c6d5df0. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low risk] Adds integration tests for response endpoints.

This test-only PR appears safe to merge; no outstanding review finding remains.

Summary

The PR adds integration tests for Responses ownership, lifecycle and routing, compact requests, and Cursor’s Responses-to-chat translation. Several known product bugs are documented in skipped tests. No PR-file changes were made since the previous review, and the previous findings are resolved.

Reviews (7) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Isolate team-only response-id ownership with a same-user different-team key,
send every denial through the OpenAI SDK on all three aliases, make the
previous_response_id affinity check deterministic, assert the whole cancel
response, prove the Cursor stream text, -fast suffixes and include_obfuscation
strip, add SDK compact cases, restore router pre-call checks after the
affinity test, and inline the root-level responses_test_support helpers

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

…deployments

Restore the cross-worker convergence wait dropped when the shared helper was
inlined, so the affinity and retrieve-routing tests cannot pass before the
alternative deployment is loaded on a multi-worker gateway

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

@mateo-berri mateo-berri added run-ci and removed run-ci labels Oct 6, 2026
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

mateo-berri and others added 2 commits October 6, 2026 09:45
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…through body

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Oct 6, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri mateo-berri removed the run-ci label Oct 6, 2026
mateo-berri and others added 2 commits October 14, 2026 03:51
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@litereview

litereview Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

✅ code-review

5/5 · Ready for human review

Scope: full · Full PR review.

Completed · Some checks not run.

No correctness findings.

This PR changes test code only. It adds five integration test files and one readiness helper under tests/integration/. It doesn't touch litellm/llms/** or litellm/litellm_core_utils/prompt_templates/**, so the real-testing-evidence gate doesn't apply. The PR changes no public API, configuration or default, so no breaking-change marker is needed.

Checks and execution details
  • Passed · Real testing evidence (required): Not applicable: no LLM translation changes in the scoped paths. The PR changes only these files: tests/integration/_support/worker_readiness.py, tests/integration/authorization/test_responses_id_ownership.py and tests/integration/providers/test_{cursor_responses,responses_compact,responses_core,responses_lifecycle}_wire.py. None of them is under litellm/llms/** or litellm/litellm_core_utils/prompt_templates/**.
  • Passed · Ruff lint on changed files (optional): uvx ruff check --config ruff-tests.toml on all six changed files reported All checks passed!
  • Passed · Python compile of changed files (optional): python -m py_compile passed on the changed test files and on worker_readiness.py.
  • Passed · Readiness helper against proxy endpoints (optional): I checked by reading the code. /debug/memory/summary in litellm/proxy/common_utils/debug_utils.py:318 returns worker_pid (os.getpid(), line 400). The proxy server mounts that router, so the helper's per-worker pairing of PID and /model/info works with the real proxy endpoints.
  • Not run · Integration suite execution (optional): I didn't run the suite. It needs a real proxy, Postgres, Redis and a scripted upstream, and openai is not installed in this sandbox. The PR reports local passes. This rule doesn't require this check.

View review · Reviewed c6d5df081415

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c6d5df0. Configure here.

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

@mateo-berri
mateo-berri merged commit 5261a2c into main Oct 14, 2026
89 checks passed
@mateo-berri
mateo-berri deleted the litellm_endpoint_contracts_responses branch October 14, 2026 06:59
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