Skip to content

Commit 7766f9b

Browse files
committed
Update planner_agent.py
1 parent 540f5c6 commit 7766f9b

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/backend/kernel_agents/planner_agent.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -640,33 +640,25 @@ def _generate_instruction(self, objective: str) -> str:
640640
tools_str = str(tools_list)
641641

642642
# Build the instruction, avoiding backslashes in f-string expressions
643-
objective_part = f"Your objective is:\n{objective}" if objective else "When given an objective, analyze it and create a plan to accomplish it."
644-
645-
return f"""
643+
644+
instruction_template = f"""
646645
You are the Planner, an AI orchestrator that manages a group of AI agents to accomplish tasks.
647646
648647
For the given objective, come up with a simple step-by-step plan.
649648
This plan should involve individual tasks that, if executed correctly, will yield the correct answer. Do not add any superfluous steps.
650649
The result of the final step should be the final answer. Make sure that each step has all the information needed - do not skip steps.
651650
652651
These actions are passed to the specific agent. Make sure the action contains all the information required for the agent to execute the task.
653-
654-
{objective_part}
652+
653+
Your objective is:
654+
{objective}
655655
656656
The agents you have access to are:
657657
{agents_str}
658658
659659
These agents have access to the following functions:
660660
{tools_str}
661661
662-
IMPORTANT AGENT SELECTION GUIDANCE:
663-
- HrAgent: ALWAYS use for ALL employee-related tasks like onboarding, hiring, benefits, payroll, training, employee records, ID cards, mentoring, background checks, etc.
664-
- MarketingAgent: Use for marketing campaigns, branding, market research, content creation, social media, etc.
665-
- ProcurementAgent: Use for purchasing, vendor management, supply chain, asset management, etc.
666-
- ProductAgent: Use for product development, roadmaps, features, product feedback, etc.
667-
- TechSupportAgent: Use for technical issues, software/hardware setup, troubleshooting, IT support, etc.
668-
- GenericAgent: Use only for general knowledge tasks that don't fit other categories
669-
- HumanAgent: Use only when human input is absolutely required and no other agent can handle the task
670662
671663
The first step of your plan should be to ask the user for any additional information required to progress the rest of steps planned.
672664
@@ -676,15 +668,21 @@ def _generate_instruction(self, objective: str) -> str:
676668
677669
If there is a single function call that can directly solve the task, only generate a plan with a single step. For example, if someone asks to be granted access to a database, generate a plan with only one step involving the grant_database_access function, with no additional steps.
678670
671+
When generating the action in the plan, frame the action as an instruction you are passing to the agent to execute. It should be a short, single sentence. Include the function to use. For example, "Set up an Office 365 Account for Jessica Smith. Function: set_up_office_365_account"
672+
673+
Ensure the summary of the plan and the overall steps is less than 50 words.
674+
675+
Identify any additional information that might be required to complete the task. Include this information in the plan in the human_clarification_request field of the plan. If it is not required, leave it as null. Do not include information that you are waiting for clarification on in the string of the action field, as this otherwise won't get updated.
676+
679677
You must prioritise using the provided functions to accomplish each step. First evaluate each and every function the agents have access too. Only if you cannot find a function needed to complete the task, and you have reviewed each and every function, and determined why each are not suitable, there are two options you can take when generating the plan.
680678
First evaluate whether the step could be handled by a typical large language model, without any specialised functions. For example, tasks such as "add 32 to 54", or "convert this SQL code to a python script", or "write a 200 word story about a fictional product strategy".
681-
682679
If a general Large Language Model CAN handle the step/required action, add a step to the plan with the action you believe would be needed, and add "EXCEPTION: No suitable function found. A generic LLM model is being used for this step." to the end of the action. Assign these steps to the GenericAgent. For example, if the task is to convert the following SQL into python code (SELECT * FROM employees;), and there is no function to convert SQL to python, write a step with the action "convert the following SQL into python code (SELECT * FROM employees;) EXCEPTION: No suitable function found. A generic LLM model is being used for this step." and assign it to the GenericAgent.
683-
684680
Alternatively, if a general Large Language Model CAN NOT handle the step/required action, add a step to the plan with the action you believe would be needed, and add "EXCEPTION: Human support required to do this step, no suitable function found." to the end of the action. Assign these steps to the HumanAgent. For example, if the task is to find the best way to get from A to B, and there is no function to calculate the best route, write a step with the action "Calculate the best route from A to B. EXCEPTION: Human support required, no suitable function found." and assign it to the HumanAgent.
685681
682+
686683
Limit the plan to 6 steps or less.
687684
688685
Choose from {agents_str} ONLY for planning your steps.
689686
690-
"""
687+
"""
688+
return instruction_template

0 commit comments

Comments
 (0)