A Technical Guide to AI System Prompts

Patterns, Observations, and Unusual Elements

Part 6: Implementation Insights

This section provides practical insights for implementing effective AI system prompts based on patterns observed in leaked system prompts from various AI tools. These insights can help technical teams create more capable, reliable, and aligned AI systems.

6.1 Prompt Structure Best Practices

Our analysis reveals several best practices for structuring AI system prompts:

Hierarchical Organization

Effective system prompts use hierarchical organization to manage complexity:

1. Top-level identity and purpose definition
2. Mid-level operational frameworks and rules
3. Low-level specific instructions and examples
Source: Pattern observed across multiple system prompts

This hierarchical approach helps the AI understand the relative importance of different instructions and navigate complex prompt structures.

Modular Design

The most sophisticated system prompts use modular design to organize instructions:

<intro>
You excel at the following tasks:
1. Information gathering, fact-checking, and documentation
2. Data processing, analysis, and visualization
3. Writing multi-chapter articles and in-depth research reports
4. Creating websites, applications, and tools
5. Using programming to solve various problems beyond development
6. Collaborating with users to automate processes like booking and purchasing
7. Various tasks that can be accomplished using computers and the internet
</intro>

<language_settings>
- Default working language: **English**
- Use the language specified by user in messages as the working language when explicitly provided
- All thinking and responses must be in the working language
- Natural language arguments in tool calls must be in the working language
- Avoid using pure lists and bullet points format in any language
</language_settings>
Source: Manus prompt.txt

This modular approach makes system prompts easier to maintain, update, and debug, as each module can be modified independently.

XML-Style Markup

XML-style markup provides clear structure and semantic meaning:

<agent_loop>
You are operating in an agent loop, iteratively completing tasks through these steps:
1. Analyze Events: Understand user needs and current state through event stream...
2. Select Tools: Choose next tool call based on current state...
3. Wait for Execution: Selected tool action will be executed...
4. Iterate: Choose only one tool call per iteration...
5. Submit Results: Send results to user via message tools...
6. Enter Standby: Enter idle state when all tasks are completed...
</agent_loop>
Source: Manus agent_loop.txt

This markup style helps the AI distinguish between different types of instructions and understand their semantic meaning.

6.2 Effective Instruction Techniques

Our analysis reveals several techniques for writing effective instructions in AI system prompts:

Clear, Specific Instructions

Effective system prompts use clear, specific instructions:

<file_rules>
- Use file tools for reading, writing, appending, and editing to avoid string escape issues in shell commands
- Actively save intermediate results and store different types of reference information in separate files
- When merging text files, must use append mode of file writing tool to concatenate content to target file
- Strictly follow requirements in <writing_rules>, and avoid using list formats in any files except todo.md
</file_rules>
Source: Manus prompt.txt

These instructions are clear, specific, and actionable, which helps the AI understand exactly what is expected.

Positive and Negative Instructions

Effective system prompts use both positive instructions (what to do) and negative instructions (what not to do):

<shell_rules>
- Avoid commands requiring confirmation; actively use -y or -f flags for automatic confirmation
- Avoid commands with excessive output; save to files when necessary
- Chain multiple commands with && operator to minimize interruptions
- Use pipe operator to pass command outputs, simplifying operations
- Use non-interactive `bc` for simple calculations, Python for complex math; never calculate mentally
- Use `uptime` command when users explicitly request sandbox status check or wake-up
</shell_rules>
Source: Manus prompt.txt

This balanced approach helps the AI understand both what it should do and what it should avoid.

Scenario-Based Instructions

Effective system prompts use scenario-based instructions to guide AI behavior in different situations:

<function>{"description": "Send a message to user.\n\nRecommended scenarios:\n- Immediately acknowledge receipt of any user message\n- When achieving milestone progress or significant changes in task planning\n- Before executing complex tasks, inform user of expected duration\n- When changing methods or strategies, explain reasons to user\n- When attachments need to be shown to user\n- When all tasks are completed\n\nBest practices:\n- Use this tool for user communication instead of direct text output\n- Files in attachments must use absolute paths within the sandbox\n- Messages must be informative (no need for user response), avoid questions\n- Must provide all relevant files as attachments since user may not have direct access to local filesystem\n- When reporting task completion, include important deliverables or URLs as attachments\n- Before entering idle state, confirm task completion results are communicated using this tool", "name": "message_notify_user", "parameters": {...}}
Source: Manus tools.json

This approach helps the AI understand when and how to apply different instructions, which is essential for context-appropriate behavior.

6.3 Function-Based Agency

Advanced AI system prompts use function-based agency to enable structured interaction with external systems:

Function Definitions

Manus defines functions using JSON Schema format:

