Skip to content

fix(backends): forward the standard service_tier param (litellm + anyllm)#2468

Open
chopratejas wants to merge 1 commit into
mainfrom
tejas/service-tier-passthrough
Open

fix(backends): forward the standard service_tier param (litellm + anyllm)#2468
chopratejas wants to merge 1 commit into
mainfrom
tejas/service-tier-passthrough

Conversation

@chopratejas

Copy link
Copy Markdown
Collaborator

Description

service_tier is a standard provider request field (OpenAI flex/default/priority, Anthropic auto/standard_only), but the SDK-translation backends rebuilt the upstream request from a fixed field whitelist and silently dropped it — so a client that set service_tier had it discarded on --backend litellm/anyllm. The direct passthrough already forwards it; this makes the translation backends do the same, alongside temperature/top_p/tools.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

  • backends/litellm.py (Anthropic path): forward service_tier when present (the OpenAI path already forwards unconsumed fields via _build_openai_extra_body).
  • backends/anyllm.py: add service_tier to the forwarded params (both the Anthropic whitelist and the OpenAI param list).

Testing

  • Unit tests pass (pytest)
  • Linting passes (ruff check)
  • Type checking passes (mypy)
  • New test added

Test Output

$ python -m pytest tests/test_backend_anyllm.py -q
16 passed in 2.51s

$ ruff check headroom/backends/litellm.py headroom/backends/anyllm.py
All checks passed!

$ mypy headroom/backends/anyllm.py headroom/backends/litellm.py   # 0 new errors

Real Behavior Proof

  • Environment: local, FakeAnyLLM instance capturing acompletion kwargs.
  • Steps: send_message({..., "service_tier": "standard_only"}).
  • Observed: instance.calls[0]["service_tier"] == "standard_only" — the param reaches the SDK call (previously absent).
  • Not tested: live provider round-trip (no keys in CI); relies on the SDK forwarding standard params.

Checklist

  • Self-reviewed
  • Tests added and passing
  • I did not edit CHANGELOG.md

…llm)

The direct passthrough already forwards service_tier; the SDK-translation
backends dropped it (fixed field whitelists). Forward it like temperature/top_p
so a client's standard service_tier (OpenAI flex/priority, Anthropic
auto/standard_only) reaches the provider through any backend. Test: anyllm
forwards service_tier to the SDK completion call.
@github-actions

Copy link
Copy Markdown
Contributor

PR governance

This PR does not yet satisfy the required template fields:

  • Missing required section Review Readiness.
  • Fill in Real Behavior ProofExact command / steps.
  • Fill in Real Behavior ProofObserved result.
  • Check I have performed a self-review before requesting human review.
  • Check This PR is ready for human review or convert the PR back to draft.

Please update the PR body, or move the PR back to draft while it is still in progress.

@github-actions github-actions Bot added the status: needs author action Pull request body or readiness checklist still needs author updates label Jul 21, 2026

@JerrettDavis JerrettDavis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This needs one more change before approval.

The LiteLLM Anthropic translation path now forwards service_tier in send_message, but the matching stream_message path still omits it. That leaves streamed Anthropic-format requests through --backend litellm with the same silent-drop behavior this PR is fixing for non-streaming requests.

Please add the same if "service_tier" in body: kwargs["service_tier"] = body["service_tier"] handling to LiteLLMBackend.stream_message, and add/extend a LiteLLM-focused test so both the send and stream Anthropic translation paths are covered. The any-llm coverage is useful, but it does not protect the LiteLLM path where the remaining omission is.

@codecov-commenter

codecov-commenter commented Jul 21, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 33.33333% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
headroom/backends/anyllm.py 50.00% 1 Missing and 1 partial ⚠️
headroom/backends/litellm.py 0.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: needs author action Pull request body or readiness checklist still needs author updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants