Skip to content

Agent Zero AI framework

Require native Responses tool calls

Alessandroff596e2a8472
diff --git a/helpers/litellm_transport.py b/helpers/litellm_transport.py
index a3dd40bf8..d5168b4fb 100644
--- a/helpers/litellm_transport.py
+++ b/helpers/litellm_transport.py
@@ -751,6 +751,10 @@ class ResponsesTransport:
elif "tool_choice" in request:
request["tool_choice"] = cls.tool_choice_from_chat(request["tool_choice"])
+ if _has_tools(response_function_tools):
+ request.setdefault("tool_choice", "required")
+ request.setdefault("parallel_tool_calls", False)
+
if not _has_tools(request.get("tools")):
request.pop("tool_choice", None)
request.pop("parallel_tool_calls", None)
diff --git a/helpers/litellm_transport.py.dox.md b/helpers/litellm_transport.py.dox.md
index add4be9ab..3be2c9574 100644
--- a/helpers/litellm_transport.py.dox.md
+++ b/helpers/litellm_transport.py.dox.md
@@ -25,6 +25,7 @@
- Keep provider selection and provider-specific defaults outside this helper; callers pass a resolved LiteLLM model name and kwargs.
- Strip Agent Zero internal kwargs before sending requests to LiteLLM.
- Do not send orphan tool controls when no tools are present; strict OpenAI-compatible servers can reject empty `tools` arrays.
+- When Agent Zero function tools are present, default Responses requests to one required native call; explicit request-level `tool_choice` and `parallel_tool_calls` values still win.
- Normalize function tool parameter schemas with an explicit object `properties` field before Responses requests so OpenAI-compatible chat backends reached through LiteLLM can validate them.
- Prefer Responses API when configured, but fallback to Chat Completions when the provider does not support Responses.
- Fall back to Chat Completions when a Responses request is rejected before any output by an endpoint-specific or shape-specific Bad Request indicating the provider cannot parse Responses payloads.
diff --git a/tests/test_stream_tool_early_stop.py b/tests/test_stream_tool_early_stop.py
index a1805d457..10fd66873 100644
--- a/tests/test_stream_tool_early_stop.py
+++ b/tests/test_stream_tool_early_stop.py
@@ -1054,6 +1054,28 @@ def test_responses_request_normalizes_function_tool_parameter_shapes():
},
{"type": "web_search"},
]
+ assert request["tool_choice"] == "required"
+ assert request["parallel_tool_calls"] is False
+
+
+def test_responses_request_preserves_explicit_a0_tool_controls():
+ request = litellm_transport.ResponsesTransport.from_chat(
+ [],
+ {
+ "a0_responses_function_tools": [
+ {
+ "type": "function",
+ "name": "native_noop",
+ "parameters": {"type": "object"},
+ }
+ ],
+ "tool_choice": "auto",
+ "parallel_tool_calls": True,
+ },
+ )
+
+ assert request["tool_choice"] == "auto"
+ assert request["parallel_tool_calls"] is True
def test_chat_completions_kwargs_omit_empty_tools():