litellm/tests
joshua-berri a479cbb0c2
fix(caching): preserve caller message limits across chat bridges (#54500)
* fix(caching): count the caller's messages for max_messages on the chat completion bridges

responses() and anthropic.messages on providers that bridge to completion()
checked max_messages against the translated chat messages, so 5 Responses
items with grouped function calls were cached and 3 Anthropic messages with
3 tool results never were. Each bridge now stamps the caller's count into
the inner call's cache controls as a frozen CallerMessageCount, which the
cache gate reads before counting the request. A count an outer bridge
already stamped is kept, a forged int or dict under the key is ignored,
and string Responses input stays unstamped so it keeps its current gate.

* test(caching): cover string input, system prompts and async writes on the chat completion bridges

Restrict the cache to completion call types so the outer Responses and
Messages caches cannot hide the inner gate, and check that string Responses
input keeps its chat message count at max_messages 0 and 1, that a separate
system prompt is not a caller message, and that async Messages under the
limit is cached. Async tests now await cache writes and flush the logging
worker in a finally block.

---------

Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com>
2026-11-25 13:06:17 -08:00
..
_support fix(gemini): return an error instead of an empty 200 when a Gemini image request gets no image (#29125) 2026-11-25 20:55:23 +00:00
audio_tests
base_sdk_tests fix(packaging): ship the license public key in the litellm-proxy sdist (#52970) 2026-11-19 23:18:32 +00:00
basic_proxy_startup_tests
benchmarks fix(guardrails): classify only the frames each read completes in Presidio's first-frame wait (#54379) 2026-11-25 11:15:49 +00:00
code_coverage_tests fix(anthropic): map /v1/messages fields onto OpenAI Responses equivalents or reject them (#54173) 2026-11-25 19:30:01 +00:00
documentation_tests
e2e refactor(ui): move MCP Tool Search, MCP Semantic Filter, and Web Search Interception settings onto the form kit (#54449) 2026-11-25 11:35:15 -08:00
e2e_harness test(e2e): move the Claude Code matrix to Opus, Sonnet and Haiku 5.5, Fable 5.2 and GPT-6 (#54305) 2026-11-25 01:47:03 +00:00
fixtures
harness_e2e
integration fix(gemini): return an error instead of an empty 200 when a Gemini image request gets no image (#29125) 2026-11-25 20:55:23 +00:00
rust-python-harness fix(gateway): serve messages drop, summary and timeout settings like Python (#51236) 2026-11-25 09:26:12 +00:00
test_litellm_rust feat(anthropic-messages): per-deployment deferred_tools handling on the /v1/messages bridge (#54183) 2026-11-25 17:14:28 +00:00
typing
unit fix(caching): preserve caller message limits across chat bridges (#54500) 2026-11-25 13:06:17 -08:00
windows_tests
__init__.py
_fake_openai_endpoint_server.py
_flush_vcr_cache.py
_live_test_helpers.py
_master_key.py
_module_state.py
_openai_record_replay_proxy.py
_process_helpers.py
_vcr_conftest_common.py
_vcr_redis_persister.py
_wait_helpers.py
_ws_vcr.py
AGENTS.md
capturing_transport.py
eval_swe_bench.py
fake_openai_endpoint.py
gettysburg.wav
large_text.py
openai_batch_completions.jsonl
pyrightconfig.json
README.MD
test_logging.conf
test_rust_python_harness.py
VCR_TESTING.md
white_100x100.png

In total litellm runs 1000+ tests

[02/20/2025] Update:

To make it easier to contribute and map what behavior is tested,

we've started mapping the litellm directory in tests/unit

This folder can only run mock tests.