litellm/tests/unit
Sindri 2bf05e78ed feat(bedrock/agentcore): optionally forward client tool declarations in InvokeAgentRuntime payload
AgentCore Runtime is schemaless on the agent side: the agent author's
@app.entrypoint handler parses whatever JSON arrives. An agent that implements a
capability itself (its own search, its own retrieval, its own code runner) has no
way today to learn whether the caller offered that capability for this turn.
AmazonAgentCoreConfig reports no supported OpenAI params and map_openai_params
ignores non_default_params, so `tools` never reaches transform_request.

Add a `forward_tools` litellm param, default off. When truthy and the caller sent
a non-empty tools list, it is forwarded verbatim under a new top-level `tools`
key, alongside the existing `prompt` and optional `content`. Mirrors
`forward_multimodal_content` (#28885) in shape, flag parsing and precedence.

Reaching the transform still requires `allowed_openai_params: ["tools"]`. That is
deliberate: get_supported_openai_params() keeps reporting what AgentCore natively
supports, so /model_group/info never advertises tool support for models that do
nothing with tools, and forwarding stays an explicit opt-in rather than a
capability claim. Nobody who has not set both keys sees any change.

The two flag checks fold into one helper. _should_forward_multimodal_content and
_should_forward_tools were identical apart from the key they read, so they become
_is_flag_enabled(optional_params, litellm_params, key), taking Mapping[str, object]
rather than bare dict, which retires an isinstance guard that could never fire.
The forwarded list is copied with tuple() rather than list(): still shallow, so
the nested tool dicts stay shared and no large payload is cloned, but the value
cannot be mutated at all and json.dumps serializes it to the same JSON array.
Against the base the file drops from 228 basedpyright diagnostics to 225 and from
42 LIT001 to 40, so it ends up cleaner than it started despite gaining a feature.

Note that get_litellm_params only forwards an allowlist of keys
(OPTIONAL_KWARGS_KEYS) and `forward_tools` is not on it, so both deployment-level
and per-request flags reach transform_request through optional_params via
add_provider_specific_params_to_optional_params. litellm_params is only the
fallback for callers that build it themselves; an end-to-end test pins the real
path.

This is a one-way signal. AgentCore responses carry no tool-call channel, so
nothing here implies function-calling support.
2026-09-23 15:36:03 +00:00
..
a2a_protocol test(a2a): sort imports in merged bedrock agentcore test 2026-09-21 16:10:40 +00:00
anthropic_interface test: add __init__.py to migrated tests/unit packages 2026-09-20 11:53:49 +00:00
batches fix(cost): bill batch prompts above 272K at OpenAI's long-context batch tier (#39861) 2026-09-22 10:22:41 -07:00
chat_completions feat(rust-bridge): add cache and secret migration foundations (#42328) 2026-09-22 03:41:04 +00:00
completion_extras test: add sync and async custom_llm_provider bridge propagation tests 2026-09-20 13:46:52 +00:00
compression test: add __init__.py to migrated tests/unit packages 2026-09-20 11:53:49 +00:00
endpoints test: add __init__.py to migrated tests/unit packages 2026-09-20 11:53:49 +00:00
enterprise test(unit): make bedrock collector and secret scan timing tests deterministic (#42405) 2026-09-22 09:30:28 -07:00
integrations chore: merge main into litellm_migrate_tests_p1 2026-09-20 12:54:53 +00:00
litellm_core_utils test(response_metadata): make the detailed-timing receive-anchor test timezone independent (#42429) 2026-09-22 10:49:37 -07:00
llms feat(bedrock/agentcore): optionally forward client tool declarations in InvokeAgentRuntime payload 2026-09-23 15:36:03 +00:00
messages feat(rust-bridge): add cache and secret migration foundations (#42328) 2026-09-22 03:41:04 +00:00
models feat(auth): breached password detection, self-service change-password and forced password reset 2026-09-21 18:48:35 +00:00
ocr feat(rust-bridge): add cache and secret migration foundations (#42328) 2026-09-22 03:41:04 +00:00
passthrough test: migrate phase 15 legacy tests to tests/unit 2026-09-20 11:55:43 +00:00
rag test: add __init__.py to intermediate tests/unit packages 2026-09-20 12:55:27 +00:00
realtime_api test: add __init__.py to new tests/unit packages 2026-09-20 12:36:13 +00:00
repositories test: point CircleCI-only suites at models still in the cost map (#42617) 2026-09-22 17:28:34 -07:00
router_strategy fix(auto-router): skip JEV for encrypted delegated tasks 2026-09-21 18:29:21 +00:00
router_utils Merge pull request #42080 from BerriAI/litellm_prompt_caching_affinity_lookback 2026-09-21 12:44:34 -07:00
rust_bridge Merge remote-tracking branch 'origin/main' into litellm_migrate_tests_p15 2026-09-20 13:44:24 +00:00
sandbox test: add __init__.py to every tests/unit directory phase 16 touches 2026-09-20 11:52:38 +00:00
skills test: add __init__.py to every tests/unit directory phase 16 touches 2026-09-20 11:52:38 +00:00
test_router test: add __init__.py to every tests/unit directory phase 16 touches 2026-09-20 11:52:38 +00:00
types test: add __init__.py to every tests/unit directory phase 16 touches 2026-09-20 11:52:38 +00:00
videos test: migrate phase 16 legacy tests to tests/unit 2026-09-20 10:59:02 +00:00
__init__.py test(unit): add package markers to migrated unit test directories 2026-09-20 11:53:14 +00:00
AGENTS.md docs(tests): define the tier contract for unit, integration and e2e 2026-09-20 06:24:06 +00:00
conftest.py test: use main's local_model_cost_map fixture in tests/unit/conftest.py 2026-09-20 13:44:30 +00:00
test_package_layout.py test(unit): make every tests/unit directory a package so pytest collection is unique 2026-09-20 11:50:59 +00:00
test_socket_policy.py test(unit): block external sockets at import time and add a socket policy regression test 2026-09-20 08:07:50 +00:00