Agents & Per-Agent Model Routing
LaraOrcest adopts a CrewAI-style role-based multi-agent paradigm. Rather than assigning all engineering responsibilities to a single generic prompt, LaraOrcest partitions the software delivery lifecycle across specialized autonomous agents.
Each agent possesses:
- A clearly defined Role, Goal, and Backstory.
- A strict JSON Schema enforcing structured LLM outputs.
- A least-privilege tool whitelist (
getAllowedTools()). - Ownership of specific fields within
RunState. - Support for Per-Agent Model Routing, allowing you to pair complex reasoning tasks with frontier models while routing routine code authoring to cost-effective models.
1. Built-in Agent Directory
| Agent Key | Class | Allowed Tools | Primary State Output | Default Scope / Paths |
|---|---|---|---|---|
business_analyst | BusinessAnalystAgent | file_reader | requirements_spec | Read-only analysis |
product_manager | ProductManagerAgent | file_reader | backlog | Read-only planning |
architect | ArchitectAgent | file_reader, codebase_inspector | technical_plan | Read-only architecture |
git_agent | GitAgent | git_command | git_state | Branch orcest/... |
package_manager_agent | PackageManagerAgent | composer_runner, directory_scaffolder, file_reader, patch_writer, codebase_inspector, artisan_runner | artifacts, metadata.package_manager | Target project bootstrap, packages & structure |
database_agent | DatabaseAgent | file_reader, patch_writer, artisan_runner | artifacts | database/, app/Models/ |
backend_agent | BackendAgent | file_reader, patch_writer, artisan_runner | artifacts | app/, routes/, config/ |
qa_agent | QaAgent | file_reader, patch_writer, test_runner | test_results | tests/ |
fixer_agent | FixerAgent | file_reader, patch_writer, artisan_runner, test_runner | artifacts, guardrails.fix_attempts | Project-wide bug repair |
reviewer_agent | ReviewerAgent | file_reader, git_command | reviews | Read-only code audit |
web_scraping_agent (Conditional) | WebScrapingAgent | file_reader | scraping_results | HTTP extraction & dispatch |
swagger_agent (Conditional) | SwaggerAgent | file_reader, patch_writer, artisan_runner | artifacts, metadata.swagger | docs/, storage/api-docs/ |
2. Core Agents Detailed Breakdown
1. business_analyst (Domain & Systems Analyst)
- Role: Extracts requirements, identifies domain entities, discovers unstated assumptions, and documents security/authorization rules.
- Workflow: Inspects existing domain models and policies using
FileReaderTool. Generates an unambiguousrequirements_specJSON structure. - Output: Stored in
$state->requirementsSpec.
2. product_manager (Technical Product Manager)
- Role: Converts the
requirements_specinto an ordered, testable backlog of discrete implementation tasks. - Workflow: Defines atomic tasks with explicit acceptance criteria, expected artifact paths, priority weights, and inter-task dependencies (
depends_on). - Output: Stored in
$state->backlog.
3. architect (Senior Software Architect)
- Role: Translates the product backlog into an idiomatic Laravel technical architecture plan conforming to Laravel 10/11/12 conventions.
- Workflow: Designs table migrations, Eloquent relationships, Casts, FormRequests, Controllers, API Resources, and Route definitions.
- Output: Stored in
$state->technicalPlan. - HITL Integration: When
--interactiveis enabled, execution automatically pauses immediately afterarchitectat theafter_plangate.
4. git_agent (Source Control Hygiene Specialist)
- Role: Manages feature branch isolation and clean repository hygiene.
- Workflow:
- Checks
git statusto ensure the repository working tree is clean. - Creates and checks out a dedicated feature branch using prefix convention
orcest/{feature-slug}. - Enforces protected branch safeguards (prevents touching
main,master,production,staging).
- Checks
- Output: Stored in
$state->gitState.
5. database_agent (Database & Eloquent Specialist)
- Role: Authors database migrations, model definitions, casts, and model factories.
- Workflow:
- Invokes
ArtisanRunnerToolto executemake:migrationandmake:model. - Uses
PatchWriterToolto write idiomatic schema blueprints and model relationships (hasMany,belongsTo,casts()).
- Invokes
- Output: Appends generated files to
$state->artifacts.
6. backend_agent (Backend & API Engineer)
- Role: Implements HTTP layers, Form Request validation rules, controller actions, and API routes.
- Workflow:
- Generates Form Requests (
make:request) enforcing strict validation rules and authorization checks. - Generates Controllers (
make:controller) returning JSON resources with appropriate HTTP status codes (200, 201, 404, 422). - Appends route definitions to
routes/api.phporroutes/web.php.
- Generates Form Requests (
- Output: Appends generated files to
$state->artifacts.
7. qa_agent (Automated QA & Test Engineer)
- Role: Writes automated feature and unit tests and executes the test suite.
- Workflow:
- Generates comprehensive tests in
tests/Feature/covering happy path assertions, validation errors, and authorization checks. - Invokes
TestRunnerTool(php artisan test --without-tty). - Parses test output into structured pass/fail metrics.
- Generates comprehensive tests in
- Output: Stored in
$state->testResults.
8. fixer_agent (Root-Cause Bug Fixer)
- Role: Diagnoses failing assertions or reviewer objections and applies targeted code repairs.
- Workflow:
- Triggered conditionally when
qa_agentreports test failures orreviewer_agentrequests revisions. - Analyzes the failure stack trace, reads offending files, and writes surgical patches via
PatchWriterTool. - Re-triggers test execution.
- Enforces
max_fix_attempts(default: 3) to prevent runaway retry loops.
- Triggered conditionally when
- Output: Updates
$state->artifactsand increments$state->guardrails['fix_attempts'].
9. reviewer_agent (Staff Reviewer & Security Auditor)
- Role: Performs an objective staff-level code review of all authored changes.
- Workflow:
- Inspects
git diffand generated artifacts against PSR-12, Laravel security standards, and business criteria. - Evaluates authorization logic, SQL injection vectors, and validation completeness.
- Issues an approval (
approved) or requests revisions (revise) with actionable findings.
- Inspects
- Output: Stored in
$state->reviews.
3. Optional & Conditional Agents
10. web_scraping_agent (Web Scraping & Ingestion Specialist)
The web_scraping_agent extracts structured data from external websites and forwards normalized payloads to destination endpoints.
Requirements & Capabilities
- Two Source URLs: Strictly expects exactly two target website URLs to scrape and compare/reconcile.
- BA & PM Alignment: Data extraction is guided directly by domain requirements (
requirements_spec) and acceptance criteria (backlog). - Payload Unification: Combines extracted data from both websites into a single normalized payload (
unified_payload). - Endpoint Dispatch: Dispatches the payload via HTTP (
POST,PUT,PATCH) to a specified destination endpoint. - Dry-Run Safety: In
--dry-runmode, scrapes and normalizes data intoartifacts(web_scraping/payload.json) but skips external HTTP dispatch.
Activation
web_scraping_agent activates when:
- Two URLs and an endpoint are supplied via CLI or prompt.
- Metadata is passed programmatically via
$options['web_scraping'].
# Example scraping run
php artisan orcest:build "Scrape pricing from https://store-a.example.com/item and https://store-b.example.com/item and dispatch to https://internal-api.example.com/webhooks/catalog" --dry-runSecurity Guardrails
- Scheme Validation: Only
httpandhttpsschemes allowed. - Private IP Protection: Localhost and RFC-1918 private IP addresses (e.g.
127.0.0.1,192.168.x.x,10.x.x.x) are blocked by default (allow_private_ips => false). - Payload Limits: Maximum response size capped at 500KB (
max_response_size), and maximum prompt context capped at 10,000 characters (max_content_chars).
11. swagger_agent (Swagger & OpenAPI Documentation Specialist)
The swagger_agent generates standardized OpenAPI 3.0+ documentation for backend endpoints.
Capabilities
- Analyzes routes, form requests, and controllers generated during the run.
- Generates OpenAPI 3.0+ compliant schemas, parameters, request bodies, and responses.
- Writes documentation in
json,yaml, orbothformats todocs/swagger.json(or configuredoutput_path).
Activation
Activated when:
--swaggerflag is passed toorcest:build.LARA_ORCEST_SWAGGER_AUTO_GENERATE=trueis enabled in.env.- The prompt explicitly mentions
api,endpoint,rest, orswagger. LARA_ORCEST_SWAGGER_CONDITIONAL=trueis enabled and API routes are detected.
# Example run generating OpenAPI specs
php artisan orcest:build "Create a user notification preference API" --swagger --swagger-format=both4. Per-Agent Model Routing
Different agents demand different model capabilities. Running high-volume routine tasks (like writing repetitive boilerplate) on expensive reasoning models wastes token budgets, while running architectural planning on small models can result in flawed system design.
LaraOrcest solves this with Per-Agent Model Routing (llm.agent_models).
Architecture Flow
┌────────────────────────────────┐
│ LaraOrcest Agent Executor │
└───────────────┬────────────────┘
│
Agent Model Override Check
Config: llm.agent_models.{agent}
│
▼
┌────────────────────────────────┐
│ OpenAI-Compatible Driver │
│ (options['model'] overridden) │
└───────────────┬────────────────┘
│ HTTP POST /v1/chat/completions
▼
┌────────────────────────────────┐
│ LiteLLM / AI Gateway │
└───────┬───────────────┬────────┘
│ │
model: "claude-3-5-sonnet" model: "gpt-4o-mini"
▼ ▼
┌───────────────┐ ┌───────────────┐
│ Anthropic API │ │ OpenAI API │
└───────────────┘ └───────────────┘Configuration in .env
You can assign specific models or LiteLLM aliases to individual agents:
# Default model for unspecified agents
LARA_ORCEST_LLM_MODEL=gpt-4o-mini
# Frontier reasoning models for analytical agents
LARA_ORCEST_MODEL_BUSINESS_ANALYST=claude-3-5-sonnet-20241022
LARA_ORCEST_MODEL_PRODUCT_MANAGER=gpt-4o
LARA_ORCEST_MODEL_ARCHITECT=claude-3-5-sonnet-20241022
LARA_ORCEST_MODEL_REVIEWER_AGENT=claude-3-5-sonnet-20241022
# Fast, cost-efficient models for routine code authoring
LARA_ORCEST_MODEL_GIT_AGENT=gpt-4o-mini
LARA_ORCEST_MODEL_DATABASE_AGENT=gpt-4o-mini
LARA_ORCEST_MODEL_BACKEND_AGENT=gpt-4o-mini
LARA_ORCEST_MODEL_SWAGGER_AGENT=gpt-4o-mini
# Specialized coding / debugging models
LARA_ORCEST_MODEL_QA_AGENT=gpt-4o
LARA_ORCEST_MODEL_FIXER_AGENT=claude-3-5-sonnet-20241022
# Specialized extraction model
LARA_ORCEST_MODEL_WEB_SCRAPING_AGENT=gpt-4o-mini
# Sub-Agent overrides
LARA_ORCEST_MODEL_DOMAIN_RULES_AGENT=gpt-4o-mini
LARA_ORCEST_MODEL_BACKLOG_SPLITTER_AGENT=gpt-4o-mini
LARA_ORCEST_MODEL_DDD_BOUNDARY_AGENT=claude-3-5-sonnet-20241022
LARA_ORCEST_MODEL_SCHEMA_PLANNER_AGENT=claude-3-5-sonnet-20241022
LARA_ORCEST_MODEL_API_CONTRACT_AGENT=claude-3-5-sonnet-20241022
LARA_ORCEST_MODEL_MIGRATION_AGENT=gpt-4o-mini
LARA_ORCEST_MODEL_MODEL_ELOQUENT_AGENT=gpt-4o-mini
LARA_ORCEST_MODEL_SEEDER_AGENT=gpt-4o-mini
LARA_ORCEST_MODEL_REQUEST_VALIDATION_AGENT=gpt-4o-mini
LARA_ORCEST_MODEL_SERVICE_ACTION_AGENT=gpt-4o-mini
LARA_ORCEST_MODEL_CONTROLLER_RESOURCE_AGENT=gpt-4o-mini
LARA_ORCEST_MODEL_FEATURE_TEST_AGENT=gpt-4o3. Hierarchical Agent Pods & Sub-Agents
When hierarchical teams are enabled (lara-orcest.teams.enabled = true), Lead Agents delegate specialized sub-tasks to helper sub-agents organized into 6 functional Pods:
1. Discovery & Planning Pod
- Lead Agents:
business_analyst,product_manager - Sub-Agents:
domain_rules_agent(DomainRulesAgent): Extracts domain invariants and state transitions.backlog_splitter_agent(BacklogSplitterAgent): Decomposes requirements into atomic tasks with explicit dependencies.web_scraping_agent(WebScrapingSubAgent): Extracts and normalizes structured data from two URLs.
- Assigned Skills:
business-requirements-analysis,backlog-task-decomposition,two-site-scraping-dispatch.
2. Architecture Pod
- Lead Agent:
architect - Sub-Agents:
ddd_boundary_agent(DddBoundaryAgent): Layered DDD context boundaries and multi-tenant invariants.schema_planner_agent(SchemaPlannerAgent): Relational schema tables, foreign keys, and indexes.api_contract_agent(ApiContractAgent): REST API contracts, routes, and JSON resource schemas.
- Assigned Skills:
laravel-modular-ddd-architecture,relational-schema-indexing,rest-api-contract-design.
3. Package Manager Pod
- Lead Agent:
package_manager_agent(PackageManagerAgent) - Sub-Agents:
laravel_installer_agent(LaravelInstallerAgent, Wave 0): Discloses target Laravel version in terminal and bootstraps fresh Laravel skeletons idempotently insidetargetProjectPath.dependency_resolver_agent(DependencyResolverAgent, Wave 1): Discloses exact package versions in terminal and installs required Composer packages from prompt specification andtechnical_plan.structure_scaffolder_agent(StructureScaffolderAgent, Wave 2): Scaffolds modular DDD or standard Laravel directories and starter files withinPathGuardboundaries.
- Assigned Skills:
laravel-project-bootstrapping,composer-dependency-management,laravel-directory-scaffolding.
4. Database Pod
- Lead Agent:
database_agent - Sub-Agents:
migration_agent(MigrationAgent, Wave 0): Anonymous migrations indatabase/migrations/**.model_eloquent_agent(ModelEloquentAgent, Wave 1): Eloquent models, relationships, and factories.seeder_agent(SeederAgent, Wave 2): Idempotent database seeders indatabase/seeders/**.
- Assigned Skills:
laravel-safe-migrations,eloquent-models-and-factories,idempotent-database-seeders.
5. Backend Pod
- Lead Agent:
backend_agent - Sub-Agents:
request_validation_agent(RequestValidationAgent, Wave 0): FormRequests and Policies.service_action_agent(ServiceActionAgent, Wave 1): Single-responsibility Actions and Services.controller_resource_agent(ControllerResourceAgent, Wave 2): Thin controllers and JsonResources.
- Assigned Skills:
laravel-form-requests-authorization,service-action-workflows,controllers-resources-routes.
6. Quality, Docs & Release Pod
- Lead Agents:
qa_agent,reviewer_agent - Sub-Agents:
feature_test_agent(FeatureTestAgent, Wave 0 under QA): Pest/PHPUnit feature and unit tests intests/**.fixer_agent(FixerSubAgent, conditional retry under QA): Root-cause bug repairs acrossapp/**,database/**,routes/**,tests/**.swagger_agent(SwaggerSubAgentunder Reviewer): OpenAPI 3.0+ documentation indocs/swagger.json.git_agent(GitSubAgentunder Reviewer): Milestone release branching (orcest/...) and clean commits.
- Assigned Skills:
laravel-feature-testing,root-cause-test-fixing,openapi-swagger-spec,safe-git-release.
Model Resolution Hierarchy
When an agent executes an LLM turn, AbstractAgent::resolveModel() evaluates configuration in the following order:
- Agent-Specific Override:
config("lara-orcest.llm.agent_models.{$agentKey}"). - Run-Level Override: CLI
--llmor$options['llm']parameter. - Driver Default:
config("lara-orcest.llm.drivers.openai_compatible.model").
Next Steps
- Learn about the Sandboxed Tools and Human-in-the-Loop gates: Safety & HITL Guide
- Review practical implementation recipes: Use Cases
