11import json
2- import os
32from textwrap import dedent , indent
43
54from beeai_framework .agents .experimental import RequirementAgent
65from beeai_framework .agents .experimental .prompts import (
76 RequirementAgentSystemPromptInput ,
8- RequirementAgentTaskPromptInput ,
97)
10- from beeai_framework .agents .experimental .requirements .ask_permission import AskPermissionRequirement
118from beeai_framework .agents .experimental .requirements .conditional import ConditionalRequirement
9+ from beeai_framework .memory import BaseMemory
1210from beeai_framework .middleware .trajectory import GlobalTrajectoryMiddleware
1311from beeai_framework .template import PromptTemplate , PromptTemplateInput
1412from beeai_framework .tools import Tool
1513from beeai_framework .tools .handoff import HandoffTool
1614
1715from agents .agent_analyst import get_agent_analyst
1816from agents .agent_writer import get_agent_writer
17+ from agents .session_context import SessionContext
1918from agents .simple_think import SimpleThinkTool
20- from agents .utils import ToolNotFoundError , create_repo_scoped_tool , get_tools_by_names , llm , session_manager
19+ from agents .utils import ToolNotFoundError , create_repo_scoped_tool , get_tools_by_names
2120
2221
23- async def get_agent_manager ():
22+ async def get_agent_manager (session_context : SessionContext , memory : BaseMemory ):
2423 """Create and configure the issue workflow management agent."""
25- tools = await session_manager .get_tools ()
24+ tools = await session_context .get_tools ()
2625
2726 try :
2827 tools = await get_tools_by_names (tools , ["create_issue" , "list_issue_types" ])
@@ -32,9 +31,9 @@ async def get_agent_manager():
3231
3332 for tool in tools :
3433 if tool .name == "create_issue" :
35- create_issue = await create_repo_scoped_tool (tool )
34+ create_issue = await create_repo_scoped_tool (tool , session_context . get_repository () )
3635 elif tool .name == "list_issue_types" :
37- list_issue_types = await create_repo_scoped_tool (tool )
36+ list_issue_types = await create_repo_scoped_tool (tool , session_context . get_repository () )
3837
3938 except ToolNotFoundError as e :
4039 raise RuntimeError (f"Failed to configure the agent: { e } " ) from e
@@ -55,13 +54,11 @@ async def get_agent_manager():
5554 issue_types_lines = [f"- { issue_type ['name' ]} : { issue_type ['description' ]} " for issue_type in issue_types_data ]
5655 issue_types_text = indent ("\n " .join (issue_types_lines ), " " )
5756
58- repository = os .getenv ("GITHUB_REPOSITORY" )
59-
6057 role = "helpful coordinator"
6158 instruction = f"""\
6259 As the Coordinator, your responsibilities include routing tasks to experts, managing processes sequentially, and handling all user-facing communication. You do not perform technical writing or reasoning yourself.
6360
64- You work in the following repository: { repository }
61+ You work in the following repository: { session_context . get_repository () }
6562
6663## Operating Principles
6764- Manage the full lifecycle of a GitHub issue from user request to creation.
@@ -113,8 +110,8 @@ async def get_agent_manager():
113110"""
114111
115112 # Get the specialized agents
116- writer = await get_agent_writer ()
117- analyst = await get_agent_analyst ()
113+ writer = await get_agent_writer (session_context )
114+ analyst = await get_agent_analyst (session_context )
118115
119116 handoff_writer = HandoffTool (
120117 target = writer ,
@@ -171,8 +168,9 @@ async def get_agent_manager():
171168
172169 return RequirementAgent (
173170 name = "Project Manager" ,
174- llm = llm ,
171+ llm = session_context . get_llm () ,
175172 role = role ,
173+ memory = memory ,
176174 instructions = instruction ,
177175 tools = [
178176 SimpleThinkTool (),
@@ -182,7 +180,7 @@ async def get_agent_manager():
182180 ],
183181 requirements = [
184182 ConditionalRequirement (SimpleThinkTool , force_at_step = 1 , force_after = [Tool ], consecutive_allowed = False ),
185- AskPermissionRequirement (create_issue ),
183+ # AskPermissionRequirement(create_issue),
186184 ],
187185 templates = {
188186 "system" : PromptTemplate (PromptTemplateInput (schema = RequirementAgentSystemPromptInput , template = template )),
0 commit comments