Skip to content

The agent that grows with you

test(agent): pass issuer_model through the Perplexity alias normalize stub

teknium18d7d57a98337
diff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.py
index c9baf11550e..0765890ab04 100644
--- a/tests/agent/test_auxiliary_client.py
+++ b/tests/agent/test_auxiliary_client.py
@@ -3948,6 +3948,72 @@ class TestCodexAuxiliaryAdapterCompletedResponse:
assert response.usage.total_tokens == 14
+class TestCodexAuxiliaryAdapterReservedToolAliases:
+ """The aux adapter emits the same tool schemas as the main Responses transport: shared
+ converter (``strict: False``) plus provider-reserved-name aliasing (OpenCode, Perplexity),
+ reversed on the parsed tool_calls before Hermes dispatch (#114260)."""
+
+ _TOOLS = [
+ {"type": "function", "function": {"name": name, "description": name,
+ "parameters": {"type": "object", "properties": {}}}}
+ for name in ("web_search", "search_files", "people_search", "read_file")
+ ]
+ _HISTORY = [
+ {"role": "system", "content": "sys"},
+ {"role": "user", "content": "find it"},
+ {"role": "assistant", "content": None, "tool_calls": [
+ {"id": "c1", "type": "function", "function": {"name": "search_files", "arguments": "{}"}}]},
+ {"role": "tool", "tool_call_id": "c1", "content": "ok"},
+ ]
+
+ @pytest.mark.parametrize("base_url, aliased", [
+ ("https://api.perplexity.ai/v1", {"web_search", "search_files", "people_search"}),
+ ("https://opencode.ai/zen/v1", {"web_search", "search_files"}),
+ ("https://api.perplexity.ai.evil.com/v1", set()),
+ ("https://example.com/v1", set()),
+ ])
+ def test_wire_tools_match_main_transport_aliases_and_strict(self, base_url, aliased):
+ from agent.transports.codex import ResponsesApiTransport
+
+ adapter = _CodexCompletionsAdapter(SimpleNamespace(base_url=base_url), "m")
+ resp_kwargs, _, _ = adapter._build_responses_kwargs(
+ {"model": "m", "messages": self._HISTORY, "tools": self._TOOLS}
+ )
+ main_kwargs = ResponsesApiTransport().build_kwargs(
+ "m", self._HISTORY, self._TOOLS, provider="custom", base_url=base_url
+ )
+ assert resp_kwargs["tools"] == main_kwargs["tools"]
+ assert all(t["strict"] is False for t in resp_kwargs["tools"])
+ assert {t["name"] for t in resp_kwargs["tools"]} == {
+ f"hermes_{n}" if n in aliased else n for n in ("web_search", "search_files", "people_search", "read_file")
+ }
+ # Replayed history names the tool the way this request declares it; the alias map rides on the payload.
+ history_names = [i["name"] for i in resp_kwargs["input"] if i.get("type") == "function_call"]
+ assert history_names == ["hermes_search_files" if "search_files" in aliased else "search_files"]
+ assert resp_kwargs.get("_wire_aliases", {}) == {f"hermes_{n}": n for n in aliased}
+
+ def test_create_maps_aliases_back_and_never_sends_alias_map(self):
+ sent = {}
+
+ class FakeResponses:
+ def create(self, **kwargs):
+ sent.update(kwargs)
+ return SimpleNamespace(
+ status="completed", id="resp_1", usage=None,
+ output=[SimpleNamespace(type="function_call", call_id="c9", id="fc_9",
+ name="hermes_search_files", arguments='{"pattern": "x"}')],
+ )
+
+ adapter = _CodexCompletionsAdapter(
+ SimpleNamespace(base_url="https://api.perplexity.ai/v1", responses=FakeResponses()), "m"
+ )
+ response = adapter.create(messages=[{"role": "user", "content": "find it"}], tools=self._TOOLS)
+
+ assert "_wire_aliases" not in sent
+ assert "hermes_search_files" in {t["name"] for t in sent["tools"]}
+ assert [tc.function.name for tc in response.choices[0].message.tool_calls] == ["search_files"]
+
+
# ---------------------------------------------------------------------------
# Issue #23432 — auxiliary timeout poisons cached client; later aux calls fail
# ---------------------------------------------------------------------------
diff --git a/tests/agent/transports/test_codex_transport.py b/tests/agent/transports/test_codex_transport.py
index e8c01f93ccf..a9a5cb6bab5 100644
--- a/tests/agent/transports/test_codex_transport.py
+++ b/tests/agent/transports/test_codex_transport.py
@@ -1149,7 +1149,7 @@ class TestResponsesReservedToolAliases:
)
monkeypatch.setattr(
"agent.codex_responses_adapter._normalize_codex_response",
- lambda resp, issuer_kind=None: (msg, "tool_calls"),
+ lambda resp, issuer_kind=None, issuer_model=None: (msg, "tool_calls"),
)
normalized = transport.normalize_response(SimpleNamespace(output=[], status="completed"))
assert [tc.name for tc in normalized.tool_calls] == ["search_files"]