Skip to main content

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.
Define a clear identity and operational context for your agent:
  • 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
Example:
Provide specific instructions for how the agent should communicate:
  • 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
Example:

Tool Usage Framework

If your agent uses tools, establish clear guidelines:
  • 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
Example (simplified):

Information Gathering Strategy

Guide how the agent handles uncertainty and gathers comprehensive context:
  • 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
Example (simplified):
For domain-specific actions (like code changes), provide detailed protocols:
  • Execution rules: When and how to perform specific actions
  • Quality standards: Requirements for action outputs
  • Error handling: How to address common failure modes
Example:
Guide how the agent should interact with external systems:
  • 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
Example:
For tools available to the agent, provide comprehensive definitions:
  • 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
Example:
  • 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
Example:

Morph API Documentation

View our OpenAI-compatible API
To get your API key, visit the dashboard to create an account. For access to our latest models, self-hosting, or business inquiries, please contact us at info@morphllm.com.

Base URL