Skip to content

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

  1. Fetches entity field schema from DataGridService
  2. Builds a system prompt (field names, types, operators)
  3. Calls the AI model to generate JSON filter conditions
  4. Auto-fixes relation fields (e.g., departmentdepartment.name)
  5. Supports AND/OR logic combinations
  6. 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:

  1. Create an Agent class, inject AiManager
  2. Register it in AgentManager

Open Source under MIT | Copyright © 2026 Doggy