Skip to content

Commit fcd52f5

Browse files
authored
Merge pull request #617 from microsoft/marktayl-macae-rfp-agent-framework
Marktayl macae rfp agent framework
2 parents 6a6fdda + 8d245a6 commit fcd52f5

File tree

7 files changed

+2268
-886
lines changed

7 files changed

+2268
-886
lines changed

src/backend/pyproject.toml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@ description = "Add your description here"
55
readme = "README.md"
66
requires-python = ">=3.11"
77
dependencies = [
8-
"agent-framework-core @ git+https://github.com/microsoft/agent-framework.git@main#subdirectory=python/packages/core",
9-
"agent-framework-azure-ai @ git+https://github.com/microsoft/agent-framework.git@main#subdirectory=python/packages/azure-ai",
10-
"agent-framework-copilotstudio @ git+https://github.com/microsoft/agent-framework.git@main#subdirectory=python/packages/copilotstudio",
11-
"agent-framework-devui @ git+https://github.com/microsoft/agent-framework.git@main#subdirectory=python/packages/devui",
12-
"agent-framework-mem0 @ git+https://github.com/microsoft/agent-framework.git@main#subdirectory=python/packages/mem0",
13-
"agent-framework-redis @ git+https://github.com/microsoft/agent-framework.git@main#subdirectory=python/packages/redis",
148
"azure-ai-evaluation==1.11.0",
159
"azure-ai-inference==1.0.0b9",
1610
"azure-ai-projects==1.0.0",
17-
"azure-ai-agents==1.2.0b5",
11+
"azure-ai-agents==1.2.0b5",
1812
"azure-cosmos==4.9.0",
1913
"azure-identity==1.24.0",
2014
"azure-monitor-events-extension==0.1.0",
@@ -37,6 +31,6 @@ dependencies = [
3731
"uvicorn==0.35.0",
3832
"pylint-pydantic==0.3.5",
3933
"pexpect==4.9.0",
40-
"mcp==1.13.1"
41-
34+
"mcp==1.13.1",
35+
"agent-framework>=1.0.0b251105",
4236
]

src/backend/uv.lock

Lines changed: 415 additions & 162 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,18 @@
44
from contextlib import AsyncExitStack
55
from typing import Any, Optional
66

7+
from agent_framework import (AggregateContextProvider, ChatAgent,
8+
ChatClientProtocol, ChatMessage,
9+
ChatMessageStoreProtocol, ChatOptions,
10+
ContextProvider, HostedMCPTool,
11+
MCPStreamableHTTPTool, Middleware, Role, ToolMode,
12+
ToolProtocol)
713
# from agent_framework.azure import AzureAIAgentClient
814
from agent_framework_azure_ai import AzureAIAgentClient
15+
from azure.ai.agents.aio import AgentsClient
916
from azure.identity.aio import DefaultAzureCredential
10-
from agent_framework import (
11-
ChatMessage,
12-
Role,
13-
ChatOptions,
14-
HostedMCPTool,
15-
AggregateContextProvider,
16-
ChatAgent,
17-
ChatClientProtocol,
18-
ChatMessageStoreProtocol,
19-
ContextProvider,
20-
Middleware,
21-
ToolMode,
22-
ToolProtocol,
23-
)
24-
from agent_framework import MCPStreamableHTTPTool
25-
26-
from v4.magentic_agents.models.agent_models import MCPConfig
2717
from v4.config.agent_registry import agent_registry
18+
from v4.magentic_agents.models.agent_models import MCPConfig
2819

2920

3021
class MCPEnabledBase:
@@ -44,7 +35,7 @@ async def open(self) -> "MCPEnabledBase":
4435
if self._stack is not None:
4536
return self
4637
self._stack = AsyncExitStack()
47-
self._prepare_mcp_tool()
38+
await self._prepare_mcp_tool()
4839
await self._after_open()
4940
return self
5041

@@ -133,10 +124,16 @@ async def open(self) -> "AzureAgentBase":
133124
await self._stack.enter_async_context(self.creds)
134125

135126
# Create AIProjectClient
136-
self.client = AzureAIAgentClient(
137-
project_endpoint=self.project_endpoint,
138-
model_deployment_name=self.model_deployment_name,
139-
async_credential=self.creds,
127+
# self.client = AzureAIAgentClient(
128+
# project_endpoint=self.project_endpoint,
129+
# model_deployment_name=self.model_deployment_name,
130+
# async_credential=self.creds,
131+
# )
132+
133+
#Create AgentsClient
134+
self.client = AgentsClient(
135+
endpoint=self.project_endpoint,
136+
credential=self.creds,
140137
)
141138
await self._stack.enter_async_context(self.client)
142139

src/backend/v4/magentic_agents/foundry_agent.py

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

6-
from agent_framework import (
7-
ChatAgent,
8-
ChatMessage,
9-
Role,
10-
HostedCodeInterpreterTool,
11-
)
6+
from agent_framework import (ChatAgent, ChatMessage, HostedCodeInterpreterTool,
7+
Role)
8+
from agent_framework_azure_ai import \
9+
AzureAIAgentClient # Provided by agent_framework
10+
from azure.ai.projects.aio import AIProjectClient
1211
from azure.ai.projects.models import ConnectionType
13-
from agent_framework_azure_ai import AzureAIAgentClient # Provided by agent_framework
14-
15-
12+
from common.config.app_config import config
13+
from v4.config.agent_registry import agent_registry
1614
from v4.magentic_agents.common.lifecycle import AzureAgentBase
1715
from v4.magentic_agents.models.agent_models import MCPConfig, SearchConfig
18-
from v4.config.agent_registry import agent_registry
1916

2017

2118
class FoundryAgentTemplate(AzureAgentBase):
@@ -45,6 +42,7 @@ def __init__(
4542
self.enable_code_interpreter = enable_code_interpreter
4643
self.search = search_config
4744
self.logger = logging.getLogger(__name__)
45+
self.project_client = config.get_ai_project_client()
4846

4947
# Decide early whether Azure Search mode should be activated
5048
self._use_azure_search = self._is_azure_search_requested()
@@ -128,7 +126,7 @@ async def _create_azure_search_enabled_client(self):
128126
resolved_connection_id = None
129127

130128
try:
131-
async for connection in self.client.project_client.connections.list():
129+
async for connection in self.project_client.connections.list():
132130
if connection.type == ConnectionType.AZURE_AI_SEARCH:
133131
# Allow direct id override
134132
if desired_connection_id and connection.id == desired_connection_id:
@@ -164,7 +162,7 @@ async def _create_azure_search_enabled_client(self):
164162

165163
# Create agent with raw tool
166164
try:
167-
azure_agent = await self.client.project_client.agents.create_agent(
165+
azure_agent = await self.client.create_agent(
168166
model=self.model_deployment_name,
169167
name=self.agent_name,
170168
instructions=(
@@ -193,8 +191,10 @@ async def _create_azure_search_enabled_client(self):
193191
)
194192

195193
chat_client = AzureAIAgentClient(
196-
project_client=self.client.project_client,
194+
project_client=self.project_client,
195+
#agents_client=self.client,
197196
agent_id=azure_agent.id,
197+
async_credential=self.creds,
198198
)
199199
return chat_client
200200
except Exception as ex:
@@ -233,7 +233,11 @@ async def _after_open(self) -> None:
233233
self.logger.info("Initializing agent in MCP mode.")
234234
tools = await self._collect_tools()
235235
self._agent = ChatAgent(
236-
chat_client=self.client,
236+
chat_client=AzureAIAgentClient(
237+
project_endpoint=self.project_endpoint,
238+
model_deployment_name=self.model_deployment_name,
239+
async_credential=self.creds,
240+
),
237241
instructions=self.agent_instructions,
238242
name=self.agent_name,
239243
description=self.agent_description,
@@ -293,23 +297,24 @@ async def close(self) -> None:
293297
# -------------------------
294298
# Factory
295299
# -------------------------
296-
async def create_foundry_agent(
297-
agent_name: str,
298-
agent_description: str,
299-
agent_instructions: str,
300-
model_deployment_name: str,
301-
mcp_config: MCPConfig | None,
302-
search_config: SearchConfig | None,
303-
) -> FoundryAgentTemplate:
304-
"""Factory to create and open a FoundryAgentTemplate."""
305-
agent = FoundryAgentTemplate(
306-
agent_name=agent_name,
307-
agent_description=agent_description,
308-
agent_instructions=agent_instructions,
309-
model_deployment_name=model_deployment_name,
310-
enable_code_interpreter=True,
311-
mcp_config=mcp_config,
312-
search_config=search_config,
313-
)
314-
await agent.open()
315-
return agent
300+
# async def create_foundry_agent(
301+
# agent_name: str,
302+
# agent_description: str,
303+
# agent_instructions: str,
304+
# model_deployment_name: str,
305+
# mcp_config: MCPConfig | None,
306+
# search_config: SearchConfig | None,
307+
# ) -> FoundryAgentTemplate:
308+
# """Factory to create and open a FoundryAgentTemplate."""
309+
# agent = FoundryAgentTemplate(
310+
# agent_name=agent_name,
311+
# agent_description=agent_description,
312+
# agent_instructions=agent_instructions,
313+
# model_deployment_name=model_deployment_name,
314+
# enable_code_interpreter=True,
315+
# mcp_config=mcp_config,
316+
# search_config=search_config,
317+
318+
# )
319+
# await agent.open()
320+
# return agent

src/frontend/pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,11 @@ version = "0.1.0"
44
description = "Add your description here"
55
readme = "README.md"
66
requires-python = ">=3.11"
7-
dependencies = []
7+
dependencies = [
8+
"fastapi",
9+
"uvicorn[standard]>=0.38.0",
10+
"jinja2",
11+
"azure-identity",
12+
"python-dotenv",
13+
"python-multipart",
14+
]

0 commit comments

Comments
 (0)