Skip to content

Commit da4091a

Browse files
Merge pull request #810 from microsoft/ab-agentframeworkv2-changes
feat: Agent framework - Upgrading to new Foundry Agents changes
2 parents b12fd8e + 6a0462b commit da4091a

File tree

13 files changed

+507
-1863
lines changed

13 files changed

+507
-1863
lines changed

src/backend/app.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33

44
from contextlib import asynccontextmanager
55

6+
from common.config.app_config import config
7+
8+
# Configure logging levels FIRST, before any logging calls
9+
logging.basicConfig(level=getattr(logging, config.AZURE_BASIC_LOGGING_LEVEL.upper(), logging.INFO))
10+
611

712
from azure.monitor.opentelemetry import configure_azure_monitor
8-
from common.config.app_config import config
13+
# from common.config.app_config import config
914
from common.models.messages_af import UserLanguage
1015

1116
# FastAPI imports
@@ -61,7 +66,7 @@ async def lifespan(app: FastAPI):
6166
)
6267

6368
# Configure logging levels from environment variables
64-
logging.basicConfig(level=getattr(logging, config.AZURE_BASIC_LOGGING_LEVEL.upper(), logging.INFO))
69+
# logging.basicConfig(level=getattr(logging, config.AZURE_BASIC_LOGGING_LEVEL.upper(), logging.INFO))
6570

6671
# Configure Azure package logging levels
6772
azure_level = getattr(logging, config.AZURE_PACKAGE_LOGGING_LEVEL.upper(), logging.WARNING)
@@ -73,6 +78,8 @@ async def lifespan(app: FastAPI):
7378

7479
logging.getLogger("opentelemetry.sdk").setLevel(logging.ERROR)
7580

81+
logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(logging.WARNING)
82+
7683
# Initialize the FastAPI app
7784
app = FastAPI(lifespan=lifespan)
7885

src/backend/common/utils/utils_af.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,15 @@ async def create_RAI_agent(
8888
)
8989

9090
model_deployment_name = config.AZURE_OPENAI_RAI_DEPLOYMENT_NAME
91-
team.team_id = "rai_team" # Use a fixed team ID for RAI agent
92-
team.name = "RAI Team"
93-
team.description = "Team responsible for Responsible AI checks"
91+
92+
# Create a copy to avoid mutating the caller's team config.
93+
# The original team object is reused later (e.g., for orchestration init),
94+
# so mutating it would corrupt the real team name/id.
95+
rai_team = team.model_copy()
96+
rai_team.team_id = "rai_team"
97+
rai_team.name = "RAI Team"
98+
rai_team.description = "Team responsible for Responsible AI checks"
99+
94100
agent = FoundryAgentTemplate(
95101
agent_name=agent_name,
96102
agent_description=agent_description,
@@ -101,7 +107,7 @@ async def create_RAI_agent(
101107
project_endpoint=config.AZURE_AI_PROJECT_ENDPOINT,
102108
mcp_config=None,
103109
search_config=None,
104-
team_config=team,
110+
team_config=rai_team,
105111
memory_store=memory_store,
106112
)
107113

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11

2-
import logging
32
import secrets
43
import string
5-
from typing import Optional
6-
7-
from common.database.database_base import DatabaseBase
8-
from common.models.messages_af import TeamConfiguration
94

105

116
def generate_assistant_id(prefix: str = "asst_", length: int = 24) -> str:
@@ -21,22 +16,3 @@ def generate_assistant_id(prefix: str = "asst_", length: int = 24) -> str:
2116
# cryptographically strong randomness
2217
random_part = "".join(secrets.choice(alphabet) for _ in range(length))
2318
return f"{prefix}{random_part}"
24-
25-
26-
async def get_database_team_agent_id(
27-
memory_store: DatabaseBase, team_config: TeamConfiguration, agent_name: str
28-
) -> Optional[str]:
29-
"""Retrieve existing team agent from database, if any."""
30-
agent_id = None
31-
try:
32-
currentAgent = await memory_store.get_team_agent(
33-
team_id=team_config.team_id, agent_name=agent_name
34-
)
35-
if currentAgent and currentAgent.agent_foundry_id:
36-
agent_id = currentAgent.agent_foundry_id
37-
38-
except (
39-
Exception
40-
) as ex: # Consider narrowing this to specific exceptions if possible
41-
logging.error("Failed to initialize Get database team agent: %s", ex)
42-
return agent_id

src/backend/pyproject.toml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,37 @@ requires-python = ">=3.11"
77
dependencies = [
88
"azure-ai-evaluation==1.11.0",
99
"azure-ai-inference==1.0.0b9",
10-
"azure-ai-projects==1.0.0",
11-
"azure-ai-agents==1.2.0b5",
10+
"azure-ai-projects==2.0.0b3",
1211
"azure-cosmos==4.9.0",
1312
"azure-identity==1.24.0",
1413
"azure-monitor-events-extension==0.1.0",
15-
"azure-monitor-opentelemetry==1.7.0",
14+
"azure-monitor-opentelemetry==1.8.5",
1615
"azure-search-documents==11.5.3",
1716
"fastapi==0.116.1",
18-
"openai==1.105.0",
19-
"opentelemetry-api==1.36.0",
20-
"opentelemetry-exporter-otlp-proto-grpc==1.36.0",
21-
"opentelemetry-exporter-otlp-proto-http==1.36.0",
22-
"opentelemetry-instrumentation-fastapi==0.57b0",
17+
"openai==2.16.0",
18+
"opentelemetry-api==1.39.0",
19+
"opentelemetry-exporter-otlp-proto-grpc==1.39.0",
20+
"opentelemetry-exporter-otlp-proto-http==1.39.0",
21+
"opentelemetry-instrumentation-fastapi==0.60b0",
2322
"opentelemetry-instrumentation-openai==0.46.2",
24-
"opentelemetry-sdk==1.36.0",
23+
"opentelemetry-sdk==1.39.0",
2524
"pytest==8.4.1",
2625
"pytest-asyncio==0.24.0",
2726
"pytest-cov==5.0.0",
2827
"python-dotenv==1.1.1",
2928
"python-multipart==0.0.22",
30-
"semantic-kernel==1.39.4",
3129
"uvicorn==0.35.0",
3230
"pylint-pydantic==0.3.5",
3331
"pexpect==4.9.0",
3432
"mcp==1.26.0",
3533
"werkzeug==3.1.5",
3634
"azure-core==1.38.0",
37-
"agent-framework>=1.0.0b251105",
35+
"agent-framework-azure-ai==1.0.0b260130",
36+
"agent-framework-core==1.0.0b260130",
3837
"urllib3==2.6.3",
3938
"protobuf==5.29.6",
4039
"cryptography==46.0.5",
4140
"aiohttp==3.13.3",
4241
"pyasn1==0.6.2",
4342
"nltk==3.9.3",
44-
]
43+
]

0 commit comments

Comments
 (0)