|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +AI agent guidance for the Symfony AI Bundle. |
| 4 | + |
| 5 | +## Component Overview |
| 6 | + |
| 7 | +Symfony integration bundle providing DI configuration for AI components (Platform, Agent, Store). Enables declarative YAML configuration and PHP attributes. |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +### Core Integration |
| 12 | +- **Platform Integration**: AI platforms as Symfony services |
| 13 | +- **Agent Configuration**: Declarative agent setup with tools/processors |
| 14 | +- **Store Configuration**: Vector stores for document retrieval |
| 15 | +- **Security Integration**: `#[IsGrantedTool]` attribute for authorization |
| 16 | +- **Profiler Integration**: Debug toolbar for AI interactions |
| 17 | + |
| 18 | +### Key Components |
| 19 | +- `AiBundle.php`: Main bundle with service configuration |
| 20 | +- `ProcessorCompilerPass.php`: Processor registration |
| 21 | +- Security system with `IsGrantedToolAttributeListener` |
| 22 | +- Profiler data collector and traceable decorators |
| 23 | + |
| 24 | +## Essential Commands |
| 25 | + |
| 26 | +### Testing |
| 27 | +```bash |
| 28 | +vendor/bin/phpunit |
| 29 | +vendor/bin/phpunit tests/DependencyInjection/AiBundleTest.php |
| 30 | +vendor/bin/phpunit --coverage-html coverage/ |
| 31 | +``` |
| 32 | + |
| 33 | +### Code Quality |
| 34 | +```bash |
| 35 | +vendor/bin/phpstan analyse |
| 36 | +# Code style fixes from monorepo root |
| 37 | +``` |
| 38 | + |
| 39 | +## Configuration Architecture |
| 40 | + |
| 41 | +### Platform Configuration |
| 42 | +- Multiple AI providers via factory classes |
| 43 | +- Anthropic, OpenAI, Azure OpenAI, Gemini, VertexAI |
| 44 | +- HTTP client integration |
| 45 | +- Automatic service aliasing |
| 46 | + |
| 47 | +### Agent Configuration |
| 48 | +- Model configuration (class, name, options) |
| 49 | +- Tool integration via `#[AsTool]` or explicit references |
| 50 | +- Input/Output processor chains |
| 51 | +- System prompt with optional tool inclusion |
| 52 | +- Token usage tracking |
| 53 | + |
| 54 | +### Store Configuration |
| 55 | +- Local stores: memory, cache |
| 56 | +- Cloud stores: Azure Search, Pinecone, Qdrant |
| 57 | +- Database stores: MongoDB, ClickHouse, Neo4j |
| 58 | + |
| 59 | +### Security Integration |
| 60 | +- `#[IsGrantedTool]` method-level authorization |
| 61 | +- Symfony Security component integration |
| 62 | +- Runtime permission checking |
| 63 | + |
| 64 | +## Service Registration |
| 65 | + |
| 66 | +### Attribute-Based |
| 67 | +- `#[AsTool]`: Tool registration with name/description |
| 68 | +- `#[AsInputProcessor]`: Agent-specific input processing |
| 69 | +- `#[AsOutputProcessor]`: Agent-specific output processing |
| 70 | + |
| 71 | +### Interface-Based Autoconfiguration |
| 72 | +- `InputProcessorInterface` → `ai.agent.input_processor` |
| 73 | +- `OutputProcessorInterface` → `ai.agent.output_processor` |
| 74 | +- `ModelClientInterface` → `ai.platform.model_client` |
| 75 | + |
| 76 | +## Debug Features |
| 77 | + |
| 78 | +### Profiler Integration |
| 79 | +- Traceable decorators for platforms/toolboxes |
| 80 | +- Symfony Profiler data collector |
| 81 | +- AI interaction and token usage monitoring |
| 82 | + |
| 83 | +### Error Handling |
| 84 | +- Fault-tolerant toolbox wrapper |
| 85 | +- Bundle-specific exception hierarchy |
| 86 | +- Clear missing dependency error messages |
| 87 | + |
| 88 | +## Testing Patterns |
| 89 | + |
| 90 | +- Bundle configuration testing |
| 91 | +- Compiler pass testing |
| 92 | +- Security integration with mock checker |
| 93 | +- Profiler data collection testing |
| 94 | +- PHPUnit 11 with strict configuration |
0 commit comments