Skip to main content

AI Agent Workers

Status: Documentation Last Updated: 2025-12-27

Overview

AI Agent Workers are the execution layer of Agency services. They perform automated tasks on behalf of clients using the same AI infrastructure that powers the Trending Engine platform.
┌─────────────────────────────────────────────────────────────────────────┐
│                     AI AGENT WORKERS ARCHITECTURE                        │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│   Client Request                                                         │
│        │                                                                 │
│        ▼                                                                 │
│   ┌─────────────────┐                                                   │
│   │  Task Router    │                                                   │
│   │  (Orchestrator) │                                                   │
│   └────────┬────────┘                                                   │
│            │                                                             │
│   ┌────────┼────────┬────────────┬───────────┐                         │
│   ▼        ▼        ▼            ▼           ▼                         │
│ Content  Research  Automation  Analysis   Custom                        │
│  Agent    Agent     Agent       Agent     Agent                         │
│                                                                          │
│   └────────┴────────┴────────────┴───────────┘                         │
│                     │                                                    │
│                     ▼                                                    │
│            ┌─────────────────┐                                          │
│            │  Deliverables   │                                          │
│            │  & Reports      │                                          │
│            └─────────────────┘                                          │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘

Agent Types

Content Agent

Creates and optimizes content for client channels.
CapabilityDescription
Blog postsSEO-optimized articles
Social mediaPlatform-specific content
Email campaignsNewsletter and drip sequences
Product descriptionsE-commerce copy

Research Agent

Gathers intelligence and competitive insights.
CapabilityDescription
Market researchIndustry trends and sizing
Competitor analysisPositioning and pricing
Keyword researchSEO opportunity discovery
Audience insightsDemographics and behavior

Automation Agent

Builds and maintains automated workflows.
CapabilityDescription
Workflow designn8n/Make/Zapier builds
Integration setupAPI connections
Data pipelinesETL processes
MonitoringAlert configuration

Analysis Agent

Processes data and generates insights.
CapabilityDescription
Performance reportsKPI dashboards
Trend analysisHistorical patterns
ForecastingPredictive models
AttributionROI tracking

Execution Model

Task Delegation

Human (PM)

    ├── Define task scope
    ├── Set quality criteria
    └── Approve outputs


AI Agent Worker

    ├── Execute task
    ├── Self-validate
    └── Submit for review


Human (PM)

    ├── Review output
    ├── Request revisions OR
    └── Approve & deliver

Linear Integration

Agent work is tracked via Linear with delegation labels:
LabelMeaning
delegate:cursorCursor agent executes
delegate:claude-codeClaude Code executes
delegate:gptChatGPT executes (research)
delegate:blockedNeeds human decision

Agent Capabilities

Supported Tools

ToolPurposeAgent Access
MCP ServerDatabase queries, tool executionAll agents
Web SearchResearch and fact-checkingResearch, Content
File SystemRead/write project filesCursor, Claude Code
Linear APIIssue managementAll agents
SupabaseData operationsAutomation, Analysis

Quality Controls

Each agent output goes through validation:
interface AgentOutput {
  taskId: string;
  agentType: AgentType;
  output: unknown;
  validation: {
    passed: boolean;
    checks: ValidationCheck[];
    confidence: number;
  };
  metadata: {
    tokensUsed: number;
    executionTime: number;
    model: string;
  };
}

const validateOutput = async (output: AgentOutput): Promise<boolean> => {
  const checks = [
    checkCompleteness(output),
    checkAccuracy(output),
    checkFormat(output),
    checkBrandVoice(output)
  ];

  return checks.every(check => check.passed);
};

Client Configuration

Agent Permissions

Each client has configured agent access:
-- Client agent configuration
CREATE TABLE agency_client_agents (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  client_id UUID REFERENCES agency_clients(id),
  agent_type TEXT NOT NULL, -- content, research, automation, analysis
  enabled BOOLEAN DEFAULT true,
  config JSONB DEFAULT '{}',
  monthly_quota INTEGER,
  used_this_month INTEGER DEFAULT 0,
  created_at TIMESTAMPTZ DEFAULT NOW()
);

Usage Tracking

-- Agent execution logs
CREATE TABLE agency_agent_executions (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  client_id UUID REFERENCES agency_clients(id),
  agent_type TEXT NOT NULL,
  task_description TEXT,
  linear_issue_id TEXT,
  status TEXT NOT NULL, -- pending, running, completed, failed
  tokens_used INTEGER,
  cost_usd DECIMAL(10,4),
  started_at TIMESTAMPTZ,
  completed_at TIMESTAMPTZ,
  output_summary TEXT,
  created_at TIMESTAMPTZ DEFAULT NOW()
);

Pricing Model

Cost Structure

ComponentCostPassed to Client
LLM tokensVariableAt cost + 20%
Tool usagePer callIncluded in package
Human reviewPer hour$75/hour

Package Allocation

PackageAgent Hours/MonthIncluded Reviews
Starter102
Growth255
Scale5010
EnterpriseUnlimitedUnlimited

Security & Compliance

Data Isolation

  • Each client’s data is isolated by tenant_id
  • Agents only access client-authorized resources
  • Credentials stored encrypted in Supabase Vault

Audit Trail

All agent actions are logged:
-- Audit log for agent actions
SELECT
  ae.created_at,
  ae.agent_type,
  ae.task_description,
  ae.status,
  ae.tokens_used,
  ae.cost_usd
FROM agency_agent_executions ae
WHERE ae.client_id = $1
ORDER BY ae.created_at DESC
LIMIT 100;

Human-in-the-Loop

Critical actions require human approval:
Action TypeAuto-ExecuteRequires Approval
Content draft
Research summary
Publish content
Data deletion
API credential use
External API calls✓ (first time)

Performance Metrics

Agent Efficiency

-- Agent performance by type
SELECT
  agent_type,
  COUNT(*) as total_executions,
  AVG(tokens_used) as avg_tokens,
  AVG(EXTRACT(EPOCH FROM (completed_at - started_at))) as avg_seconds,
  COUNT(*) FILTER (WHERE status = 'completed') * 100.0 / COUNT(*) as success_rate
FROM agency_agent_executions
WHERE created_at > NOW() - INTERVAL '30 days'
GROUP BY agent_type;

Quality Metrics

MetricTargetMeasurement
First-pass acceptance> 80%Outputs approved without revision
Revision rounds< 2Average revisions per deliverable
Client satisfaction> 4.5/5Post-delivery survey

DocumentPurpose
OVERVIEW.mdAgency architecture
automation-packages.mdPackage definitions
deliverables.mdOutput management
reporting.mdClient reporting