mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 13:29:19 +08:00
## 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
- [x] 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
- [x] Unit tests pass (`pytest`)
- [x] Linting passes (`ruff check`)
- [x] Type checking passes (`mypy`)
- [x] New test added
### Test Output
```text
$ 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
- [x] Self-reviewed
- [x] Tests added and passing
- [x] I did **not** edit `CHANGELOG.md`
<!-- devin-review-badge-begin -->
---
<a href="https://app.devin.ai/review/headroomlabs-ai/headroom/pull/2468"
target="_blank"><picture><source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img
src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4"
alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
---------
Co-authored-by: JerrettDavis <mxjerrett@gmail.com>