Skip to content

Commit db9dd41

Browse files
committed
fixes for the id stuff - added temp difference btwn reasoning and non reasoning.
1 parent e9cbbaa commit db9dd41

4 files changed

Lines changed: 35 additions & 31 deletions

File tree

src/backend/common/utils/utils_af.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
import logging
44

5+
from common.config.app_config import config
56
# Converted import path (agent_framework version of FoundryAgentTemplate)
67
from common.database.database_base import DatabaseBase
78
from common.models.messages_af import TeamConfiguration
89
from v4.common.services.team_service import TeamService
9-
from v4.magentic_agents.foundry_agent import FoundryAgentTemplate # formerly v4.magentic_agents.foundry_agent
1010
from v4.config.agent_registry import agent_registry
11-
from common.config.app_config import config
11+
from v4.magentic_agents.foundry_agent import \
12+
FoundryAgentTemplate # formerly v4.magentic_agents.foundry_agent
13+
1214
logging.basicConfig(level=logging.INFO)
1315

1416
async def find_first_available_team(team_service: TeamService, user_id: str) -> str:
@@ -62,6 +64,7 @@ async def create_RAI_agent(team: TeamConfiguration, memory_store: DatabaseBase)
6264
agent_name=agent_name,
6365
agent_description=agent_description,
6466
agent_instructions=agent_instructions,
67+
use_reasoning=False,
6568
model_deployment_name=model_deployment_name,
6669
enable_code_interpreter=False,
6770
project_endpoint=config.AZURE_AI_PROJECT_ENDPOINT,

src/backend/v4/magentic_agents/common/lifecycle.py

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,23 @@
22

33
import logging
44
import os
5-
from contextlib import AsyncExitStack
65
import secrets
76
import string
7+
from contextlib import AsyncExitStack
88
from typing import Any, Optional
99

10-
from agent_framework import (
11-
AggregateContextProvider,
12-
ChatAgent,
13-
ChatClientProtocol,
14-
ChatMessage,
15-
ChatMessageStoreProtocol,
16-
ChatOptions,
17-
ContextProvider,
18-
HostedMCPTool,
19-
MCPStreamableHTTPTool,
20-
Middleware,
21-
Role,
22-
ToolMode,
23-
ToolProtocol,
24-
)
25-
10+
from agent_framework import (AggregateContextProvider, ChatAgent,
11+
ChatClientProtocol, ChatMessage,
12+
ChatMessageStoreProtocol, ChatOptions,
13+
ContextProvider, HostedMCPTool,
14+
MCPStreamableHTTPTool, Middleware, Role, ToolMode,
15+
ToolProtocol)
2616
# from agent_framework.azure import AzureAIAgentClient
2717
from agent_framework_azure_ai import AzureAIAgentClient
2818
from azure.ai.agents.aio import AgentsClient
2919
from azure.identity.aio import DefaultAzureCredential
30-
from common.models.messages_af import CurrentTeamAgent, TeamConfiguration
3120
from common.database.database_base import DatabaseBase
21+
from common.models.messages_af import CurrentTeamAgent, TeamConfiguration
3222
from v4.common.services.team_service import TeamService
3323
from v4.config.agent_registry import agent_registry
3424
from v4.magentic_agents.models.agent_models import MCPConfig
@@ -196,10 +186,10 @@ async def get_database_team_agent(self) -> Optional[AzureAIAgentClient]:
196186
agent = await self.client.get_agent(
197187
agent_id=currentAgent.agent_foundry_id
198188
)
199-
if agent and agent.agent_id is not None:
189+
if agent and agent.id is not None:
200190
chat_client = AzureAIAgentClient(
201191
project_endpoint=self.project_endpoint,
202-
agent_id=agent.agent_id,
192+
agent_id=agent.id,
203193
model_deployment_name=self.model_deployment_name,
204194
async_credential=self.creds,
205195
)
@@ -213,15 +203,15 @@ async def get_database_team_agent(self) -> Optional[AzureAIAgentClient]:
213203
async def save_database_team_agent(self) -> None:
214204
"""Save current team agent to database."""
215205
try:
216-
if self._agent.chat_client.agent_id is None:
206+
if self._agent.id is None:
217207
self.logger.error("Cannot save database team agent: agent_id is None")
218208
return
219209

