diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py index 4f8c9a0a4..f8fe50d89 100644 --- a/agent/auxiliary_client.py +++ b/agent/auxiliary_client.py @@ -573,7 +573,8 @@ class _AnthropicCompletionsAdapter: self._is_oauth = is_oauth def create(self, **kwargs) -> Any: - from agent.anthropic_adapter import build_anthropic_kwargs, normalize_anthropic_response + from agent.anthropic_adapter import build_anthropic_kwargs + from agent.transports import get_transport messages = kwargs.get("messages", []) model = kwargs.get("model", self._model) @@ -610,7 +611,28 @@ class _AnthropicCompletionsAdapter: anthropic_kwargs["temperature"] = temperature response = self._client.messages.create(**anthropic_kwargs) - assistant_message, finish_reason = normalize_anthropic_response(response) + _transport = get_transport("anthropic_messages") + _nr = _transport.normalize_response( + response, strip_tool_prefix=self._is_oauth + ) + + # Map NormalizedResponse → OpenAI-compatible SimpleNamespace + tool_calls = None + if _nr.tool_calls: + tool_calls = [ + SimpleNamespace( + id=tc.id, + type="function", + function=SimpleNamespace(name=tc.name, arguments=tc.arguments), + ) + for tc in _nr.tool_calls + ] + assistant_message = SimpleNamespace( + content=_nr.content, + tool_calls=tool_calls, + reasoning=_nr.reasoning, + ) + finish_reason = _nr.finish_reason usage = None if hasattr(response, "usage") and response.usage: