← all conversations

Agent Adapter Registration

2025-03-132 turns1,807 charsgpt-4o-mini
code-reviewagent-sdkbest-practices

Summary

User wants to reword a code review comment about incorrect Agent SDK adapter registration in their own voice.

Messages

reword this in my voice: The way you've written the code isn't quite right. The Agents SDK doesn't allow you to explicitly pass the adapter in the Agent constructor like that. The correct pattern is exactly what was shown in the original code: pythonCopy# First register the adapter with the client agent_adapter = OllamaAgentAdapter() agent_adapter.register(ollama_client) # Then create the agent with the client agent = Agent( ollama_client, tools=[add_numbers], instructions=INSTRUCTIONS ) The registration process (agent_adapter.register(ollama_client)) is what links the adapter to the client. After registration, whenever the client is used, the adapter's functionality is automatically applied. There's no parameter in the Agent constructor to explicitly specify an adapter - the association between client and adapter happens through the registration pattern before the Agent is created.
The way you've written the code isn't quite hitting the mark. The Agents SDK doesn’t let you pass the adapter directly into the Agent constructor like that. The correct approach follows the pattern shown in the original code: ```python # First, register the adapter with the client agent_adapter = OllamaAgentAdapter() agent_adapter.register(ollama_client) # Then, create the agent with the client agent = Agent( ollama_client, tools=[add_numbers], instructions=INSTRUCTIONS ) ``` The key here is the registration process (`agent_adapter.register(ollama_client)`), which ties the adapter to the client. After registering, the client automatically applies the adapter's functionality whenever it's used. There’s no need to specify the adapter in the Agent constructor—this connection between the client and adapter is established during registration before the Agent is even created.
gpt-4o-mini