Commit graph

789 commits

Author SHA1 Message Date
Sameer Kankute
929331bf83
fix(bedrock): custom tool schemas and missing tool names for Converse
Normalize JSON Schema type custom to object for Bedrock invoke and
_bedrock_tools_pt, ensure stable names for tools without name, and
avoid KeyError in the Anthropic messages adapter when translating
tools to OpenAI format for bedrock/converse.

Made-with: Cursor
2026-04-09 10:40:09 +05:30
Sameer Kankute
f8a2c9b13a
feat(bedrock): normalize custom tool JSON schema for Invoke and Converse
Anthropic/Claude Code use input_schema.type "custom"; Bedrock rejects it.
- Add normalize_json_schema_custom_types_to_object and use it for Invoke,
  chat invoke, and _bedrock_tools_pt (Anthropic input_schema + OpenAI params).
- Coerce invalid root types to object for Converse toolSpec.
- Tests for invoke transform, converse _bedrock_tools_pt, and unit helper.

Made-with: Cursor
2026-04-09 10:09:18 +05:30
yuneng-jiang
72fba093c8 Merge remote-tracking branch 'origin/main' into litellm_dev_sameer_16_march_week 2026-03-21 15:11:29 -07:00
yuneng-jiang
10b0139bf8
Merge branch 'main' into litellm_oss_staging_03_05_2026 2026-03-21 14:58:11 -07:00
Sameer Kankute
0673c57fef
Merge pull request #23939 from Sameerlite/Sameerlite/azure-ai-annotations
fix(azure-ai-agents): preserve annotations in Bing Search grounding responses
2026-03-20 23:33:08 +05:30
Sameer Kankute
ecfcf241c6
Merge pull request #24119 from BerriAI/main
merge main
2026-03-19 15:53:32 +05:30
Sameer Kankute
f29b4981a0 fix(prompting): preserve separator for assistant(tc)->assistant edge case
When scanning backward over counted messages, preserve old behavior for
adjacent assistant turns by inserting user_continue if the immediate
previous raw message is assistant. This handles malformed
assistant(tool_calls)->assistant(no-tool-calls) inputs without splitting
valid assistant(tool_calls)->tool chains.

Made-with: Cursor
2026-03-18 17:13:42 +05:30
Sameer Kankute
22fc08d602 fix(prompting): revert _insert_assistant_continue_message to adjacent-check logic
Restore backward-compatible behavior: only insert assistant_continue
between directly adjacent user messages, not across tool-call chains.
The _counts_for_alternation skip logic was a silent behavioral change
for [user, assistant(tc), tool, user] sequences.

Made-with: Cursor
2026-03-18 16:59:16 +05:30
Sameer Kankute
67f5ce9c7c address greptile review feedback (greploop iteration 1)
- Restore backward compat for leading assistant(tool_calls) — always prepend user_continue
- Replace partial assertions with full list assertion in trailing tool-call test

Made-with: Cursor
2026-03-18 16:41:26 +05:30
Sameer Kankute
0941e40363 fix(prompting): address greptile review - fix SyntaxError, restore backward compat, add trailing tool-call test
- Remove stray ): on line 303 (P0 SyntaxError)
- Restore backward-compatible trailing-assistant behavior (P1)
- Add test_ensure_alternating_roles_trailing_tool_call_assistant
- Keep role check alongside _counts_for_alternation (P2 is false positive)

Made-with: Cursor
2026-03-18 16:30:42 +05:30
Sameer Kankute
ae350ed370 Fix greptile comments 2026-03-18 16:10:33 +05:30
Sameer Kankute
f1421d1082 fix(prompting): preserve tool chains in alternation insertion
Avoid inserting assistant continue messages in the middle of assistant tool_call->tool chains by inserting before the next counted user turn, and add regression coverage for this edge case.

