Skip to content

Commit 77bddf0

Browse files
committed
Integrate ChatAgent into ReasoningAgentTemplate
Replaces direct client assignment with instantiation of a ChatAgent, passing relevant parameters such as instructions, name, description, tools, and model configuration. This change aligns ReasoningAgentTemplate with the foundry_agent pattern and prepares for enhanced tool and chat handling.
1 parent f7df204 commit 77bddf0

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/backend/af/magentic_agents/reasoning_agent.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@
55
from typing import Optional
66

77
from agent_framework import (
8+
ChatAgent,
89
ChatMessage,
910
Role,
1011
)
1112
from agent_framework_azure_ai import AzureAIAgentClient
1213
from azure.identity.aio import DefaultAzureCredential
1314

15+
16+
#from agent_framework.azure import AzureOpenAIChatClient
17+
18+
19+
1420
from af.magentic_agents.common.lifecycle import MCPEnabledBase
1521
from af.magentic_agents.models.agent_models import MCPConfig, SearchConfig
1622
from af.magentic_agents.reasoning_search import ReasoningSearch, create_reasoning_search
@@ -123,9 +129,20 @@ async def _after_open(self) -> None:
123129
len(self.mcp_tool.functions) if hasattr(self.mcp_tool, 'functions') else 0
124130
)
125131

126-
# Store client reference (for compatibility with base class delegation)
127-
self._agent = self._client
132+
# Prepare tools for the agent
133+
tools = self._prepare_tools()
128134

135+
# Create ChatAgent instance (similar to foundry_agent)
136+
self._agent = ChatAgent(
137+
chat_client=self._client,
138+
instructions=self.base_instructions,
139+
name=self.agent_name,
140+
description=self.agent_description,
141+
tools=tools if tools else None,
142+
tool_choice="auto" if tools else "none",
143+
temperature=1.0, # Reasoning models use fixed temperature
144+
model_id=self.model_deployment_name,
145+
)
129146
# Register agent globally
130147
try:
131148
agent_registry.register_agent(self)

0 commit comments

Comments
 (0)