Skip to main content
This guide demonstrates how to create custom agents tailored for specific use cases. Using the planning agent as a concrete example, you’ll learn how to design specialized agents with custom tool sets, system prompts, and configurations that optimize performance for particular workflows. The example showcases a two-phase workflow where a custom planning agent (with read-only tools) analyzes tasks and creates structured plans, followed by an execution agent that implements those plans with full editing capabilities.
examples/01_standalone_sdk/24_planning_agent_workflow.py
You can run the example code as-is.
The model name should follow the LiteLLM convention: provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o). The LLM_API_KEY should be the API key for your chosen provider.
ChatGPT Plus/Pro subscribers: You can use LLM.subscription_login() to authenticate with your ChatGPT account and access Codex models without consuming API credits. See the LLM Subscriptions guide for details.

Anatomy of a Custom Agent

The planning agent demonstrates the two key components for creating specialized agent:

1. Custom Tool Selection

Choose tools that match your agent’s specific role. Here’s how the planning agent defines its tools:
The planning agent uses:
  • GlobTool: For discovering files and directories matching patterns
  • GrepTool: For searching specific content across files
  • PlanningFileEditorTool: For writing structured plans to PLAN.md only
This read-only approach (except for PLAN.md) keeps the agent focused on analysis without implementation distractions.

2. System Prompt Customization

Custom agents can use specialized system prompts to guide behavior. The planning agent uses system_prompt_planning.j2 with injected plan structure that enforces:
  1. Objective: Clear goal statement
  2. Context Summary: Relevant system components and constraints
  3. Approach Overview: High-level strategy and rationale
  4. Implementation Steps: Detailed step-by-step execution plan
  5. Testing and Validation: Verification methods and success criteria

Complete Implementation Reference

For a complete implementation example showing all these components working together, refer to the planning agent preset source code.

Next Steps