Agent Prompting
Learn how to use prompt models like Claude, GPT-4o, and Gemini optimized for agentic workflows.General
- Use the
system
prompt to give instructions to the model. - Use the
user
prompt to give the model a task to complete. - Use XML for structuring your prompt.
Identity and Purpose
Identity and Purpose
Define a clear identity and operational context for your agent:Example:
- Clear role definition: “You are a powerful agentic AI coding assistant”
- Operational context: “You operate exclusively in [specific environment]”
- Relationship model: “You are pair programming with a USER”
- Task scope: Define the types of tasks the agent should expect
Communication Guidelines
Communication Guidelines
Provide specific instructions for how the agent should communicate:Example:
- Style: “Be concise and do not repeat yourself”
- Tone: “Be conversational but professional”
- Formatting: “Format your responses in markdown”
- Boundaries: Set clear limits on what information should not be shared
Tool Usage Framework
Tool Usage Framework
If your agent uses tools, establish clear guidelines:Example (simplified):
- Schema adherence: Always follow tool call schemas exactly as specified
- Tool availability: Only use tools that are explicitly provided
- Natural communication: Never refer to tool names when communicating with users
- Autonomous operation: Execute plans immediately without waiting for confirmation
- Information gathering: Prefer tool calls over asking users for information
Information Gathering Strategy
Information Gathering Strategy
Guide how the agent handles uncertainty and gathers comprehensive context:Example (simplified):
- Thoroughness: Ensure you have the FULL picture before replying
- Symbol tracing: Track every symbol back to its definitions and usages
- Exploration depth: Look beyond first results for comprehensive coverage
- Semantic search mastery: Use broad queries and multiple search variations
- Self-sufficiency: Bias towards finding answers independently
Action Protocols
Action Protocols
For domain-specific actions (like code changes), provide detailed protocols:Example:
- Execution rules: When and how to perform specific actions
- Quality standards: Requirements for action outputs
- Error handling: How to address common failure modes
External Resources
External Resources
Guide how the agent should interact with external systems:Example:
- Authorization: When permission is/isn’t needed to use external resources
- Selection criteria: How to choose between alternative resources
- Security considerations: Best practices for handling sensitive information
Function Definitions
Function Definitions
For tools available to the agent, provide comprehensive definitions:Example:
- Purpose: Clear description of what the function does
- Parameters: Required and optional inputs with types
- Usage guidelines: When and how to use the function
- Examples: Sample implementations for common scenarios
Best Practices
Best Practices
- Compartmentalize information into logical sections with clear boundaries
- Be specific with concrete examples and explicit rules
- Establish hierarchy with clear priorities and decision frameworks
- Create guardrails to prevent common AI pitfalls
- Balance autonomy by defining freedom within constraints
- Test and iterate on your prompt structure based on agent performance
Morph API Documentation
View our OpenAI-compatible API