litellm/tests/test_litellm/integrations
Krrish Dholakia 386f334fee
Prompt Compression - add it to the proxy (#25729)
* refactor: new agentic loop event hook

simplifies how to create logic for tool based multi llm calls

* fix: compress - make it work on anthropic input as well

* fix(compress.py): working prompt compression for claude code

ensures claude code messages can run through proxy easily

* docs: add agentic loop hook guide

* docs: add agentic_loop_hook to sidebar

* fix: fix multiple arguments error

* fix: fix tool call loop for compression on streaming /v1/messages

* fix: fix linting errors

* fix: fix ci/cd errors

* feat(litellm_pre_call_utils.py): use claude code session for litellm session id

allows claude code logs to be stitched together, making it easy to know they were all part of the same conversation

* fix: suppress incorrect mypy warning rE: module

* revert: drop PR's changes to litellm/proxy/_experimental/out/

Restores the 34 HTML files under _experimental/out/ to their pre-PR
paths (X/index.html -> X.html). All renames are R100 (content
unchanged); no other files are touched.

* fix: address greptile review comments on PR #25729

- Skip ``kwargs["tools"] = []`` injection when compression is a no-op —
  Anthropic Messages rejects empty tool arrays on requests that did not
  originally declare tools.
- Move agentic-loop safety guards (fingerprint cycle / max depth) out of
  the per-callback try/except so they propagate instead of being swallowed
  by the generic exception handler. Extracted _check_agentic_loop_safety.
- Gate generic ``x-<vendor>-session-id`` capture behind the
  LITELLM_CAPTURE_VENDOR_SESSION_HEADERS env var (off by default) to
  preserve backwards compatibility; explicit x-litellm-* headers are
  unaffected.
- Fix monkeypatch target in pre-call-hook test to patch the actual
  module-level binding
  (litellm.integrations.compression_interception.handler.compress).
- Add regression tests for empty-tools skip and opt-in session capture.

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

* revert: drop LITELLM_CAPTURE_VENDOR_SESSION_HEADERS flag

Generic x-<vendor>-session-id header capture is a new feature and only
runs *after* the explicit x-litellm-trace-id / x-litellm-session-id
checks, so it does not change behavior for any existing caller that was
already using the LiteLLM headers — no backwards-incompatibility to gate.

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

* refactor(compress): replace input_type with CallTypes call_type

Drop the bespoke ``CompressionInputType`` literal and use the existing
``litellm.types.utils.CallTypes`` enum instead.  ``litellm.compress()``
now takes ``call_type: Union[CallTypes, str]`` (default
``CallTypes.completion``) — no new concept to learn, and the enum is
already the way the rest of the codebase talks about request shapes.

Supported values: ``completion`` / ``acompletion`` (OpenAI chat-completions
shape) and ``anthropic_messages`` (Anthropic structured content blocks).

Updated: compress(), the compression_interception handler, tests, docs,
and the two eval scripts.

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-20 15:08:00 -07:00
..
arize style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
azure_storage style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
bitbucket style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
cloudzero style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
compression_interception Prompt Compression - add it to the proxy (#25729) 2026-04-20 15:08:00 -07:00
datadog style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
dotprompt style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
focus style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
gcs_bucket style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
gcs_pubsub
gitlab style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
langfuse style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
levo style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
litellm_agent Agent Builder - support new experimental agent builder, to ensure agents pass compliance checks (#21817) 2026-02-21 15:32:47 -08:00
open_telemetry/data
SlackAlerting style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
websearch_interception Prompt Compression - add it to the proxy (#25729) 2026-04-20 15:08:00 -07:00
test_agentops.py
test_anthropic_cache_control_hook.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_athina.py
test_azure_sentinel.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_braintrust_logging.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_braintrust_span_name.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_custom_guardrail_recursion.py fix: recursive pydantic issue (#19531) 2026-01-22 19:56:41 -08:00
test_custom_guardrail.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_custom_prompt_management.py
test_deepeval.py
test_langfuse_otel.py fix: prevent sys.modules["langfuse"] import failures in langfuse unit tests 2026-02-18 08:22:23 -03:00
test_langfuse.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_langsmith_init.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mlflow.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_openmeter.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_opentelemetry_dynamic_imports.py Make grpc dependency optional (#19447) 2026-01-20 19:03:52 -08:00
test_opentelemetry.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prometheus_cache_metrics.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prometheus_client_ip_user_agent.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prometheus_invalid_key_filtering.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prometheus_labels.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prometheus_metric_name_consistency.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prometheus_missing_metrics.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prometheus_none_metadata.py fix: guard against None metadata in prometheus metrics (#21489) 2026-02-18 12:40:45 -08:00
test_prometheus_queue_guardrail_metrics.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prometheus_services.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prometheus_spend_logs_metadata.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prometheus_stream_label.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prometheus_user_team_metrics.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_responses_background_cost.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_s3_v2.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_weave_otel.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00