1616# from v4.magentic_agents.models.agent_models import (BingConfig, MCPConfig,
1717# SearchConfig)
1818from v4 .magentic_agents .proxy_agent import ProxyAgent
19- from v4 .magentic_agents .reasoning_agent import ReasoningAgentTemplate
2019
2120
2221class UnsupportedModelError (Exception ):
@@ -41,7 +40,7 @@ def __init__(self, team_service: Optional[TeamService] = None):
4140 # with open(file_path, 'r') as f:
4241 # data = json.load(f)
4342 # return json.loads(json.dumps(data), object_hook=lambda d: SimpleNamespace(**d))
44-
43+
4544 # Ensure only an explicit boolean True in the source sets this flag.
4645 def extract_use_reasoning (self , agent_obj ):
4746 # Support both dict and attribute-style objects
@@ -59,7 +58,7 @@ async def create_agent_from_config(
5958 agent_obj : SimpleNamespace ,
6059 team_config : TeamConfiguration ,
6160 memory_store : DatabaseBase ,
62- ) -> Union [FoundryAgentTemplate , ReasoningAgentTemplate , ProxyAgent ]:
61+ ) -> Union [FoundryAgentTemplate , ProxyAgent ]:
6362 """
6463 Create an agent from configuration object.
6564
@@ -91,16 +90,16 @@ async def create_agent_from_config(
9190 )
9291
9392 # Determine which template to use
94- # Usage
93+ # Usage
9594 use_reasoning = self .extract_use_reasoning (agent_obj )
9695
97- # Validate reasoning template constraints
96+ # Validate reasoning constraints
9897 if use_reasoning :
9998 if getattr (agent_obj , "use_bing" , False ) or getattr (
10099 agent_obj , "coding_tools" , False
101100 ):
102101 raise InvalidConfigurationError (
103- f"ReasoningAgentTemplate cannot use Bing search or coding tools. "
102+ f"Agent cannot use Bing search or coding tools. "
104103 f"Agent '{ agent_obj .name } ' has use_bing={ getattr (agent_obj , 'use_bing' , False )} , "
105104 f"coding_tools={ getattr (agent_obj , 'coding_tools' , False )} "
106105 )
@@ -118,44 +117,30 @@ async def create_agent_from_config(
118117 # bing_config = BingConfig.from_env() if getattr(agent_obj, 'use_bing', False) else None
119118
120119 self .logger .info (
121- f"Creating agent '{ agent_obj .name } ' with model '{ deployment_name } ' { index_name } "
122- f"(Template: { 'Reasoning' if use_reasoning else 'Foundry' } )"
120+ "Creating agent '%s' with model '%s' %s (Template: %s)" ,
121+ agent_obj .name ,
122+ deployment_name ,
123+ index_name ,
124+ "Reasoning" if use_reasoning else "Foundry" ,
123125 )
124126
125- # Create appropriate agent
126- if use_reasoning :
127- # Get reasoning specific configuration
128- project_endpoint = config .AZURE_AI_PROJECT_ENDPOINT
129- agent = ReasoningAgentTemplate (
130- agent_name = agent_obj .name ,
131- agent_description = getattr (agent_obj , "description" , "" ),
132- agent_instructions = getattr (agent_obj , "system_message" , "" ),
133- model_deployment_name = deployment_name ,
134- project_endpoint = project_endpoint , # type: ignore
135- search_config = search_config ,
136- mcp_config = mcp_config ,
137- team_service = self .team_service ,
138- team_config = team_config ,
139- memory_store = memory_store ,
140- )
141- else :
142- agent = FoundryAgentTemplate (
143- agent_name = agent_obj .name ,
144- agent_description = getattr (agent_obj , "description" , "" ),
145- agent_instructions = getattr (agent_obj , "system_message" , "" ),
146- model_deployment_name = deployment_name ,
147- enable_code_interpreter = getattr (agent_obj , "coding_tools" , False ),
148- project_endpoint = config .AZURE_AI_PROJECT_ENDPOINT ,
149- mcp_config = mcp_config ,
150- search_config = search_config ,
151- team_service = self .team_service ,
152- team_config = team_config ,
153- memory_store = memory_store ,
154- )
127+ agent = FoundryAgentTemplate (
128+ agent_name = agent_obj .name ,
129+ agent_description = getattr (agent_obj , "description" , "" ),
130+ agent_instructions = getattr (agent_obj , "system_message" , "" ),
131+ model_deployment_name = deployment_name ,
132+ enable_code_interpreter = getattr (agent_obj , "coding_tools" , False ),
133+ project_endpoint = config .AZURE_AI_PROJECT_ENDPOINT ,
134+ mcp_config = mcp_config ,
135+ search_config = search_config ,
136+ team_service = self .team_service ,
137+ team_config = team_config ,
138+ memory_store = memory_store ,
139+ )
155140
156141 await agent .open ()
157142 self .logger .info (
158- f "Successfully created and initialized agent '{ agent_obj .name } '"
143+ "Successfully created and initialized agent '%s'" , agent_obj .name
159144 )
160145 return agent
161146
@@ -184,7 +169,10 @@ async def get_agents(
184169 for i , agent_cfg in enumerate (team_config_input .agents , 1 ):
185170 try :
186171 self .logger .info (
187- f"Creating agent { i } /{ len (team_config_input .agents )} : { agent_cfg .name } "
172+ "Creating agent %d/%d: %s" ,
173+ i ,
174+ len (team_config_input .agents ),
175+ agent_cfg .name
188176 )
189177
190178 agent = await self .create_agent_from_config (
@@ -194,7 +182,10 @@ async def get_agents(
194182 self ._agent_list .append (agent ) # Keep track for cleanup
195183
196184 self .logger .info (
197- f"✅ Agent { i } /{ len (team_config_input .agents )} created: { agent_cfg .name } "
185+ "✅ Agent %d/%d created: %s" ,
186+ i ,
187+ len (team_config_input .agents ),
188+ agent_cfg .name
198189 )
199190
200191 except (UnsupportedModelError , InvalidConfigurationError ) as e :
@@ -207,7 +198,10 @@ async def get_agents(
207198 continue
208199
209200 self .logger .info (
210- f"Successfully created { len (initalized_agents )} /{ len (team_config_input .agents )} agents for team '{ team_config_input .name } '"
201+ "Successfully created %d/%d agents for team '%s'" ,
202+ len (initalized_agents ),
203+ len (team_config_input .agents ),
204+ team_config_input .name
211205 )
212206 return initalized_agents
213207
0 commit comments