Made-with: Cursor
2026-03-18 15:55:51 +05:30
Sameer Kankute
3cdabff323 Fix greptile review 2026-03-18 15:45:09 +05:30
Sameer Kankute
b9266bb3b9 Fix ensure_alternating_roles for correct order 2026-03-18 15:25:57 +05:30
Sameer Kankute
6fe3188af0 fix(azure-ai-agents): accumulate annotations from multiple text items in streaming
- Fix bug where only last text item's annotations were preserved when
  thread.message.completed contained multiple text content items
- Accumulate annotations via extend() instead of overwriting
- Add test_azure_ai_agents_streaming_annotations_from_completed_message
- Add test_azure_ai_agents_streaming_accumulates_annotations_from_multiple_text_items

Addresses Greptile review on PR #23849

Made-with: Cursor
2026-03-18 09:04:00 +05:30
Sameer Kankute
8eb8756e84 fix: Preserve annotations in Azure AI Foundry Agents responses
Azure AI Agents with Grounding (e.g., Bing Search) include annotations
(citation URLs) in responses, but the handler was dropping them during
transformation. This fix:

- Extracts annotations from text content in agent responses
- Transforms them to OpenAI-compatible ChatCompletionAnnotation format
- Passes annotations through all completion paths (sync, async, streaming)
- Handles both polling and SSE streaming responses

Fixes #19126

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-17 15:55:41 +05:30
Awais Qureshi
84b4af40fa
fix(fireworks): skip #transform=inline for base64 data URLs (#23729)
* fix(fireworks): skip #transform=inline for base64 data URLs

Closes #23583

Appending #transform=inline to a data: URL corrupted the base64 payload,
causing binascii.Error (Incorrect padding) when Fireworks AI attempted to
decode the image. Data URLs are already inlined so the fragment is a no-op
anyway — guard both the str and dict image_url branches to skip the suffix
when the URL starts with "data:".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(fireworks): skip #transform=inline for base64 data URLs

  Closes #23583

* fix(fireworks): skip #transform=inline for base64 data URLs

  Closes #23583

* fix(fireworks): skip #transform=inline for base64 data URLs

  Closes #23583

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2026-03-16 22:30:18 -07:00
yuneng-jiang
8f56ddb9c6 Merge remote main into litellm_ci_optimize
Resolved conflict in test_claude_agent_sdk.py by keeping main's additions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 00:50:22 -07:00
yuneng-jiang
ccfe4b57d5 [Fix] Restore unconditional importlib.reload for llm_translation conftest
The xdist-conditional reload (manual reset in xdist mode) was missing
attributes that importlib.reload resets, causing Azure connection errors.
The original conftest used importlib.reload unconditionally (even under
xdist) and that worked on main. Restore that behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 00:35:02 -07:00
yuneng-jiang
f434cdbdce [Fix] Remove flush_cache from llm_translation conftest to prevent connection churn
The old conftest never flushed HTTP client cache. Adding flush_cache() before
every test forces new TCP connections to external APIs, causing transient
connection failures under xdist parallelism. Global state isolation is already
handled by _SCALAR_DEFAULTS reset.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 00:20:40 -07:00
yuneng-jiang
acfaea9d25 [Fix] Reset api_base/api_key in xdist conftest to prevent cross-test leakage
test_rerank.py sets litellm.api_base = "http://localhost:4000" which leaked
to all subsequent tests on the same xdist worker, causing connection failures
across every provider (Cohere, Azure, OpenAI, etc.).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 23:55:44 -07:00
yuneng-jiang
5db6aef834 [Fix] Restore xdist test isolation: capture true defaults and poll cooldowns
The revert of 9711e3adfe left xdist tests without proper state isolation.
Module-level assignments like `litellm.num_retries = 3` in 12+ test files
pollute shared globals, and the fixture was saving/restoring contaminated
values instead of resetting to true defaults.

- Capture true litellm defaults at conftest import time and reset before
  each test (local_testing + llm_translation)