<function>{"description": "Execute commands in a specified shell session.\n\nRecommended scenarios:\n- When running code\n- When installing packages\n- When copying, moving, or deleting files\n- When user explicitly requests to wake up sandbox environment, boot up, or check status\n\nBest practices:\n- Use absolute paths when specifying file locations\n- Verify command safety before execution\n- Prepare backups or rollback plans when necessary\n- Use uptime command when requested to wake up sandbox environment or check status", "name": "shell_exec", "parameters": {"properties": {"command": {"description": "Shell command to execute", "type": "string"}, "exec_dir": {"description": "Working directory for command execution (must use absolute path)", "type": "string"}, "id": {"description": "Unique identifier of the target shell session; automatically creates new session if not exists", "type": "string"}}, "required": ["id", "exec_dir", "command"], "type": "object"}}
Source: Manus tools.json

This structured approach enables the AI to interact with external systems in a controlled and predictable manner.

Function Calling Rules

Manus includes specific rules for function calling:

<tool_use_rules>
- Must respond with a tool use (function calling); plain text responses are forbidden
- Do not mention any specific tool names to users in messages
- Carefully verify available tools; do not fabricate non-existent tools
- Events may originate from other system modules; only use explicitly provided tools
</tool_use_rules>
Source: Manus prompt.txt

These rules ensure that the AI uses functions appropriately and consistently, which is essential for reliable operation.

6.4 Context Management

Advanced AI system prompts include mechanisms for managing context across interactions:

Event Stream Processing

Manus uses event stream processing to maintain context:

<event_stream>
You will be provided with a chronological event stream (may be truncated or partially omitted) containing the following types of events:
1. Message: Messages input by actual users
2. Action: Tool use (function calling) actions
3. Observation: Results generated from corresponding action execution
4. Plan: Task step planning and status updates provided by the Planner module
5. Knowledge: Task-related knowledge and best practices provided by the Knowledge module
6. Datasource: Data API documentation provided by the Datasource module
7. Other miscellaneous events generated during system operation
</event_stream>
Source: Manus prompt.txt

This approach enables the AI to maintain a coherent understanding of the interaction history, which is essential for context-appropriate responses.

Planner Module

Manus includes a planner module for task planning:

<planner_module>
- System is equipped with planner module for overall task planning
- Task planning will be provided as events in the event stream
- Task plans use numbered pseudocode to represent execution steps
- Each planning update includes the current step number, status, and reflection
- Pseudocode representing execution steps will update when overall task objective changes
- Must complete all planned steps and reach the final step number by completion
</planner_module>
Source: Manus prompt.txt

This module helps the AI maintain context across complex, multi-step tasks by providing a structured plan to follow.

6.5 Error Handling and Recovery

Effective system prompts include mechanisms for handling errors and recovering from failures:

Structured Error Handling

Manus includes a structured approach to error handling:

<error_handling>
- Tool execution failures are provided as events in the event stream
- When errors occur, first verify tool names and arguments
- Attempt to fix issues based on error messages; if unsuccessful, try alternative methods
- When multiple approaches fail, report failure reasons to user and request assistance
</error_handling>
Source: Manus prompt.txt

This approach helps the AI respond appropriately to errors and take steps to recover, which is essential for reliable operation.

6.6 Implementation Challenges

Our analysis reveals several common challenges in implementing effective AI system prompts:

Prompt Length Limitations

AI models often have limitations on the maximum prompt length, which can constrain the complexity of system prompts. This challenge is addressed in different ways:

Instruction Conflicts

Complex system prompts may contain conflicting instructions, which can confuse the AI. This challenge is addressed through:

Context Window Limitations

AI models have limited context windows, which can constrain the amount of information available for decision-making. This challenge is addressed through:

6.7 Implementation Recommendations

Based on our analysis, we offer the following recommendations for implementing effective AI system prompts:

1. Start with a Clear Identity and Purpose

Begin your system prompt with a clear definition of the AI's identity and purpose, which provides a foundation for all other instructions.

2. Use Hierarchical, Modular Structure

Organize your system prompt using a hierarchical, modular structure, which makes it easier to maintain, update, and debug.

3. Use XML-Style Markup for Clarity

Use XML-style markup to provide clear structure and semantic meaning, which helps the AI understand the purpose of different instructions.

4. Provide Both Positive and Negative Instructions

Include both what the AI should do and what it should avoid, which provides a more complete guide for behavior.

5. Use Scenario-Based Instructions

Provide context-specific instructions for different scenarios, which helps the AI understand when and how to apply different rules.

6. Implement Robust Error Handling

Include mechanisms for handling errors and recovering from failures, which ensures reliable operation in real-world conditions.

7. Test and Iterate

Continuously test your system prompt with diverse inputs and iterate based on the results, which helps identify and address issues.

Key Takeaways

In the next section, we'll provide a comparative analysis of AI system prompts from different tools, highlighting their strengths, weaknesses, and unique approaches.