PromptExpanderAgent.
Quick Start
How It Works
Workflow
- Receive short prompt
- Optionally gather context via tools
- Apply expansion strategy
- Return detailed, actionable prompt
Setup
Run — Python
Run — CLI
Run — agents.yaml
Serve API
Expansion Strategies
BASIC
Simple expansion with clarity improvements. Fixes ambiguity and adds minimal context.
DETAILED
Rich expansion with context, constraints, format guidance, and quality expectations.
STRUCTURED
Expansion with clear sections: Task, Format, Requirements, Style, Constraints.
CREATIVE
Expansion with vivid, inspiring language and creative direction.
Basic Usage
Using Specific Strategies
Using Tools for Context
Configuration Options
ExpandResult Properties
Convenience Methods
Key Difference from Query Rewriter
| Feature | Query Rewriter | Prompt Expander |
|---|---|---|
| Purpose | Optimize for search/retrieval | Expand for task execution |
| Use Case | RAG applications | Task prompts |
| Output | Search-optimized queries | Detailed action prompts |
| CLI Flag | --query-rewrite | --expand-prompt |
Example: Movie Script
Input:Monitor / Verify
Features Demonstrated
| Feature | Implementation |
|---|---|
| Workflow | Single-step prompt expansion |
| Observability | --verbose flag |
| Tools | Optional context-gathering tools |
| Structured Output | ExpandResult with metadata |
Best Practices
Match the strategy to the goal
Match the strategy to the goal
Use
BASIC to fix ambiguity, STRUCTURED for task specs, and CREATIVE for writing prompts. The wrong strategy over- or under-expands the request.Raise temperature for creative expansion
Raise temperature for creative expansion
Creative strategies benefit from a higher
temperature. Keep it low for structured, deterministic expansions where you want repeatable output.Attach tools to ground the expansion
Attach tools to ground the expansion
Pass
tools=[search_tool] so the agent pulls real context before expanding — useful when the prompt references current events or your own data.Use Query Rewriter for search, not expansion
Use Query Rewriter for search, not expansion
This agent enriches prompts for task execution. To optimise text for retrieval and RAG, use the Query Rewriter Agent instead.
Related
Optimise queries for search and retrieval.
Feed an expanded prompt into a research workflow.

