litellm/tests/test_litellm/proxy/hooks
Krish Dholakia 12c4876891
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-02-25 11:44:30 -08:00
..
test_async_post_call_streaming_iterator_hook.py fix(proxy): async_post_call_streaming_iterator_hook now properly iterates async generators (#17626) 2025-12-07 23:29:42 -08:00
test_dynamic_rate_limiter_v3.py Merge pull request #17707 from raghav-stripe/raghav-fix-responsesapi-rl 2025-12-11 08:57:16 +05:30
test_image_generation_guardrails.py added tests 2026-02-11 15:45:47 +05:30
test_key_management_event_hooks.py feat: hashicorp vault rotate support 2026-01-23 17:32:55 +09:00
test_max_iterations_limiter.py Agents - assign tools (#22064) 2026-02-25 11:44:30 -08:00
test_parallel_request_limiter_v3.py fix(tests): isolate flaky tests - restore global state in setup/teardown (#21791) 2026-02-21 11:30:35 -08:00
test_post_call_failure_hook_integration.py [Feat] Enable async_post_call_failure_hook to transform error responses (#18348) 2025-12-22 11:24:30 -08:00
test_post_call_response_headers_hook.py [Feat] Add async_post_call_response_headers_hook to CustomLogger (#20083) 2026-01-30 12:44:44 -08:00
test_post_call_streaming_hook_integration.py fix(proxy): use return value from CustomLogger.async_post_call_success_hook (#19670) 2026-01-26 08:48:22 -08:00
test_post_call_success_hook_integration.py fix(proxy): use return value from CustomLogger.async_post_call_success_hook (#19670) 2026-01-26 08:48:22 -08:00
test_prompt_injection_detection.py fix: prompt injection not working (#16701) 2025-11-17 20:04:57 -08:00
test_proxy_track_cost_callback.py [Fix] Enrich failure spend logs with key/team metadata 2026-02-24 17:14:37 -08:00
test_send_invite_email.py Fix User Invite & Key Generation Email Notification Logic (#18524) 2026-01-06 01:35:52 +05:30