Skip to content

fix(responses)!: reject unavailable continuation history - #48397

Closed
DevChiniwala wants to merge 9 commits into
BerriAI:mainfrom
DevChiniwala:litellm_reject_missing_response_history
Closed

DevChiniwala wants to merge 9 commits into
BerriAI:mainfrom
DevChiniwala:litellm_reject_missing_response_history

Conversation

@DevChiniwala

@DevChiniwala DevChiniwala commented Oct 26, 2026 •

Copy link
Copy Markdown

Handwritten 1-3 sentence description

<make-me-human-readable>
Continuing a bridged Responses conversation with unavailable history returns HTTP 400 instead of answering with only the new turn. Synchronous callers also reconstruct stored history before sending a continuation
</make-me-human-readable>

Details

TLDR

Problem this solves

  • Missing history silently loses earlier conversation turns
  • Synchronous continuation skips stored-history reconstruction

How it solves it

  • Reject unavailable history before a provider request
  • Reuse reconstruction for synchronous continuations

Intentional product change, a continuation whose history cannot be reconstructed returns HTTP 400. Clients can send the complete conversation without previous_response_id

User Flow

Before, a continuation can appear successful after losing earlier turns

  1. Send a Responses request through a chat-completions provider and save its response ID
  2. Send another turn using that ID when stored history is unavailable
  3. Receive a completed response based only on the new turn

After, the same continuation reports unavailable history

  1. Send a Responses request through a chat-completions provider and save its response ID
  2. Send another turn using that ID when stored history is unavailable
  3. Receive HTTP 400 naming previous_response_id, with no provider request

Relevant issues

Fixes #48366

Local verification

Tested tip 4dafb0e93c1a84a2de245c8cd0113ff61f1dcbba includes main ff3983c1f627ad09a5e36e45cc92a0cec91afb72. The net change is limited to the four Responses files. The native extension was rebuilt from that main revision

All 799 tests in the Responses transformation directory and CI-coverage check pass. Four missing-history regressions fail on unchanged current main and pass after the fix, covering synchronous and asynchronous calls with streaming enabled and disabled

Ruff formatting and lint pass. The strict-rule, type-discipline, test-quality and basedpyright comparisons pass against that main revision. The type result compares rule counts with existing repository diagnostics and does not claim a codebase without type errors

The follow-up keeps request maps typed and validates optional streaming metadata while retaining support for existing dictionary keys and None

The fork Rust, Rust DB, Terraform and cost-map workflows do not trigger for this Python-only follow-up because their push path filters do not match it

Required upstream workflows still need maintainer approval and successful execution on the current head

Screenshots / Proof of Fix

The local regression uses a simulated provider. Before the fix, a missing-history request completes without raising the expected error. After the fix, it raises BadRequestError with status 400 and sends no provider request

Live-provider before/after proof has not been performed. This changes continuation behavior and does not qualify for the mechanical-change E2E exception. The PR remains a draft

Related work

#48408 rejects synchronous continuations. This draft reconstructs their stored history. #48421 also checks per-turn history completeness in the session layer. This draft guards empty reconstructed history, while per-turn completeness is a broader scope decision. Maintainer guidance is needed to consolidate these approaches

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally
  • My PR passes all required CI/CD checks
  • My PR's scope is as isolated as possible
  • Every automated review on my PR's latest commit has finished and its findings are addressed

Type

Bug Fix

Caveats

Severe

  • Apps that relied on silent history loss receive HTTP 400

Medium

  • Live-provider before/after evidence remains pending
  • Upstream workflows require maintainer approval
  • Related implementations need maintainer scope guidance

Low

  • The author must rewrite the tagged opening before review

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

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 35 untouched benchmarks


Comparing DevChiniwala:litellm_reject_missing_response_history (1261885) with main (72f1ac4)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (dddbaa8) during the generation of this report, so 72f1ac4 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@DevChiniwala

Copy link
Copy Markdown
Author

Updated in fe5be2a: upstream conflict resolved, 894 tests and all delta gates pass; CI pending, draft retained for live-provider evidence

@DevChiniwala

Copy link
Copy Markdown
Author

Fork Rust CI reproduces the unchanged Anthropic/Databricks beta-matrix mismatch; its source and fixture match d884167. Upstream validation still requires maintainer approval

@DevChiniwala

Copy link
Copy Markdown
Author

Pushed 3de002e. All 6,470 Rust tests and 894 Responses tests pass locally. The PR still needs synchronization and live-provider evidence

@DevChiniwala

DevChiniwala commented Nov 2, 2026 •

Copy link
Copy Markdown
Author

Streaming metadata types fixed in 4dafb0e. 799 related tests and delta gates pass. Live provider proof and upstream CI remain pending

@CLAassistant

CLAassistant commented Nov 3, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Both our `run_async_function` and upstream's `unenforced_allowed_tools_tool_choice`
imports are kept — each is used in the file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DevChiniwala
DevChiniwala marked this pull request as ready for review November 13, 2026 22:35
Copilot AI balanced review requested due to automatic review settings November 13, 2026 22:35

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@veria-ai

veria-ai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@github-actions

Copy link
Copy Markdown
Contributor

#48366 was fixed by #53766 on main, so this pull request is closed. Reopen it if something was missed.

@github-actions github-actions Bot closed this Nov 25, 2026
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.

[Bug]: Responses API chat completions bridge silently ignores a previous_response_id it cannot resolve

3 participants