litellm/tests/integration/observability
edvinsq 72b33f4e64
fix(responses): refuse a previous_response_id follow-up whose stored turns are redacted (#54636)
* fix(responses): refuse previous_response_id replay of turns stored redacted

With turn_off_message_logging on, spend logs keep only redacted-by-litellm
placeholders, so a bridged previous_response_id follow-up replayed them and the
model answered without the earlier turns. The bridge now answers 400 with
OpenAI's previous_response_not_found code, naming the id and asking for the
history in input, unless a compaction summary in the input replaces it

* fix(responses): import BadRequestError directly in the redacted replay refusal

The helper's return annotation read litellm.BadRequestError while litellm was still
initializing, so importing litellm on Python 3.12 failed with a circular import

* fix(responses): skip router fallbacks for the redacted replay refusal

A fallback deployment never holds the earlier turns either, so falling back only added a futile upstream call. Detection now also requires the blank prompt and input that redaction writes.

* test(integration): expect the redacted replay refusal in the custom logger redaction test

* fix(router): skip fallbacks for the redacted replay refusal in the rust core

* fix(router): keep the redacted replay refusal from cooling down or failing the deployment

A refused previous_response_id follow-up is the caller's stored history, not a deployment fault, so it now counts as declined: allowed_fails_policy never cools the deployment down for it and Prometheus no longer marks the deployment as an outage

* fix(responses): name previous_response_id on the input_tokens refusal for turns stored redacted

* fix(router): end retries for the redacted replay refusal in the rust core

* fix(responses): handle the redacted replay refusal like the unknown previous response refusal

PreviousResponseNotReplayableError now subclasses UnknownPreviousResponseError, so the router, cooldowns,
SDK retries, Slack alerts and background polling treat it the same way, and the per-consumer special
cases are gone. A follow-up that resends the earlier turns in input is no longer refused

* fix(responses): refuse a redacted replay read back from cold storage, and let fallbacks reach a provider that holds the response

The redacted turn check now reads the messages marker with empty input and prompt, which matches both the spend log row and the logging payload kept in cold storage. The refusal is built through previous_response_refusal, so a provider-held response id lets the fallback walk go on while a bridge-made id ends the call, the same as the not found refusal

* fix(responses): let only a restarted conversation past the redacted replay refusal

A follow-up on turns stored redacted went through whenever its input held any
assistant reply or tool call, so a partial resend still answered from placeholder
turns, and a tool loop got a 400 or a 200 depending on whether it echoed the call.
The refusal now passes input that starts with a user message ahead of its first
earlier reply, or that carries a compaction item

A conversation resent over redacted turns now replaces them the way a compaction
item does, so the provider no longer gets the placeholder turns ahead of it, and a
resent tool loop no longer fails at Anthropic on the replayed tool call

The message no longer blames message logging, since the redaction header stores
the same rows

* fix(responses): count resent replies per replayed turn and restart the replay at a stored resend

A follow-up on redacted turns now passes only when its input holds at least one earlier reply per replayed turn, so a few-shot example no longer stands in for a longer conversation. A stored turn that resent the conversation over redacted turns becomes the replay start, so its plain follow-ups replay from it, keeping earlier system and developer messages. A turn read back from cold storage keeps its conversation in `messages`, so the resend check and the replay read that when `input` is missing

* fix(responses): count the replies a stored resend already held when checking a later resend

After a stored turn resent the conversation over redacted turns, a later follow-up on a redacted turn passed as a resend with one reply per turn since that stored turn, so it could leave out the exchanges the stored turn resent. The count a resend must reach now starts from the replies that stored turn, or the first stored turn, already held

* fix(responses): ignore hosted items when counting resent replies and keep the stored input key on replay

A hosted tool search or reasoning item between two parts of one reply no longer splits it into two resent replies, so a resend that skips a redacted turn is refused instead of dropping that turn

A turn rebuilt from cold storage keeps its messages key when earlier instructions are merged into it, so its long tool calls are still renamed to the shortened name the provider was sent

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-30 21:08:16 +00:00
..
_azure_storage_support.py fix(azure_storage): name Data Lake objects without base64 padding or slashes (#43914) 2026-09-30 18:17:13 -07:00
_langfuse_otel_metadata_support.py test(observability): allowlist the key Langfuse collector host in the OTel v2 console test (#52157) 2026-11-17 00:13:41 +00:00
_logging_only_scope_support.py test(integration): fix four flaky integration tests (#49554) 2026-11-02 09:23:17 -08:00
_openinference_support.py fix(proxy): send finish_reason null on every in-progress streamed chat chunk (#53876) 2026-11-26 08:08:44 +00:00
_s3_v2_support.py fix(s3_v2): upload fresh events first, drop terminal failures and hour-old retries by default, opt-in adaptive concurrency (#43022) 2026-09-26 14:58:28 -07:00
_ternary_support.py feat(focus): add ternary destination for FOCUS export (#46106) 2026-10-12 22:52:40 -07:00
azure_dispatch_support.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
conftest.py test(integration): scope the signoz, otel conversation id, and series cap proxy fixtures to their module (#48965) 2026-10-29 03:28:39 -07:00
logging_worker_drain_canary.py test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00
test_akto_logging_only.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_anthropic_cache_control_hook_real_io.py 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
test_anthropic_overloaded_failure_signals.py fix(proxy): answer an upstream overload with 503 server_is_overloaded on OpenAI routes (#49993) 2026-11-04 16:37:55 -08:00
test_apply_guardrail_endpoint.py fix(proxy)!: label shared-handler errors the way the route catch-alls do (#39555) 2026-10-30 06:58:05 -07:00
test_arize_key_credential_reference.py fix(proxy): normalize metadata logging and tolerate malformed stored values (#51719) 2026-11-23 10:57:37 -08:00
test_arize_otel_v2_openinference_chaos.py test(observability): reserve sink port throughout outage (#50100) 2026-11-04 21:07:21 +00:00
test_arize_otel_v2_openinference_family.py test(integration): repair tests that merged changes left stale (#50782) 2026-11-10 01:08:35 +00:00
test_arize_otel_v2_openinference_modes.py test(integration): size restart-mid-burst timeouts from the proxy boot budget (#49376) 2026-10-31 10:17:34 -07:00
test_arize_otel_v2_openinference_sad_edge.py fix(proxy)!: stop answering with the literal string "None" as error type and param on the proxy-server, auth, spend, and key health routes (#39540) 2026-10-29 18:20:52 -07:00
test_arize_otel_v2_openinference_spans.py fix(decisions): bill unpriced returned TypeSafe versions at the requested model and name a missing answers field (#47508) 2026-10-20 11:46:17 -07:00
test_azure_content_safety_audit.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_azure_content_safety_dispatch.py fix(guardrails): restore Azure guardrail get_user_prompt dispatch and allow logging (#44067) 2026-10-01 23:30:32 -07:00
test_azure_content_safety_dispatch_resilience.py test(integration): budget proxy restart tests from calibrated boot time (#49761) 2026-11-07 15:37:18 -08:00
test_azure_content_safety_endpoints.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_azure_storage_chaos.py test(integration): budget proxy restart tests from calibrated boot time (#49761) 2026-11-07 15:37:18 -08:00
test_azure_storage_client_ttl.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_azure_storage_file_names.py fix(azure_storage): keep client call ids from sharing one Data Lake file (#44099) 2026-10-01 23:23:37 -07:00
test_batch_line_items_cold_storage.py test(integration): fix seven CircleCI integration tests that race or assume a worker spread (#47001) 2026-10-16 22:45:29 +00:00
test_bedrock_converse_guardrail_rewrites.py fix(guardrails)!: preserve Bedrock Converse redactions and honor tool-only scans (#45874) 2026-10-17 20:38:14 -07:00
test_bedrock_converse_stream_post_call_guardrail.py test: update the spend tests that still expected the pre-ledger accounting queues (#50814) 2026-11-09 22:07:42 -08:00
test_bedrock_error_request_id.py fix(responses): preserve provider request IDs in streaming failure logs (#45453) 2026-10-16 00:29:11 -07:00
test_bedrock_guardrail_attachments.py fix(ci): isolate integration workers and repair test fixtures (#45863) 2026-10-11 01:56:02 -07:00
test_bedrock_invoke_stream_post_call_guardrail.py test(integration): bill the Bedrock invoke outage burst by the tokens each cut-off stream logged (#53239) 2026-11-21 01:18:02 +00:00
test_cache_hit_guardrail_metrics.py test(integration): repair release qualification timing and labels (#49737) 2026-11-02 18:02:28 -08:00
test_cache_hit_guardrail_metrics_chaos.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_callback_delivery.py test(integration): repair seven stale integration tests on main (#47600) 2026-10-20 11:21:04 -07:00
test_content_filter_logging_only.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_custom_logger_hook_counts.py fix(logging)!: fire one CustomLogger failure hook per async call outside the async flag list (#47124) 2026-10-20 15:19:14 -07:00
test_custom_logger_hook_counts_chaos.py fix(logging)!: fire one CustomLogger failure hook per async call outside the async flag list (#47124) 2026-10-20 15:19:14 -07:00
test_custom_logger_hook_counts_modes.py fix(logging)!: fire one CustomLogger failure hook per async call outside the async flag list (#47124) 2026-10-20 15:19:14 -07:00
test_custom_logger_hook_counts_post_call_block.py fix(logging)!: fire one CustomLogger failure hook per async call outside the async flag list (#47124) 2026-10-20 15:19:14 -07:00
test_custom_logger_hook_counts_vendors.py fix(logging)!: fire one CustomLogger failure hook per async call outside the async flag list (#47124) 2026-10-20 15:19:14 -07:00
test_custom_logger_redaction.py fix(responses): refuse a previous_response_id follow-up whose stored turns are redacted (#54636) 2026-11-30 21:08:16 +00:00
test_datadog_logging_delivery.py test: migrate legacy unit dirs and unrun folders into tests/unit, tests/integration and tests/e2e (#45940) 2026-10-11 06:24:57 -07:00
test_file_usage_counter_span.py test(integration): wait for the request span before counting file usage counter spans (#54992) 2026-11-28 20:50:50 +00:00
test_generic_guardrail_api_wire.py fix(guardrails): accept Gemini tools in generic_guardrail_api, add opt-in forward_messages_as_sent, name the error type on fail-open (#46338) 2026-10-16 14:52:35 -07:00
test_generic_guardrail_num_retries.py feat(guardrails): add num_retries to generic_guardrail_api for checks lost after connect (#46965) 2026-10-17 12:22:41 -07:00
test_grayswan_wire.py fix(guardrails): drop hop-by-hop headers from generic guardrail request_headers (#55080) 2026-11-29 10:16:32 -08:00
test_grayswan_wire_chaos.py test(integration): give chaos and timing tests a harness API and gate raw signals (#46031) 2026-10-12 05:27:33 -07:00
test_guardrail_attachment.py test: replace 61 live logging and otel tests with offline unit and integration coverage (#45362) 2026-10-08 15:55:57 -07:00
test_guardrail_effects.py test(guardrails): expect the content_filter finish on a blocked chat stream (#51281) 2026-11-12 00:57:46 +00:00
test_guardrail_load_balancing.py test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00
test_guardrail_pipeline_applied_header.py fix(guardrails): drop the response pipeline steps that never ran from x-litellm-applied-guardrails (#49264) 2026-10-30 17:00:44 -07:00
test_guardrail_spend_log_redaction_marker.py fix(spend-logs): store no redaction marker in guardrail fields when prompts are not stored (#53912) 2026-11-25 17:12:14 -08:00
test_guardrail_stream_scope.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_guardrail_stream_scope_chaos.py test(integration): remove BUG skips for 3 tests that pass on main (#47364) 2026-10-19 21:39:35 -07:00
test_guardrail_stream_scope_matrix.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_guardrail_timeout_all_providers.py feat(guardrails): add Wingback guardrail integration (#46136) 2026-10-12 22:18:10 -07:00
test_langfuse_delivery.py test(observability): expect the Langfuse media reference in a refused request's logged input (#54928) 2026-11-28 00:22:01 +00:00
test_langfuse_destination_span_scope.py feat(otel v2): proxy-level default langfuse_span_scope for key and team destinations (#51726) 2026-11-14 15:45:11 -08:00
test_langfuse_otel_console_output.py test(observability): allowlist the key Langfuse collector host in the OTel v2 console test (#52157) 2026-11-17 00:13:41 +00:00
test_langfuse_otel_legacy_destinations.py fix(otel)!: give key/team Langfuse destinations user, tags and session on OTel v2 without global Langfuse keys (#48718) 2026-10-29 12:19:08 -07:00
test_langfuse_otel_metadata_chaos.py fix(spend)!: save streamed /v1/responses spend rows under the encrypted resp_ id the client received (#49493) 2026-11-02 14:13:17 -08:00
test_langfuse_otel_metadata_clients.py fix(spend)!: save streamed /v1/responses spend rows under the encrypted resp_ id the client received (#49493) 2026-11-02 14:13:17 -08:00
test_langfuse_otel_metadata_destinations.py fix(langfuse otel): emit request metadata under langfuse.observation.metadata and langfuse.trace.metadata on the OTEL v2 Langfuse mapper (#42697) 2026-10-27 18:54:10 -07:00
test_langfuse_otel_metadata_identity.py fix(langfuse otel): emit request metadata under langfuse.observation.metadata and langfuse.trace.metadata on the OTEL v2 Langfuse mapper (#42697) 2026-10-27 18:54:10 -07:00
test_langfuse_otel_tenant_only.py fix(otel)!: give key/team Langfuse destinations user, tags and session on OTel v2 without global Langfuse keys (#48718) 2026-10-29 12:19:08 -07:00
test_langfuse_otel_trace_fields.py fix(langfuse_otel)!: derive trace-level name, input, output and tags on traces litellm starts (#42705) 2026-10-27 10:34:55 -07:00
test_langfuse_otel_v2_environment.py fix(otel): send the Langfuse environment, release and version on OTel v2 (#51385) 2026-11-14 11:40:35 -08:00
test_langsmith_logging_delivery.py test: migrate legacy unit dirs and unrun folders into tests/unit, tests/integration and tests/e2e (#45940) 2026-10-11 06:24:57 -07:00
test_langtrace_delivery.py test: update stale integration and guardrail e2e tests to intended behavior (#48665) 2026-10-28 01:11:25 +00:00
test_logging_only_scope_chaos.py test(observability): give K3 the calibrated proxy budget instead of a fixed 300s (#51592) 2026-11-13 11:18:32 -08:00
test_logging_only_scope_config.py fix(spend-logs): store no redaction marker in guardrail fields when prompts are not stored (#53912) 2026-11-25 17:12:14 -08:00
test_logging_only_scope_runtime.py test: update four stale integration and UI tests for intended behavior changes (#52108) 2026-11-16 13:20:21 -08:00
test_logging_worker_drain.py test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00
test_mixpanel_user_id.py feat(otel): add Mixpanel OpenTelemetry v2 preset callback (#49999) 2026-11-25 10:27:02 -08:00
test_otel_auto_router_model.py fix(otel): name the routed model on auto-router LLM spans (#50498) 2026-11-07 15:52:00 -08:00
test_otel_cache_hit_cost.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_otel_conversation_id.py fix(spend)!: save streamed /v1/responses spend rows under the encrypted resp_ id the client received (#49493) 2026-11-02 14:13:17 -08:00
test_otel_destination_metadata_keys.py feat(otel): let a team or key OTel v2 destination add its own request metadata keys (#50813) 2026-11-11 13:57:41 -08:00
test_otel_excluded_services.py test(integration): isolate shared proxy state behind six order-dependent flakes (#46172) 2026-10-13 09:55:11 -07:00
test_otel_excluded_services_matrix.py test(otel): keep proxy startup out of the per-test timeout in the excluded services matrix (#51759) 2026-11-14 01:05:05 +00:00
test_otel_failed_attempts.py fix(otel): emit a span for every failed retry and fallback attempt (#50310) 2026-11-17 14:38:25 -08:00
test_otel_responses_provider.py fix(responses): log the resolved provider on Responses API calls (#52622) 2026-11-18 22:34:16 +00:00
test_otel_team_capture_message_content.py test(integration): wait for the stalled-tenant root span and accept a bare POST name (#49406) 2026-10-31 12:24:33 -07:00
test_otel_team_request_metadata.py fix(otel): seed request metadata baggage for team-only OTel v2 destinations (#50373) 2026-11-06 14:47:48 -08:00
test_otel_team_sampling_across_pods.py fix(otel): decide per-team Arize sampling from the trace id so every pod agrees (#47468) 2026-10-26 11:44:30 -07:00
test_otel_text_completion_choices.py fix(otel): keep text completion choice fields beside the synthesized message (#42537) 2026-09-22 14:24:32 -07:00
test_otel_trace_response_header.py test: update stale integration and guardrail e2e tests to intended behavior (#48665) 2026-10-28 01:11:25 +00:00
test_otel_v1_request_trace.py fix(caching): key response cache by router model group in litellm_metadata (#44542) 2026-10-05 17:06:21 +00:00
test_ovalix_guardrail.py feat(ovalix)!: scan files, tool calls and tool results (#49309) 2026-10-31 17:01:12 -07:00
test_panw_airs_block_masked_response.py feat(guardrails): opt-in response_masked_data on PANW Prisma AIRS block (#46219) 2026-10-29 10:45:00 -07:00
test_passthrough_guardrail_scan_text.py fix(guardrails): exclude litellm_metadata from pass-through guardrail scan text (#48276) 2026-10-26 12:07:58 -07:00
test_passthrough_operation_name.py fix(otel): label configured pass-through routes litellm.passthrough and read the operation from the upstream (#48675) 2026-10-28 10:48:34 -07:00
test_passthrough_trace_context.py Preserve caller trace context on opted-in HTTP pass-through routes (#53275) 2026-11-27 00:09:57 +00:00
test_passthrough_upstream_error_chaos.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_passthrough_upstream_error_visibility.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_presidio_entity_masking.py fix(proxy)!: stop answering with the literal string "None" as error type and param on the proxy-server, auth, spend, and key health routes (#39540) 2026-10-29 18:20:52 -07:00
test_presidio_masking_endpoints.py fix(proxy): count generateContent spend under its own endpoint (#52701) 2026-11-18 16:50:56 -08:00
test_presidio_overlapping_spans.py fix(presidio): stop overlapping entity spans from corrupting numbered PII tokens (#47024) 2026-10-17 11:21:03 -07:00
test_presidio_streaming_output.py fix(anthropic): carry safeguard_results and stop_details in synthesized message_delta events (#46096) 2026-10-17 16:48:37 +00:00
test_prometheus_deployment_failure_api_provider.py fix(prometheus): label deployment failures with the deployment's provider instead of None (#47384) 2026-10-19 13:38:26 -07:00
test_prometheus_project_alias_label.py fix(prometheus): skip custom metadata labels a metric already carries (#46267) 2026-10-13 18:20:52 -07:00
test_prometheus_provider_auth_failure.py test(integration): wait for the success series before the stored-credential 401 (#53460) 2026-11-21 15:14:09 -08:00
test_prometheus_provider_auth_failure_chaos.py fix(prometheus): count provider-side 401s in LLM failure and deployment metrics (#46668) 2026-10-26 17:57:06 -07:00
test_prometheus_request_metrics.py test: replace 61 live logging and otel tests with offline unit and integration coverage (#45362) 2026-10-08 15:55:57 -07:00
test_prometheus_series_cap.py test(integration): fix the baseline accounting and series cap flakes (#51096) 2026-11-11 12:36:02 -08:00
test_prometheus_series_cap_chaos.py feat(docker)!: one shipped image and one entrypoint beside the Dockerfile (#43332) 2026-11-10 18:32:16 -08:00
test_prometheus_shared_custom_labels.py test(integration): wait on the right signal in five flaky integration contracts (#46737) 2026-10-15 13:48:51 -07:00
test_raw_response_callback_delivery.py fix(logging): stop keeping a full response copy nobody reads (#52524) 2026-11-18 11:51:01 -08:00
test_realtime_guardrail_translation.py test: migrate tests/llm_translation into unit, integration and e2e tiers (#45759) 2026-10-11 07:58:53 +00:00
test_s3_v2_flush_surfaces_rust.py feat(s3-log): replace the python s3_v2 logger with a rust callback (#51539) 2026-11-14 23:03:58 +00:00
test_s3_v2_partition_granularity_rust.py feat(s3-log): replace the python s3_v2 logger with a rust callback (#51539) 2026-11-14 23:03:58 +00:00
test_s3_v2_streaming_failure_dedupe_rust.py feat(s3-log): replace the python s3_v2 logger with a rust callback (#51539) 2026-11-14 23:03:58 +00:00
test_s3_v2_upload_fanout_rust.py feat(s3-log): replace the python s3_v2 logger with a rust callback (#51539) 2026-11-14 23:03:58 +00:00
test_signoz_delivery.py fix(spend)!: save streamed /v1/responses spend rows under the encrypted resp_ id the client received (#49493) 2026-11-02 14:13:17 -08:00
test_straiker_v3_platform.py feat(guardrails): straiker stream_mode, per-phase logging and prompt-block replies (#51401) 2026-11-14 13:50:05 -08:00
test_stream_error_alert_api_base.py fix(proxy): name the deployment in stream error alerts on chat, completions, responses and messages (#51034) 2026-11-11 22:50:23 +00:00
test_ternary_focus_export.py feat(focus): add ternary destination for FOCUS export (#46106) 2026-10-12 22:52:40 -07:00
test_weave_key_scoped_delivery.py test: move Sail, Weave and Presidio e2e tests to integration tests (#49533) 2026-10-31 18:31:01 -07:00
test_wingback_guardrail.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_xecguard_wire.py refactor(types): replace Any with proven types in 7 files (#43704) 2026-09-29 06:12:58 -07:00