Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(gateway): relay a null "tools" in Responses replies instead of failing (#6309)

wang2-lateb8ae9491453
diff --git a/openviking_gateway/tool_protocols/responses.py b/openviking_gateway/tool_protocols/responses.py
index c8f21aa27..4f051d502 100644
--- a/openviking_gateway/tool_protocols/responses.py
+++ b/openviking_gateway/tool_protocols/responses.py
@@ -150,7 +150,7 @@ class ResponsesProtocol(ToolProtocol):
def public_response(self, value):
value = {**value, "id": self.identifier}
- if "tools" in value:
+ if isinstance(value.get("tools"), list):
value["tools"] = [t for t in value["tools"] if not t.get("name", "").startswith(PREFIX)]
return value
diff --git a/tests/gateway/test_native_tools.py b/tests/gateway/test_native_tools.py
index 5334fb671..21971d7e2 100644
--- a/tests/gateway/test_native_tools.py
+++ b/tests/gateway/test_native_tools.py
@@ -679,6 +679,27 @@ async def test_responses_custom_tool_mixed_handoff(running_gateway, streaming):
assert "openviking_search" not in response.text
[email protected]("streaming", [False, True])
+async def test_responses_relays_null_tools(running_gateway, streaming):
+ app, client, admin, key, _, _ = running_gateway
+ await enable_tools(client, admin)
+
+ async def backend(request):
+ if request.path != "/v1/responses":
+ return None
+ value = {**native_response("responses", 1), "tools": None}
+ return await wire_response(request, "responses", value, streaming)
+
+ app.state.test_backend["handler"] = backend
+ response = await client.post(
+ "/v1/responses",
+ headers={"Authorization": "Bearer " + key["key"]},
+ json=request_body("responses", streaming),
+ )
+ assert response.status_code == 200, response.text
+ assert visible_response("responses", response, streaming)["tools"] is None
+
+
@pytest.mark.parametrize("protocol", ["responses", "anthropic"])
async def test_native_incompatible_mode_keeps_only_visible_history(
setup_kernel, credential, policy, protocol