Prompt Development Guide
This guide provides comprehensive information about the prompt template system used in Nexent for creating different types of agents. The YAML files in the backend/prompts/
directory define system prompts, planning prompts, and other key prompt components for various agent types.
File Naming Convention
The naming format follows {agent_type}_agent.yaml
, where:
agent_type
: Describes the main function or purpose of the agent (e.g., manager, search, etc.)
Prompt Template Structure
Each YAML file contains the following main sections:
1. system_prompt
The system prompt is the core component of an agent, defining its role, capabilities, and behavioral guidelines. It typically includes:
- Core Responsibilities: Main duties and capabilities description
- Execution Flow: Standard process and methods for agent task execution
- Available Resources: List of tools and sub-agents the agent can use
- Resource Usage Requirements: Priority and strategy for using different tools
- Python Code Standards: Code writing standards and constraints
- Example Templates: Examples demonstrating agent task execution
2. planning
Contains various prompts for task planning:
- initial_facts: Initial fact collection prompts
- initial_plan: Initial plan formulation prompts
- update_facts_pre_messages: Prompts before updating facts
- update_facts_post_messages: Prompts after updating facts
- update_plan_pre_messages: Prompts before updating plans
- update_plan_post_messages: Prompts after updating plans
3. managed_agent
Defines prompts for sub-agent interactions:
- task: Task assignment prompts for sub-agents
- report: Prompts for sub-agent result reporting
4. final_answer
Defines prompts for final answer generation:
- pre_messages: Prompts before generating final answers
- post_messages: Prompts after generating final answers
5. tools_requirement
Defines prompts for tool usage standards and priorities.
6. few_shots
Provides few-shot learning examples to help agents better understand task execution methods.
Template Variables
The prompt templates use the following special variables for dynamic replacement:
: Available tools list
: Available sub-agents list
: Current task description
: Authorized Python module imports
: Updated facts list
: Known facts list
: Remaining execution steps
Available Prompt Templates
Core Templates
Manager Agent Templates
manager_system_prompt_template.yaml
- Chinese versionmanager_system_prompt_template_en.yaml
- English version
These templates define the core manager agent that coordinates and dispatches various assistants and tools to efficiently solve complex tasks.
Managed Agent Templates
managed_system_prompt_template.yaml
- Chinese versionmanaged_system_prompt_template_en.yaml
- English version
These templates define specialized agents that perform specific tasks under the coordination of the manager agent.
Specialized Agent Templates
knowledge_summary_agent.yaml
- Knowledge summary agent (Chinese)knowledge_summary_agent_en.yaml
- Knowledge summary agent (English)analyze_file.yaml
- File analysis agent (Chinese)analyze_file_en.yaml
- File analysis agent (English)
Utility Templates
Located in the utils/
directory:
Prompt Generation Templates
prompt_generate.yaml
- Chinese versionprompt_generate_en.yaml
- English version
These templates help generate efficient and clear prompts for different agent types.
Prompt Fine-tuning Templates
prompt_fine_tune.yaml
- Chinese versionprompt_fine_tune_en.yaml
- English version
Templates for fine-tuning and optimizing existing prompts.
Title Generation Templates
generate_title.yaml
- For generating titles and summaries
Execution Flow
The standard agent execution flow follows this pattern:
- Think: Analyze current task status and progress
- Code: Write simple Python code following standards
- Observe: View code execution results
- Repeat: Continue the cycle until the task is complete
Code Standards
When writing Python code in prompts:
- Use the format
代码:\n```py\n
for executable code - Use the format
代码:\n```code:language_type\n
for display-only code - Use only defined variables that persist across calls
- Use
print()
function to make variable information visible - Use keyword parameters for tool and agent calls
- Avoid excessive tool calls in a single round
- Only import from authorized modules:
Best Practices
- Task Decomposition: Break complex tasks into manageable sub-tasks
- Professional Matching: Assign tasks based on agent expertise
- Information Integration: Integrate outputs from different agents
- Efficiency Optimization: Avoid redundant work
- Result Evaluation: Assess agent return results and provide additional guidance when needed
Example Usage
Here's an example of how a manager agent might coordinate with specialized agents:
# Example task assignment
managed_agent:
task: |
Please analyze the provided document and extract key insights.
report: |
{{final_answer}}
This system allows for flexible and powerful agent coordination while maintaining clear standards and best practices for prompt development.