Skip to content

Commit abca384

Browse files
committed
Added prompt for tools use with HIL
1 parent b8f11cd commit abca384

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

src/backend/v3/orchestration/human_approval_manager.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from semantic_kernel.agents import Agent
1111
from semantic_kernel.agents.orchestration.magentic import (
1212
MagenticContext, StandardMagenticManager)
13+
from semantic_kernel.agents.orchestration.prompts._magentic_prompts import \
14+
ORCHESTRATOR_TASK_LEDGER_FACTS_PROMPT
1315
from semantic_kernel.contents import ChatMessageContent
1416
from v3.config.settings import connection_config, current_user_id
1517
from v3.models.models import MPlan, MStep
@@ -28,10 +30,22 @@ class HumanApprovalMagenticManager(StandardMagenticManager):
2830

2931
def __init__(self, *args, **kwargs):
3032
# Remove any custom kwargs before passing to parent
31-
super().__init__(*args, **kwargs)
33+
3234
# Use object.__setattr__ to bypass Pydantic validation
3335
# object.__setattr__(self, 'current_user_id', None)
36+
37+
custom_addition = """
38+
39+
ADDITIONAL INSTRUCTIONS:
40+
To address this request we have assembled the following team:
41+
42+
{{$team}}
43+
44+
Please check with the team members to list all relevant tools they have access to, and their required parameters."""
45+
46+
kwargs['task_ledger_facts_prompt'] = ORCHESTRATOR_TASK_LEDGER_FACTS_PROMPT + custom_addition
3447

48+
super().__init__(*args, **kwargs)
3549

3650
async def plan(self, magentic_context: MagenticContext) -> Any:
3751
"""
@@ -44,12 +58,12 @@ async def plan(self, magentic_context: MagenticContext) -> Any:
4458
elif not isinstance(task_text, str):
4559
task_text = str(task_text)
4660

47-
print(f"\n🎯 Human-in-the-Loop Magentic Manager Creating Plan:")
61+
print(f"\n Human-in-the-Loop Magentic Manager Creating Plan:")
4862
print(f" Task: {task_text}")
4963
print("-" * 60)
5064

5165
# First, let the parent create the actual plan
52-
print("📋 Creating execution plan...")
66+
print(" Creating execution plan...")
5367
plan = await super().plan(magentic_context)
5468
self.magentic_plan = self.plan_to_obj( magentic_context, self.task_ledger)
5569

@@ -110,19 +124,19 @@ async def prepare_final_answer(self, magentic_context: MagenticContext) -> ChatM
110124
"""
111125
Override to ensure final answer is prepared after all steps are executed.
112126
"""
113-
print("\n📝 Magentic Manager - Preparing final answer...")
127+
print("\n Magentic Manager - Preparing final answer...")
114128

115129
return await super().prepare_final_answer(magentic_context)
116130

117131
async def _get_plan_approval_with_details(self, task: str, participant_descriptions: dict, plan: Any) -> bool:
118132
while True:
119-
approval = input("\n Approve this execution plan? [y/n/details]: ").strip().lower()
133+
approval = input("\ Approve this execution plan? [y/n/details]: ").strip().lower()
120134

121135
if approval in ['y', 'yes']:
122-
print(" Plan approved by user")
136+
print(" Plan approved by user")
123137
return True
124138
elif approval in ['n', 'no']:
125-
print(" Plan rejected by user")
139+
print(" Plan rejected by user")
126140
return False
127141
# elif approval in ['d', 'details']:
128142
# self._show_detailed_plan_info(task, participant_descriptions, plan)

0 commit comments

Comments
 (0)