220210
currentAgent = CurrentTeamAgent(
221211
team_id=self.team_config.team_id,
222212
team_name=self.team_config.name,
223213
agent_name=self.agent_name,
224-
agent_foundry_id=self._agent.chat_client.agent_id,
214+
agent_foundry_id=self._agent.id,
225215
agent_description=self.agent_description,
226216
agent_instructions=self.agent_instructions,
227217
)

src/backend/v4/magentic_agents/foundry_agent.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
import logging
44
from typing import List, Optional
55

6-
from agent_framework import ChatAgent, ChatMessage, HostedCodeInterpreterTool, Role
7-
from agent_framework_azure_ai import AzureAIAgentClient # Provided by agent_framework
6+
from agent_framework import (ChatAgent, ChatMessage, HostedCodeInterpreterTool,
7+
Role)
8+
from agent_framework_azure_ai import \
9+
AzureAIAgentClient # Provided by agent_framework
810
from azure.ai.projects.models import ConnectionType
911
from common.config.app_config import config
10-
from common.models.messages_af import TeamConfiguration
1112
from common.database.database_base import DatabaseBase
13+
from common.models.messages_af import TeamConfiguration
1214
from v4.common.services.team_service import TeamService
1315
from v4.config.agent_registry import agent_registry
1416
from v4.magentic_agents.common.lifecycle import AzureAgentBase
@@ -29,6 +31,7 @@ def __init__(
2931
agent_name: str,
3032
agent_description: str,
3133
agent_instructions: str,
34+
use_reasoning: bool,
3235
model_deployment_name: str,
3336
project_endpoint: str,
3437
enable_code_interpreter: bool = False,
@@ -57,6 +60,7 @@ def __init__(
5760

5861
# Decide early whether Azure Search mode should be activated
5962
self._use_azure_search = self._is_azure_search_requested()
63+
self.use_reasoning = use_reasoning
6064

6165
# Placeholder for server-created Azure AI agent id (if Azure Search path)
6266
self._azure_server_agent_id: Optional[str] = None
@@ -218,6 +222,13 @@ async def _create_azure_search_enabled_client(self, chatClient=None) -> Optional
218222
# -------------------------
219223
async def _after_open(self) -> None:
220224
"""Initialize ChatAgent after connections are established."""
225+
if self.use_reasoning:
226+
self.logger.info("Initializing agent in Reasoning mode.")
227+
temp = None
228+
else:
229+
self.logger.info("Initializing agent in Foundry mode.")
230+
temp = 0.1
231+
221232

222233
try:
223234
chatClient= await self.get_database_team_agent()
@@ -241,7 +252,7 @@ async def _after_open(self) -> None:
241252
name=self.agent_name,
242253
description=self.agent_description,
243254
tool_choice="required", # Force usage
244-
temperature=1.0,
255+
temperature=temp,
245256
model_id=self.model_deployment_name,
246257
)
247258
else:
@@ -256,7 +267,7 @@ async def _after_open(self) -> None:
256267
description=self.agent_description,
257268
tools=tools if tools else None,
258269
tool_choice="auto" if tools else "none",
259-
temperature=1.0,
270+
temperature=temp,
260271
model_id=self.model_deployment_name,
261272
)
262273

src/backend/v4/magentic_agents/magentic_agent_factory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
from typing import List, Optional, Union
88

99
from common.config.app_config import config
10-
from common.models.messages_af import TeamConfiguration
1110
from common.database.database_base import DatabaseBase
11+
from common.models.messages_af import TeamConfiguration
1212
from v4.common.services.team_service import TeamService
1313
from v4.magentic_agents.foundry_agent import FoundryAgentTemplate
1414
from v4.magentic_agents.models.agent_models import MCPConfig, SearchConfig
15-
1615
# from v4.magentic_agents.models.agent_models import (BingConfig, MCPConfig,
1716
# SearchConfig)
1817
from v4.magentic_agents.proxy_agent import ProxyAgent
@@ -128,6 +127,7 @@ async def create_agent_from_config(
128127
agent_name=agent_obj.name,
129128
agent_description=getattr(agent_obj, "description", ""),
130129
agent_instructions=getattr(agent_obj, "system_message", ""),
130+
use_reasoning=use_reasoning,
131131
model_deployment_name=deployment_name,
132132
enable_code_interpreter=getattr(agent_obj, "coding_tools", False),
133133
project_endpoint=config.AZURE_AI_PROJECT_ENDPOINT,

0 commit comments

Comments
 (0)