- Make llm_translation/conftest.py xdist-safe (skip reload under xdist,
  add state isolation)
- Replace asyncio.sleep(2) with polling in cooldown handler tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 23:33:21 -07:00
yuneng-jiang
b4f7d11a82 Revert "Fix xdist test isolation: capture true defaults and poll instead of sleep"
This reverts commit 9711e3adfe.
2026-03-15 22:57:39 -07:00
yuneng-jiang
9711e3adfe Fix xdist test isolation: capture true defaults and poll instead of sleep
The conftest fixtures were saving/restoring the current (potentially
contaminated) values of litellm globals like num_retries instead of
resetting to true defaults. Under xdist, module-level assignments
(e.g. `litellm.num_retries = 3` in 12+ test files) pollute the
shared module state and leak across tests in the same worker.

- Capture true litellm defaults at conftest import time and reset
  before each test (local_testing + llm_translation)
- Make llm_translation/conftest.py xdist-safe (skip reload, add
  state isolation)
- Replace asyncio.sleep(2) with polling in cooldown handler tests
- Add @pytest.mark.flaky to tests making real API calls under xdist

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 22:27:26 -07:00
yuneng-jiang
beee329b26 Fix flaky test_gemini_image_generation_async by removing non-deterministic content assertion
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 17:58:00 -07:00
Sameer Kankute
6c3e036648
Merge branch 'main' into litellm_fix_responses_bridge_gpr-5.4 2026-03-14 21:43:17 +05:30
Chesars
5c1e5c2510 Merge main into litellm_oss_staging_03_05_2026 2026-03-14 00:42:39 -03:00
Chesars
2d33d6496b Merge branch 'upstream/main' into HEAD
# Conflicts:
#	tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py
2026-03-13 22:56:08 -03:00
yuneng-jiang
25e161a0fa fix(tests): remove test_completion_bedrock_claude_sts_oidc_auth and test_completion_bedrock_httpx_command_r_sts_oidc_auth that depend on external infra
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 11:53:53 -07:00
Sameer Kankute
a5bec4911f Fix _supports_reasoning_effort_level for responses bridge 2026-03-13 13:29:39 +05:30
yuneng-jiang
15075ef9ec fix(tests): update outdated model names in o1 and gemini tests
OpenAI retired o1-mini, o1-preview, gpt-4-0314, and gpt-4-32k from the model
cost map. Google renamed gemini-2.5-flash-image-preview to gemini-2.5-flash-image.
Updated tests to use current model names.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 22:50:52 -07:00
yuneng-jiang
f1a7e42577
Merge pull request #23485 from BerriAI/litellm_/sleepy-swirles
[Fix] Realtime websocket tests for websockets v15+ API
2026-03-12 15:02:18 -07:00
yuneng-jiang
3f0c7b5552 [Fix] Update realtime websocket tests for websockets v15+ API
Use explicit imports from websockets.exceptions (ConnectionClosedOK,
ConnectionClosedError) instead of the removed websockets.exceptions
attribute, and add openai/ model prefix so get_llm_provider resolves
the provider correctly in CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 14:40:48 -07:00
Chesars
4e6e1d8de8 merge: resolve conflicts with upstream staging (bedrock + mcp tests)
Keep both sets of tests: upstream's OAuth2 token injection test and
our case-insensitive tool matching tests. Use upstream's version of
the bedrock output_config test (more comprehensive).
2026-03-12 13:40:16 -03:00
Chesars
feed274aa3 Reapply "feat: add model_cost aliases expansion support"
This reverts commit 3d2df7e8b5.
2026-03-12 13:36:57 -03:00
Cesar Garcia
6bd7cd7573
Merge branch 'main' into litellm_oss_staging_03_11_2026 2026-03-12 10:43:08 -03:00
Sameer Kankute
374c35a6b7 Fix update deprecated model test 2026-03-12 18:34:15 +05:30
Chesars
1be6b31e2f merge: resolve conflicts between main and litellm_oss_staging_03_11_2026 2026-03-12 09:38:31 -03:00
Joe Reyna
ca910a8fa0
Replace broken Anthropic Skills API integration test with unit tests (#23325)
* Replace broken Anthropic Skills API integration test with unit tests

* Update tests/test_litellm/test_anthropic_skills_transformation.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: Aarish Alam <arishalam121@gmail.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-11 22:00:08 +05:30
Cesar Garcia
3d2df7e8b5
Revert "feat: add model_cost aliases expansion support" 2026-03-10 22:39:19 -03:00
Cesar Garcia
6bca746d23
Merge pull request #21601 from Chesars/feat/model-cost-aliases
feat: add model_cost aliases expansion support
2026-03-10 18:07:23 -03:00
Cesar Garcia
e4fddb9f24
Merge pull request #23093 from MaxwellCalkin/fix/thinking-blocks-interleave-23047
fix: preserve thinking block order with multiple web searches
2026-03-10 18:06:45 -03:00
Chesars
0680a97409 fix: handle list-content messages in thinking block interleaving
When assistant content is already a list containing thinking blocks
inline (not str/None), SEQUENTIAL MODE was still prepending all
thinking_blocks from provider_specific_fields, causing duplication
and breaking Anthropic's position-dependent signature verification.

Now detects if the content list already has thinking blocks and skips
the extend(thinking_blocks) to preserve the original interleaved order.

Addresses the correctness gap identified by Greptile review where
list-content messages bypass INTERLEAVED MODE.

Fixes: https://github.com/BerriAI/litellm/issues/23047
2026-03-10 12:48:30 -03:00
Sameer Kankute
88c4079b16 fix(skills): match zip folder name to skill name in SKILL.md for Anthropic API
Made-with: Cursor
2026-03-10 14:11:11 +05:30
yuneng-jiang
6fe82d3886
Merge pull request #23211 from BerriAI/litellm_/sharp-keller
[Fix] Skills API test failing with duplicate skill name 500
2026-03-09 17:13:29 -07:00
yuneng-jiang
af8f91ef66 [Fix] Use unique skill names in Skills API test to avoid duplicate-name 500s
The test_create_skill test was consistently failing in CI with a 500 from
Anthropic because the SKILL.md frontmatter always used the same hardcoded
name (test-skill-litellm). Since test_delete_skill is permanently skipped,
skills accumulate in the CI account, and re-creating with a duplicate name
triggers an Internal Server Error on Anthropic's side.

Fix: pass a timestamp-based unique_suffix to create_skill_zip so each run
produces a distinct skill name in the zip's SKILL.md frontmatter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:09:15 -07:00
Sameer Kankute
4b1929ce93 Fix mistral ocr failing test 2026-03-09 11:29:33 +05:30
Maxwell Calkin
95ecf9f46d test: add tests for thinking block interleaving with server tool calls 2026-03-08 01:35:03 -05:00
Ishaan Jaff
34984d22ae
fix(test): update openrouter image generation assertion for gemini-2.5-flash-image (#23070)
* fix(anthropic/skills): remove ?beta=true query param from Skills API URLs

Beta access is controlled via the anthropic-beta header (already set
to skills-2025-10-02), not a URL query param. The spurious ?beta=true
was causing 500 errors from Anthropic's server.

* fix(test): update openrouter image generation assertion to accept any image format

gemini-2.5-flash-image returns JPEG, not PNG. The assertion was hardcoded
to png after the model was swapped from gemini-2.5-flash-image-preview
(which returned PNG) in commit 34e8e972.
2026-03-07 16:52:04 -08:00
Varad Khonde
6d4a281ba0 fix(gemini): handle 'minimal' reasoning_effort param for gemini-3.1-flash-lite-preview 2026-03-06 00:26:45 +05:30