mirror of
https://github.com/symfony/ai-agent.git
synced 2026-03-23 23:12:11 +01:00
2.3 KiB
2.3 KiB
AGENTS.md
AI agent guidance for the Agent component.
Component Overview
Framework for building AI agents with user interaction and task execution. Built on Platform component with optional Store integration for memory.
Architecture
Core Classes
- Agent (
src/Agent.php): Main orchestration class - AgentInterface: Contract for implementations
- Input/Output (
src/Input.php,src/Output.php): Pipeline data containers
Processing Pipeline
- InputProcessorInterface: Input transformation contract
- OutputProcessorInterface: Output transformation contract
- Middleware-like processing chain
Key Features
- Memory (
src/Memory/): Conversation memory with embeddings - Toolbox (
src/Toolbox/): Function calling capabilities - Structured Output: Typed response support
- Message Stores (
src/Chat/MessageStore/): Chat persistence
Essential Commands
Testing
vendor/bin/phpunit
vendor/bin/phpunit tests/AgentTest.php
vendor/bin/phpunit --coverage-html coverage/
Code Quality
vendor/bin/phpstan analyse
cd ../../.. && vendor/bin/php-cs-fixer fix src/agent/
Processing Architecture
Pipeline Flow
- Input processors modify requests
- Platform processes request
- Output processors modify responses
Built-in Processors
- SystemPromptInputProcessor: Adds system prompts
- ModelOverrideInputProcessor: Runtime model switching
- MemoryInputProcessor: Conversation context from memory
Memory Providers
- StaticMemoryProvider: In-memory storage
- EmbeddingProvider: Vector-based semantic memory (requires Store)
Tool Integration
- Auto-discovery via attributes
- Fault-tolerant execution
- Event system for lifecycle management
Dependencies
- Platform component: Required for AI communication
- Store component: Optional for embedding memory
- Symfony: HttpClient, Serializer, PropertyAccess, Clock
Testing Patterns
- Use
MockHttpClientover response mocking - Test processors independently
- Use
/fixturesfor multimodal content - Prefer
self::assert*in tests
Development Notes
- Component is experimental (BC breaks possible)
- Add
@authortags to new classes - Use component-specific exceptions from
src/Exception/ - Follow
@SymfonyPHP CS Fixer rules