Skip to content

fix(openai): forward Responses background_options (lts/1.108.x) - #53993

Merged
mateo-berri merged 3 commits into
lts/1.108.xfrom
litellm_lts_openai_background_options
Nov 24, 2026
Merged

mateo-berri merged 3 commits into
lts/1.108.xfrom
litellm_lts_openai_background_options

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

LTS twin of #53991. OpenAI's Responses API takes background options such as a completion window for background runs, and the gateway silently removed them, so this passes them through to OpenAI unchanged on the 1.108 line.

Main commit LTS commit
ce861ca d6bc32e
b4321c3 b022a7c 70688d8 (the Final annotations only, this line has no compact rejected-params list for the compact test line)
Details

Link to Devin session: https://app.devin.ai/sessions/26d0518689f14b8fa0acd3f0254acea6
Open in Devin Desktop: https://app.devin.ai/desktop/session/26d0518689f14b8fa0acd3f0254acea6?variant=devin
Requested by: @mateo-berri

TLDR

Problem this solves:

  • background_options on /v1/responses was dropped before reaching OpenAI

How it solves it:

  • Add background_options (completion_window, continuation_id) to the Responses optional params

Adaptations from main:

  • Main also lists the field among params rejected on compact requests, the line has no such list, so that hunk is omitted

Screenshots / Proof of Fix

Live before and after on this line, both legs on the same config against the real provider. The main twin's proof is on #53991

# config.yaml
model_list:
  - model_name: gpt-5-mini
    litellm_params:
      model: openai/gpt-5-mini
      api_key: os.environ/OPENAI_API_KEY
general_settings:
  master_key: sk-1234
# env: OPENAI_API_KEY, LITELLM_DANGEROUSLY_PERMIT_WEAK_OR_UNSET_MASTER_KEY=true
python -m litellm.proxy.proxy_cli --config config.yaml --port 4611 --num_workers 1   # Before checkout
python -m litellm.proxy.proxy_cli --config config.yaml --port 4612 --num_workers 1   # After checkout

One worker without Redis or a database on both legs, since the change only adds a request field and reads no shared state

Before (7276136, merge base with lts/1.108.x)

Invalid completion_window

  1. curl -s localhost:4611/v1/responses -H "Authorization: Bearer sk-1234" -H "content-type: application/json" -d '{"model":"gpt-5-mini","input":"say hi","background":true,"background_options":{"completion_window":"bogus"}}' (HTTP status plus the status, background and error fields shown)
HTTP 200 {'status': 'queued', 'background': True, 'error': None}

Valid completion_window

  1. Same curl with "completion_window":"soonest"
HTTP 200 {'status': 'queued', 'background': True, 'error': None}

No background_options

  1. Same curl without background_options
HTTP 200 {'status': 'queued', 'background': True, 'error': None}

After (b022a7c, later commits change only the test file)

Invalid completion_window

  1. Same curl against port 4612
HTTP 400 {'status': None, 'background': None, 'error': {'message': 'litellm.BadRequestError: OpenAIException - {\n  "error": {\n    "message": "Invalid value: \'bogus\'. Supported values are: \'soonest\', \'2h\', and \'8h\'.",\n    "type": "invalid_request_error",\n    "param": "background_options.completion_window",\n    "code": "invalid_value"\n  }\n}\n\nLiteLLM: model group \'gpt-5-mini\' failed with the error above. No fallback was attempted.', 'type': 'invalid_request_error', 'param': None, 'code': '400'}}

Valid completion_window

  1. Same curl with "completion_window":"soonest" against port 4612
HTTP 200 {'status': 'queued', 'background': True, 'error': None}

No background_options

  1. Same curl without background_options against port 4612
HTTP 200 {'status': 'queued', 'background': True, 'error': None}

Focused tests: tests/unit/responses/test_responses_utils.py 51 passed

Type

🐛 Bug Fix

Caveats (if any)

Medium

  • 2h and 8h windows were rejected by OpenAI for the QA models on main, only soonest was seen succeeding
  • continuation_id was not exercised live, only in the unit test

Low


Note

Low Risk
Adds a forwarded optional request field and types with a focused unit test; no auth or data-path changes.

Overview
Fixes silent dropping of background_options on /v1/responses requests so LiteLLM forwards OpenAI’s background-run settings to the provider.

Adds a ResponsesAPIBackgroundOptions type (completion_window: soonest | 2h | 8h, continuation_id) and registers background_options on ResponsesAPIOptionalRequestParams, which is the allowlist used when building the outbound Responses request.

A unit test asserts that background plus background_options survive optional-param filtering and mapping for OpenAI, while unrelated keys are stripped.

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

background_options was filtered out of /v1/responses requests, so a background completion window silently fell back to the default

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

Copy link
Copy Markdown
Contributor

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

@veria-ai

veria-ai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with the previous finding fixed and no new actionable issues found

Summary

Adds background_options to the Responses request fields so OpenAI receives the supplied options unchanged

  • OpenAI Responses requests now keep background run options.

Reviews (3) · Last reviewed commit: "test(openai): type the background_option..." · Reviewed by Greptile

Comment thread litellm/types/llms/openai.py Resolved
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

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 Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

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 70688d8. Configure here.

@mateo-berri
mateo-berri merged commit fe08c44 into lts/1.108.x Nov 24, 2026
64 of 66 checks passed
@mateo-berri
mateo-berri deleted the litellm_lts_openai_background_options branch November 24, 2026 02:00
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