Skip to content

fix: add supports_mid_conversation_system to bare first-party Claude cost-map keys - #36969

Merged
mateo-berri merged 1 commit into
BerriAI:litellm_internal_stagingfrom
oneKn8:fix-cost-map-mid-conversation-flag
Aug 20, 2026
Merged

mateo-berri merged 1 commit into
BerriAI:litellm_internal_stagingfrom
oneKn8:fix-cost-map-mid-conversation-flag

Conversation

@oneKn8

@oneKn8 oneKn8 commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Bare first-party keys (claude-opus-4-8, the 5 family) lack supports_mid_conversation_system
  • Regional and provider-prefixed variants of the same models carry it
  • A plain custom_llm_provider="anthropic" lookup reports the capability as unset

How it solves it:

  • Adds the flag to the 5 bare first-party entries in both cost-map files
  • Adds a sweep test so future first-party entries cannot miss it

User Flow

Before: a developer checking whether their model keeps mid-conversation system messages gets a wrong answer for first-party keys

  1. They call litellm.get_model_info(model="claude-opus-4-8", custom_llm_provider="anthropic")
  2. supports_mid_conversation_system comes back None, so their code treats a model that supports the feature as unsupported
  3. On a proxy serving anthropic/claude-opus-4-8, GET /model/info shows the same null under model_info
  4. The same call with model="vertex_ai/claude-opus-4-8" returns True, so the same model reports different capabilities per route

After: the same lookup answers consistently on every route

  1. They call litellm.get_model_info(model="claude-opus-4-8", custom_llm_provider="anthropic")
  2. supports_mid_conversation_system comes back True, matching the regional and provider-prefixed entries
  3. GET /model/info on the same proxy shows true for every anthropic/<bare key> deployment

Relevant issues

Surfaced by the reporter in #36559 (follow-up to #36968); this PR is the cost-map data fix only

Linear ticket

Part of LIT-5872 (https://linear.app/litellm-ai/issue/LIT-5872/hoisting-mid-conversation-system-reminders-on-pre-48-claude)

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

This is a capability-metadata fix. The flag is only read on the bedrock, vertex_ai, and azure_ai partner routes, whose entries already carry it, so no request bytes change for any model and a paid LLM call cannot demonstrate it. The user-visible surfaces are the SDK lookup and the proxy's /model/info, so both legs below drive those against a real proxy booted from each commit, with no mocks

Both legs use the same config: five deployments whose litellm_params.model is anthropic/<bare key>, LITELLM_LOCAL_MODEL_COST_MAP=True, master key sk-1234

Before, at 2bc9bb4 (merge base)

SDK lookup:

$ for m in claude-opus-4-8 claude-sonnet-5 claude-opus-5 claude-fable-5 claude-mythos-5; do LITELLM_LOCAL_MODEL_COST_MAP=True .venv/bin/python -c "import litellm; print('$m', litellm.get_model_info(model='$m', custom_llm_provider='anthropic').get('supports_mid_conversation_system'))"; done
claude-opus-4-8 None
claude-sonnet-5 None
claude-opus-5 None
claude-fable-5 None
claude-mythos-5 None

Proxy on port 44191 (confirmed free with lsof -nP -iTCP:44191 -sTCP:LISTEN before boot):

$ curl -s http://localhost:44191/model/info -H "Authorization: Bearer sk-1234" | jq -c '.data[] | {model_name, supports_mid_conversation_system: .model_info.supports_mid_conversation_system}'
{"model_name":"claude-opus-4-8","supports_mid_conversation_system":null}
{"model_name":"claude-sonnet-5","supports_mid_conversation_system":null}
{"model_name":"claude-opus-5","supports_mid_conversation_system":null}
{"model_name":"claude-fable-5","supports_mid_conversation_system":null}
{"model_name":"claude-mythos-5","supports_mid_conversation_system":null}

GET /v1/model/info with the same filter returned the same five null rows

After, at 4cd1c81 (PR head)

SDK lookup:

$ for m in claude-opus-4-8 claude-sonnet-5 claude-opus-5 claude-fable-5 claude-mythos-5; do LITELLM_LOCAL_MODEL_COST_MAP=True .venv/bin/python -c "import litellm; print('$m', litellm.get_model_info(model='$m', custom_llm_provider='anthropic').get('supports_mid_conversation_system'))"; done
claude-opus-4-8 True
claude-sonnet-5 True
claude-opus-5 True
claude-fable-5 True
claude-mythos-5 True

Proxy on port 43817 (confirmed free the same way):

$ curl -s http://localhost:43817/model/info -H "Authorization: Bearer sk-1234" | jq -c '.data[] | {model_name, supports_mid_conversation_system: .model_info.supports_mid_conversation_system}'
{"model_name":"claude-opus-4-8","supports_mid_conversation_system":true}
{"model_name":"claude-sonnet-5","supports_mid_conversation_system":true}
{"model_name":"claude-opus-5","supports_mid_conversation_system":true}
{"model_name":"claude-fable-5","supports_mid_conversation_system":true}
{"model_name":"claude-mythos-5","supports_mid_conversation_system":true}

GET /v1/model/info with the same filter returned the same five true rows

Both proxies also listed 58 unrelated deployments loaded from the dev database (the worktree .env sets DATABASE_URL); those rows are omitted above and are identical between legs

The new sweep test fails at the merge base (assert missing == [] reports all five keys) and passes at the head

Type

🐛 Bug Fix

Caveats (if any)

  • Data plus one sweep test only; no behavior code touched
  • Minor: the sweep test lives next to the flag's consumer tests in test_anthropic_experimental_pass_through_messages_handler.py rather than beside the existing shipped-backup sweep in tests/test_litellm/litellm_core_utils/test_get_model_cost_map.py; left as is since moving it buys nothing for a data fix
  • Minor: the test re-imports json, os, and litellm inside the function although the file already imports them at the top; harmless

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

  • 4cd1c81 passes /live-pr-risk

@greptile-apps

greptile-apps Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR aligns bare first-party Claude 4.8+/5 metadata with provider-prefixed variants so Anthropic model-info lookups report mid-conversation system-message support consistently.

  • Adds supports_mid_conversation_system: true to five bare Anthropic model entries in both synchronized cost maps.
  • Adds a sweep test requiring every matching first-party Anthropic cost-map entry to carry the capability flag.

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified.

The synchronized cost-map updates match the existing Claude capability generalization, and the new test accurately checks the affected first-party model family without introducing runtime or network behavior.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Adds the capability flag to the five intended bare Claude entries, consistently with the existing fallback generalization.
litellm/model_prices_and_context_window_backup.json Mirrors the root cost-map metadata changes in the packaged map used for local runtime lookups.
tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py Adds a targeted data-integrity sweep covering mapped first-party Anthropic entries matched by the existing capability rule.

Reviews (1): Last reviewed commit: "fix: add supports_mid_conversation_syste..." | Re-trigger Greptile

@codecov

codecov Bot commented Aug 14, 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 Aug 14, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing oneKn8:fix-cost-map-mid-conversation-flag (4cd1c81) with litellm_internal_staging (b9d2fd0)1

Open in CodSpeed

Footnotes

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

@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 4cd1c81. 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. Thanks for the contribution!

@mateo-berri
mateo-berri merged commit 6fcdea0 into BerriAI:litellm_internal_staging Aug 20, 2026
72 checks passed
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