Skip to content

Commit 372ebd4

Browse files
committed
Add memory_store support to agent lifecycle classes
Introduces an optional memory_store (DatabaseBase) parameter to MCPEnabledBase, AzureAgentBase, FoundryAgentTemplate, and ReasoningAgentTemplate classes. This enables agents to utilize a shared database for memory storage, improving extensibility and future integration with persistent memory features.
1 parent fc05377 commit 372ebd4

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

src/backend/common/utils/utils_af.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ async def create_RAI_agent() -> FoundryAgentTemplate:
5151
"- Is completely meaningless, incoherent, or appears to be spam\n"
5252
"Respond with 'TRUE' if the input violates any rules and should be blocked, otherwise respond with 'FALSE'."
5353
)
54+
5455
model_deployment_name = config.AZURE_OPENAI_DEPLOYMENT_NAME
5556
agent = FoundryAgentTemplate(
5657
agent_name=agent_name,

src/backend/v4/api/router.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@
4444
)
4545

4646

47-
48-
49-
5047
@app_v4.websocket("/socket/{process_id}")
5148
async def start_comms(
5249
websocket: WebSocket, process_id: str, user_id: str = Query(None)

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from azure.ai.agents.aio import AgentsClient
2626
from azure.identity.aio import DefaultAzureCredential
2727
from common.models.messages_af import TeamConfiguration
28+
from common.database.database_base import DatabaseBase
2829
from v4.common.services.team_service import TeamService
2930
from v4.config.agent_registry import agent_registry
3031
from v4.magentic_agents.models.agent_models import MCPConfig
@@ -43,6 +44,7 @@ def __init__(
4344
team_service: TeamService | None = None,
4445
team_config: TeamConfiguration | None = None,
4546
project_endpoint: str | None = None,
47+
memory_store: DatabaseBase| None = None,
4648
) -> None:
4749
self._stack: AsyncExitStack | None = None
4850
self.mcp_cfg: MCPConfig | None = mcp
@@ -53,6 +55,7 @@ def __init__(
5355
self.client: Optional[AzureAIAgentClient] = None
5456
self.project_endpoint = project_endpoint
5557
self.creds: Optional[DefaultAzureCredential] = None
58+
self.memory_store: Optional[DatabaseBase] = memory_store
5659

5760
async def open(self) -> "MCPEnabledBase":
5861
if self._stack is not None:
@@ -154,8 +157,9 @@ def __init__(
154157
project_endpoint: str | None = None,
155158
team_service: TeamService | None = None,
156159
team_config: TeamConfiguration | None = None,
160+
memory_store: DatabaseBase | None = None,
157161
) -> None:
158-
super().__init__(mcp=mcp, team_service=team_service, team_config=team_config, project_endpoint=project_endpoint)
162+
super().__init__(mcp=mcp, team_service=team_service, team_config=team_config, project_endpoint=project_endpoint, memory_store=memory_store)
159163

160164
self._created_ephemeral: bool = (
161165
False # reserved if you add ephemeral agent cleanup

src/backend/v4/magentic_agents/foundry_agent.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from azure.ai.projects.models import ConnectionType
99
from common.config.app_config import config
1010
from common.models.messages_af import TeamConfiguration
11+
from src.backend.common.database.database_base import DatabaseBase
1112
from v4.common.services.team_service import TeamService
1213
from v4.config.agent_registry import agent_registry
1314
from v4.magentic_agents.common.lifecycle import AzureAgentBase
@@ -35,13 +36,15 @@ def __init__(
3536
search_config: SearchConfig | None = None,
3637
team_service: TeamService | None = None,
3738
team_config: TeamConfiguration | None = None,
39+
memory_store: DatabaseBase | None = None,
3840
) -> None:
3941
super().__init__(
4042
mcp=mcp_config,
4143
model_deployment_name=model_deployment_name,
4244
project_endpoint=project_endpoint,
4345
team_service=team_service,
4446
team_config=team_config,
47+
memory_store=memory_store,
4548
)
4649
self.agent_name = agent_name
4750
self.agent_description = agent_description

src/backend/v4/magentic_agents/reasoning_agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#from agent_framework.azure import AzureOpenAIChatClient
1717

1818
from common.models.messages_af import TeamConfiguration
19+
from src.backend.common.database.database_base import DatabaseBase
1920
from v4.common.services.team_service import TeamService
2021
from v4.magentic_agents.common.lifecycle import MCPEnabledBase
2122
from v4.magentic_agents.models.agent_models import MCPConfig, SearchConfig
@@ -48,6 +49,7 @@ def __init__(
4849
max_search_docs: int = 3,
4950
team_service: TeamService | None = None,
5051
team_config: TeamConfiguration | None = None,
52+
memory_store: DatabaseBase | None = None,
5153
) -> None:
5254
"""Initialize reasoning agent.
5355
@@ -61,7 +63,7 @@ def __init__(
6163
mcp_config: Optional MCP server configuration
6264
max_search_docs: Maximum number of search documents to retrieve
6365
"""
64-
super().__init__(mcp=mcp_config, team_service=team_service, team_config=team_config, project_endpoint=project_endpoint)
66+
super().__init__(mcp=mcp_config, team_service=team_service, team_config=team_config, project_endpoint=project_endpoint, memory_store=memory_store)
6567
self.agent_name = agent_name
6668
self.agent_description = agent_description
6769
self.base_instructions = agent_instructions

0 commit comments

Comments
 (0)