Agent System
Doggy's Agent system provides four intelligent agents, accessed uniformly via the AgentManager Facade.
Overview
Agent system lives in src/Service/AI/Agent/, orchestrated by AgentManager:
php
// src/Service/AI/AgentManager.php
class AgentManager
{
public function getQueryAgent(): NaturalLanguageQueryAgent
public function getVisionAgent(): VisionAgent
public function getCodingAgent(): CodingAgent
public function getPasswordPolicyAgent(): PasswordPolicyAgent
}Coding Agent
CodingAgent for general code generation:
php
use App\Service\AI\Agent\CodingAgent;
$code = $codingAgent->generateCode('Create a Symfony controller for employee CRUD');Natural Language Query
NaturalLanguageQueryAgent converts natural language into DataGrid filter conditions, deeply integrated with DataGridService:
php
use App\Service\AI\Agent\NaturalLanguageQueryAgent;
$filters = $queryAgent->parseQuery(
text: 'Employees hired last month',
entityClass: Employee::class,
currentFilters: []
);
// Returns: { filters: [...], thought_process: "..." }Supported examples:
- "Show enabled departments"
- "Departments with 'tech' in the name"
- "Employees added in the last week"
How It Works
- Fetches entity field schema from
DataGridService - Builds a system prompt (field names, types, operators)
- Calls the AI model to generate JSON filter conditions
- Auto-fixes relation fields (e.g.,
department→department.name) - Supports AND/OR logic combinations
- Handles DeepSeek/reasoning model
</think>tags
Password Policy Agent
PasswordPolicyAgent converts natural language security policies into DSL expressions:
php
$policy = $passwordPolicyAgent->parsePolicyInstruction(
'Password must be at least 8 characters with numbers and uppercase letters'
);
// Returns: { and: [{field: "length", operator: ">=", value: 8}, {field: "has_number", ...}, {field: "has_uppercase", ...}] }Vision Agent
VisionAgent for image analysis (reserved interface, multimodal support pending):
php
$result = $visionAgent->analyzeImage($imageUrl, 'Recognize this invoice');Extending
To add a custom Agent:
- Create an Agent class, inject
AiManager - Register it in
AgentManager