ContextAgent.
ContextAgent is a specialized agent for Context Engineering - comprehensive codebase analysis and Product Requirements Prompt (PRP) generation.
Not to be confused with Context Window Management (
context=ContextConfig()).
This agent analyzes codebases and generates implementation guidance, while ContextConfig manages token budgets and compaction.Quick Start
How It Works
Key Features
| Feature | Description |
|---|---|
| Codebase Analysis | Analyze project structure, patterns, conventions |
| AST Analysis | Extract classes, functions, imports from Python |
| Pattern Extraction | Identify code patterns and architecture |
| PRP Generation | Create comprehensive implementation guidance |
| Validation Framework | Define success criteria and quality gates |
| Implementation Blueprint | Step-by-step implementation plan |
| GitHub Integration | Analyze GitHub repositories directly |
API Reference
Core Methods
Async Methods
Configurable Output
Control output using theoutput= parameter (inherited from Agent):
Protocol Compliance
ContextAgent implementsContextEngineerProtocol:
GitHub Analysis
Multi-Agent Workflow
Output Directory
Context Engineering outputs are saved to.praison/prp/:
Context Engineering vs Context Window Management
| ContextAgent (Context Engineering) | context=ContextConfig (Context Window) |
|---|---|
| Codebase analysis | Token budgeting |
| PRP generation | Auto-compaction |
| Pattern extraction | Session tracking |
| Implementation blueprints | Multi-memory aggregation |
| Validation frameworks | Overflow detection |
Best Practices
Analyse once, reuse the analysis
Analyse once, reuse the analysis
analyze_codebase is the expensive step. Cache its result and pass it into generate_prp and create_implementation_blueprint rather than re-scanning for each call.Scope file patterns to what matters
Scope file patterns to what matters
Pass
file_patterns=["*.py"] (or your language) so the agent focuses on relevant source instead of walking test fixtures and generated files.Feed the PRP to an implementation agent
Feed the PRP to an implementation agent
The generated PRP is designed to prime another agent. Hand it to a
Developer agent’s instructions for higher first-try success.Don't confuse it with ContextConfig
Don't confuse it with ContextConfig
This agent engineers implementation context. For token budgeting and compaction inside a run, use
context=ContextConfig() instead — they solve different problems.Related
Implement the PRP with the sandboxed CodeAgent.
Token budgeting and context-window compaction.

