litellm/tests/test_litellm/proxy
Krish Dholakia 835ac240d2 Agents - assign tools (#22064)
* feat(proxy): add max_iterations limiter for agent session loops (#22058)

Adds a new proxy hook that enforces a per-session cap on the number of
LLM calls an agentic loop can make. Callers send a session_id with each
request, and the hook counts calls per session, returning 429 when the
configured max_iterations limit is exceeded.

- Uses Redis Lua script for atomic increment (multi-instance safe)
- Falls back to in-memory cache when Redis unavailable
- Follows parallel_request_limiter_v3 pattern
- Configurable via key metadata: {"max_iterations": 25}
- Session counters auto-expire via TTL (default 1hr)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add new code execution dataset

* feat(agent_endpoints/): allow giving agents keys

* fix: ui fixes

* feat: allow assigning mcp servers to agents

* fix: eliminate duplicate DB queries in MCP agent auth and N+1 in agent listing (#22110)

- Extract _get_agent_object_permission helper so _get_allowed_mcp_servers_for_agent
  and _get_agent_tool_permissions_for_server share a single DB fetch instead of
  each independently querying the same agent row (was 1+N queries per MCP request)
- Use include={"object_permission": True} on find_many in get_all_agents_from_db
  to eagerly load permissions in one query instead of N+1
- Use include={"object_permission": True} on create/update/find_unique in all
  agent CRUD operations, removing attach_object_permission_to_dict follow-up calls

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 18:15:17 +05:30
..
_experimental/mcp_server Agents - assign tools (#22064) 2026-03-03 18:15:17 +05:30
agent_endpoints tests 2026-02-13 22:01:28 -08:00
anthropic_endpoints [Fix] 404 Not Found on /api/event_logging/batch endpoint (#20504) 2026-02-05 10:58:08 -08:00
auth Revert "fix(vertex_ai): enable context-1m-2025-08-07 beta header (#21870)" (#21876) 2026-02-21 20:12:01 -08:00
client add a new feature fix to expose the team alias when authenticating th… (#17725) 2025-12-10 10:10:28 -08:00
common_utils fix: add .copy() to create_request_copy and tests for header caching 2026-03-03 18:14:54 +05:30
db feat(proxy): tool policies - auto-discover tools + policy enforcement guardrail (#22041) 2026-03-03 18:14:57 +05:30
discovery_endpoints fix(azure): preserve content_policy_violation error details from Azure OpenAI (#20883) 2026-02-10 22:47:03 -08:00
experimental/mcp_server Litellm fix GitHub action testing (#11163) 2025-05-26 14:41:42 -07:00
google_endpoints fix: Metadata / Trace ID Missing in S3 Streaming Callbacks 2026-03-03 18:15:16 +05:30
guardrails fix(guardrails): prevent presidio crash on non-json responses 2026-03-03 18:15:16 +05:30
health_endpoints fix: resolve flaky test failures in health, spend logs, and CLI tests (#21769) 2026-02-21 10:02:24 -08:00
hooks Agents - assign tools (#22064) 2026-03-03 18:15:17 +05:30
image_endpoints fixing core proxy tests 2026-02-12 17:54:32 -08:00
management_endpoints feat(agents): assign virtual keys to agents (#22045) 2026-03-03 18:15:10 +05:30
management_helpers [MCP Gateway] Litellm mcp fixes team control (#15304) 2025-10-07 16:48:00 -07:00
middleware test: add backwards compatibility tests for PrometheusAuthMiddleware 2026-02-21 12:06:31 -08:00
openai_files_endpoint fix(tests): isolate flaky files endpoint tests from global proxy state (#21788) 2026-02-21 11:20:32 -08:00
pass_through_endpoints fix(tests): isolate auth in vertex passthrough and spend logs date range tests (#21824) 2026-02-21 14:14:50 -08:00
policy_engine Guardrail Policy Versioning (#21862) 2026-02-21 20:14:31 -08:00
prompts fix(prompts): fix prompt info lookup and delete using correct IDs (#19358) 2026-01-20 12:28:34 -08:00
public_endpoints /public/model_hub health information 2026-01-16 15:36:56 -08:00
rag_endpoints tests and route permissions (#21508) 2026-02-18 16:58:38 -08:00
response_api_endpoints Fix x-litellm-key-spend update 2025-12-12 11:44:51 +05:30
spend_tracking [Feature] Add request_duration_ms to SpendLogs 2026-03-03 18:15:16 +05:30
test_configs Litellm fix GitHub action testing (#11163) 2025-05-26 14:41:42 -07:00
ui_crud_endpoints Merge pull request #21926 from BerriAI/main 2026-02-23 18:17:30 +05:30
vector_store_endpoints test_delete_vector_store_checks_access 2026-01-31 12:05:09 -08:00
__init__.py test fix 2025-10-17 10:46:42 -07:00
conftest.py Add health endpoint tests to CI with database and Redis support (#17877) 2025-12-12 07:35:50 -08:00
test_aiohttp_cleanup_closed.py fix(aiohttp): only set enable_cleanup_closed when required (#21897) 2026-03-03 18:14:40 +05:30
test_api_key_masking_in_errors.py fix: mask API keys in error responses for invalid/malformed keys (#20289) 2026-02-12 19:58:05 +05:30
test_batch_metadata_none_fix.py Fix issue #13995: Handle None metadata in batch requests (#13996) 2025-08-27 14:51:09 -07:00
test_caching_routes.py [Bug Fix] Ensure /redis/info works on GCP Redis (#11732) 2025-06-14 15:35:09 -07:00
test_chat_completion_metadata.py fix: propagate JWT auth metadata to OTEL spans (#19627) 2026-01-23 21:21:23 -08:00
test_common_request_processing.py fix(router): emit x-litellm-overhead-duration-ms header for streaming requests (#22027) 2026-03-03 18:14:40 +05:30
test_custom_proxy.py fix(ui/): fix routing for custom server root path (#15701) 2025-10-23 13:59:29 -07:00
test_empty_model_list.py Fixing tests and linting 2026-01-21 11:02:39 -08:00
test_enforce_user_param.py Enforce support of enforce_user_param to openai post endpoints 2025-12-03 12:19:21 +05:30
test_fallback_management_endpoints.py Add fallback endpoints support 2026-01-16 10:51:33 +05:30
test_fastapi_offline_routes.py [Bug Fix] - Get Routes (#13466) 2025-08-09 12:52:23 -07:00
test_health_check_functions.py healthcheck-model_id-fix: There was quite a bit of code that needed to be changed since health checks were entirely keyed by model name. This includes, proxy logic, the dashboard, and even networking, because model name was the identifier everywhere. All changed files had tests added to them, which are passing with no regressions. 2026-03-03 18:15:08 +05:30
test_litellm_pre_call_utils.py Guardrail Policy Versioning (#21862) 2026-02-21 20:14:31 -08:00
test_model_dump_with_preserved_fields.py fix: address PR review comments for model_dump_with_preserved_fields 2026-02-21 10:48:10 -08:00
test_model_id_header_propagation.py (fix) propagate x-litellm-model-id in responses (#16986) 2025-11-24 20:40:43 -08:00
test_proxy_cli.py fix(tests): fix flaky test_use_prisma_db_push_flag_behavior (#21849) 2026-02-21 15:23:55 -08:00
test_proxy_server.py Merge origin/main into litellm_fix_streaming_connection_pool_leak 2026-02-21 12:44:50 -08:00
test_proxy_types.py Litellm dev 06 06 2025 p1 (#11496) 2025-06-07 09:12:16 -07:00
test_proxy_utils.py Fix date overflow/division by zero in proxy utils (#19527) 2026-01-21 21:09:57 -08:00
test_pyroscope.py Fix CI/CD pyroscope test failure (#21219) 2026-02-14 12:07:20 -08:00
test_response_model_sanitization.py fix(proxy): prevent provider-prefixed model leaks (#19943) 2026-01-28 22:26:38 -08:00
test_route_a2a_models.py Fix test_route_a2a_model_bypasses_router 2026-02-05 09:47:05 +05:30
test_route_llm_request.py Override router settings 2026-01-31 16:04:52 -08:00
test_shared_health_check.py Add shared healthcheck 2025-10-09 22:18:05 +05:30
test_spend_log_cleanup.py feat(proxy): cleanup spend logs cron verification, fix, and docs (#19085) 2026-01-14 22:14:48 +05:30
test_swagger_chat_completions.py fix(tests): isolate flaky tests - restore global state in setup/teardown (#21791) 2026-02-21 11:30:35 -08:00
test_team_member_update.py fix mapped tests (#12320) 2025-07-04 10:04:43 -07:00