litellm/tests/unit/integrations
zoveki bf723ef711
fix(vertex_ai): cache the whole conversation prefix up to the cache_control block so Gemini sees turns in order (#54434)
* fix(vertex_ai): cache the whole conversation prefix up to the cache_control block so Gemini sees turns in order

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(vertex_ai): assert the exact cached prefix and remaining turns

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(vertex_ai): send a fully marked request uncached so Gemini's implicit cache serves it

An explicit cache serves only its exact prefix, so a client that moves its mark to the newest turn created and paid for a new cache every turn that no later call read.

* fix(vertex_ai): send web images in cached turns inline since Gemini caches reject web URLs

Moving the turns before a cache_control mark into the Gemini cache put their https image parts into the cachedContents create call, which AI Studio and Vertex both reject, so those requests got a 400. The cached prefix now inlines web media the way AI Studio's normal request path does, while the cache key still comes from the original messages. When the proxy cannot fetch one of those images, the request skips the explicit cache and goes out as before, so Vertex still fetches the URL itself

* fix(vertex_ai): keep web links Vertex fetches itself out of context caches

Building a context cache now downloads only the media the provider's own
request downloads, and only from conversation turns, since a system message
reaches the cache as text alone

Vertex fetches an https link with a known media type itself, and its
cachedContents call takes only gs:// links, so a cached turn holding such a
link now skips the explicit cache and the request goes out as before. A
download that fails now fails the request once, as the main request would,
instead of skipping the cache and downloading again

* fix(vertex_ai): inline media in a cached system prompt sent as a turn

A model without system message support gets its system prompt as a user turn in the cache, so its web media now downloads into the cache like any other turn's, and on Vertex a web link there skips the cache

* fix(vertex_ai): convert cached turns with the same request settings as the rest of the request

The cached-turn conversion rebuilt litellm_params from drop_params alone, so it
read different request settings than the uncached turns. Pass the request's
litellm_params through so both conversions see the same vertex_project and
vertex_credentials when a caller supplies them

Also types the test helper's optional_params as dict[str, object]

* fix(vertex_ai): keep v1 Files API links in Gemini context caches

A cached prefix holding a generativelanguage v1/files URI skipped the explicit cache, since only the v1beta prefix was treated as a Files API link

* fix(vertex_ai): cache the system prompt alone when the marked block leaves only system messages, and build media caches off the event loop

* fix(vertex_ai): cache the whole marked prefix unless the system prompt can hold a cache alone or the mark follows an unmarked turn, and keep one cache when only the newest turn's mark sets a TTL

* fix(vertex_ai): cache a single marked turn with its system prompt, and cache the system prompt alone when Gemini cannot take the marked turns

A system prompt is cached alone ahead of a newest-turn mark only when it carries its own mark, so a marked document after a big unmarked system prompt, and a marked turn beside big tools with no system prompt, go into the cache again. When the marked prefix ends on a model turn or links web media Gemini fetches itself, the system prompt is cached alone instead of skipping the cache.

* test(vertex_ai): mock the GCS, token, and image HTTP calls instead of LiteLLM's own fetch helpers

The extensionless gs:// tests now answer the GCS metadata and Google token calls with respx and responses, so a broken credential path fails them, and the web image fixture injects an HTTP client instead of replacing safe_get

* fix(vertex_ai): cache a request that marks both its system prompt and its turn whole again, as main does

---------

Co-authored-by: mateo <277851410+mateo-berri@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-25 21:26:15 +00:00
..
arize refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
azure_storage
bitbucket refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
clickhouse feat(lens): treat Lens's own calls as ordinary calls labeled lens-signals and remove x-lens-internal (#53163) 2026-11-20 13:01:03 -08:00
cloudzero
code_interpreter_interception fix(tool_choice): accept the Responses API's flat allowed_tools layout on chat completions (#50467) 2026-11-10 13:04:06 -08:00
compression_interception fix(anthropic): stream /v1/messages text before an internal retrieve tool call (#53658) 2026-11-23 05:17:36 +00:00
custom_logger_v2 fix(realtime): enforce TPM limits during realtime sessions (#53689) 2026-11-24 05:15:04 -08:00
datadog fix(datadog): send DD_TAGS on Datadog logs and LLM Observability spans (#52415) 2026-11-18 20:27:30 +00:00
dotprompt
email_alerting feat(alerts): add management controls and opt-in daily summaries (#51418) 2026-11-12 10:06:07 -08:00
focus feat(focus): upgrade FOCUS export to the 1.5 Cost and Usage schema (#52105) 2026-11-16 15:43:15 -08:00
gcs_bucket
gcs_pubsub feat(responses): store each bridged turn's path to the root so a fork replays only its ancestors (#49519) 2026-11-23 12:43:11 -08:00
generic_api feat(logging): add luca to the generic API compatible callbacks (#53899) 2026-11-23 19:13:09 -08:00
gitlab
helicone
langfuse fix(otel v2): stop legacy langfuse loggers sending to refused key/team hosts (#51344) 2026-11-16 11:34:20 -08:00
lens feat(lens): provision a model key for embedded Lens (#53900) 2026-11-23 18:18:53 -08:00
levo
litellm_agent
mavvrik_focus
newrelic
open_telemetry refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
opik refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
otel feat(otel): add option to disable background service spans (#54478) 2026-11-25 12:28:04 -08:00
pointfive
prompt_cache_alerts test: stabilize the flaky prompt cache detector unit tests (#52671) 2026-11-18 14:47:18 -08:00
s3_v2_golden test(s3-log): record output_cost_per_image_token_flex in the s3_v2 golden payloads (#54334) 2026-11-25 03:07:02 +00:00
SlackAlerting fix(alerting): retire completed requests and prevent hanging alert starvation (#54493) 2026-11-25 13:05:51 -08:00
ternary
vantage
vector_store_integrations ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
websearch_interception fix(messages): answer 400 for a non-string user or system text block and keep count_tokens in step with inference (#54165) 2026-11-25 00:48:41 +00:00
zerobus
__init__.py
conftest.py
rubrik_test_helpers.py
s3_v2_rust_support.py refactor(s3-log): move the rust-backed s3 logger from s3_v3 to s3_v2 (#51893) 2026-11-14 22:24:23 -08:00
test_agentops.py
test_anthropic_cache_control_hook.py fix(vertex_ai): cache the whole conversation prefix up to the cache_control block so Gemini sees turns in order (#54434) 2026-11-25 21:26:15 +00:00
test_argilla.py
test_athina.py
test_azure_sentinel.py
test_braintrust_logging.py
test_braintrust_span_name.py
test_custom_callback_input.py
test_custom_guardrail.py fix(guardrails)!: close gaps in bedrock tool call and tool description scans (#54169) 2026-11-25 06:56:15 +00:00
test_custom_guardrail_post_call_once.py feat(custom-logger-v2): add types, dispatcher and route callback call sites (step 0) (#51214) 2026-11-13 22:08:05 +00:00
test_custom_guardrail_recursion.py
test_custom_logger.py feat(custom-logger-v2): add types, dispatcher and route callback call sites (step 0) (#51214) 2026-11-13 22:08:05 +00:00
test_custom_prompt_management.py refactor(typing): clear 1146 basedpyright Any errors across 365 files (#52768) 2026-11-21 04:25:33 +00:00
test_customer_budget_webhook.py fix(proxy): alert on customer org, customer team, and customer member budgets (#51579) 2026-11-13 09:16:33 -08:00
test_deepeval.py
test_dynamodb.py
test_email_alerting.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
test_galileo.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
test_guardrail_logging_sync.py
test_helicone.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_humanloop.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
test_lago.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
test_langfuse.py
test_langfuse_otel.py fix(otel v2): stop legacy langfuse loggers sending to refused key/team hosts (#51344) 2026-11-16 11:34:20 -08:00
test_langsmith.py
test_langsmith_init.py
test_langtrace.py fix(otel): serialize pydantic Message objects in langfuse_otel, weave_otel and langtrace (#46845) 2026-11-10 14:50:39 -08:00
test_lunary.py
test_mlflow.py
test_openmeter.py
test_opentelemetry.py fix(otel): emit a span for every failed retry and fallback attempt (#50310) 2026-11-17 14:38:25 -08:00
test_opentelemetry_dynamic_imports.py
test_opentelemetry_request_spans.py
test_opik_utils.py
test_otel_guardrail_violation_spans.py
test_otel_team_attributes_matrix.py
test_performance_alert_notifications.py feat(alerts): add management controls and opt-in daily summaries (#51418) 2026-11-12 10:06:07 -08:00
test_posthog.py
test_prefix_block_hashes.py feat(proxy): opt-in prefix block hashes in spend logs for workload replay (#52120) 2026-11-16 22:52:42 -08:00
test_prometheus_api_promql_escape.py
test_prometheus_budget_metric_guard.py
test_prometheus_budget_metrics_db_lookups.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_prometheus_budget_metrics_timeout.py
test_prometheus_cache_metrics.py
test_prometheus_caller_identity.py
test_prometheus_carried_budget_state.py refactor(redis): move per-request miss, settlement and shutdown-drain tracking from Python into Rust (#51384) 2026-11-20 17:57:37 +09:00
test_prometheus_client_ip_user_agent.py
test_prometheus_custom_metadata_label_counts.py fix(prometheus): emit every declared label on litellm_deployment_cooled_down (#54488) 2026-11-25 11:39:52 -08:00
test_prometheus_deployment_state_proxy_rejects.py 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
test_prometheus_end_user_cardinality.py
test_prometheus_input_sequence_length_label.py
test_prometheus_invalid_key_filtering.py feat(github_copilot): support GitHub App authentication with PEM upload (#51427) 2026-11-14 10:33:20 -05:00
test_prometheus_labels.py 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
test_prometheus_mcp_tool_metrics.py
test_prometheus_media_generation_metrics.py
test_prometheus_metric_name_consistency.py feat(proxy): send gateway model calls to Lens as traces when the Lens store is connected (#53042) 2026-11-20 10:12:08 -08:00
test_prometheus_metrics_endpoint.py
test_prometheus_missing_metrics.py
test_prometheus_none_metadata.py
test_prometheus_overhead_with_guardrails.py
test_prometheus_queue_guardrail_metrics.py
test_prometheus_rate_limit_labels.py
test_prometheus_remaining_tokens_router_fallback.py
test_prometheus_requested_model_cardinality.py
test_prometheus_series_cardinality.py
test_prometheus_service_tier_label.py fix(bedrock): answer 400 for service tiers Bedrock cannot serve, forward reserved (#50516) 2026-11-14 01:33:57 +00:00
test_prometheus_services.py
test_prometheus_spend_capture_rate.py
test_prometheus_spend_logs_metadata.py
test_prometheus_stream_label.py
test_prometheus_token_detail_metrics.py
test_prometheus_user_team_metrics.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_prometheus_zero_cost_metric.py
test_prompt_layer.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
test_prompt_manager_ssti.py
test_responses_background_cost.py
test_rubrik.py feat(customer portal): set budgets per customer and gateway app (#52477) 2026-11-18 17:31:03 +00:00
test_s3.py
test_s3_v2_native.py test: fix four flaky router and s3 log unit tests (#53034) 2026-11-20 18:27:51 +00:00
test_s3_v2_rust.py test(s3-log): wait for the drop warning record before checking it (#53842) 2026-11-23 17:59:09 +00:00
test_s3_v2_strip_writer.py refactor(s3-log): move the rust-backed s3 logger from s3_v3 to s3_v2 (#51893) 2026-11-14 22:24:23 -08:00
test_shadow_eval_logger.py feat(shadow-eval): add optional rubric grades (#52321) 2026-11-17 12:04:31 -08:00
test_sqs.py
test_wandb.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
test_weave_otel.py fix(otel): serialize pydantic Message objects in langfuse_otel, weave_otel and langtrace (#46845) 2026-11-10 14:50:39 -08:00