mdxui

Actors

Understanding the four actor types - ServiceAccount, Model, Agent, and Human

Actors

An Actor is anything that can execute a function. There are four types of actors in the system, each with different execution characteristics and capabilities.


The Actor Hierarchy

Actor
├── ServiceAccount  → executes Code functions
├── Model           → executes Generative functions
└── Worker
    ├── Agent       → executes Agentic functions
    └── Human       → executes Human functions

Workers are a special subset of actors - Agents and Humans - that "perform Tasks" rather than execute functions directly. Workers figure things out, while ServiceAccounts and Models execute deterministically.


ServiceAccount

A ServiceAccount is a non-human actor that executes deterministic code functions.

Characteristics

  • Execution style: Deterministic, synchronous
  • Function type: Code functions
  • Autonomy: None - runs predefined logic
  • Authentication: API keys, service tokens
  • Examples: API service accounts, background jobs, webhooks

Use Cases

Use CaseExample
Data transformationParse CSV, convert JSON to XML
ValidationCheck email format, validate input
IntegrationSync with external APIs
AutomationSend notifications, process webhooks
ComputationCalculate totals, aggregate metrics

Example

interface ServiceAccount {
  id: string
  name: string
  type: 'ServiceAccount'
  apiKey: string
  permissions: string[]
}

const serviceAccount: ServiceAccount = {
  id: 'sa_123',
  name: 'Payment Processor',
  type: 'ServiceAccount',
  apiKey: 'sk_live_...',
  permissions: ['payments.read', 'payments.write']
}

// ServiceAccount executes Code function
async function processPayment(invoice: Invoice): Promise<Payment> {
  const result = await stripe.charges.create({
    amount: invoice.amount,
    currency: 'usd',
    customer: invoice.customerId,
  })
  return result
}

When to Use ServiceAccounts

Use ServiceAccounts when:

  • Logic is deterministic and predictable
  • No judgment or creativity required
  • Performance and speed are critical
  • You need reliable, repeatable execution
  • The function is pure transformation or I/O

Model

A Model is an LLM that executes generative functions through direct generation.

Characteristics

  • Execution style: LLM generation, synchronous
  • Function type: Generative functions
  • Autonomy: Limited - single-turn generation
  • Authentication: API keys for LLM providers
  • Examples: GPT-4, Claude, Gemini

Use Cases

Use CaseExample
Content generationWrite copy, generate descriptions
SummarizationCondense documents, extract key points
ClassificationCategorize content, sentiment analysis
ExtractionPull structured data from text
TranslationConvert between languages
TransformationRewrite tone, format conversion

Example

interface Model {
  id: string
  name: string
  type: 'Model'
  provider: 'openai' | 'anthropic' | 'google'
  model: string
  apiKey: string
}

const model: Model = {
  id: 'model_123',
  name: 'Claude Sonnet 4.5',
  type: 'Model',
  provider: 'anthropic',
  model: 'claude-sonnet-4-5',
  apiKey: 'sk_ant_...'
}

// Model executes Generative function
async function generateProductDescription(product: Product): Promise<string> {
  const prompt = `Generate a compelling product description for: ${product.name}`
  const response = await anthropic.messages.create({
    model: model.model,
    messages: [{ role: 'user', content: prompt }]
  })
  return response.content[0].text
}

When to Use Models

Use Models when:

  • You need creative or natural language output
  • The task involves understanding and generation
  • Rules-based logic is too rigid
  • You need human-like reasoning in a single turn
  • The function is classification, extraction, or transformation

Agent

An Agent is an AI that executes agentic functions by autonomously performing tasks.

Characteristics

  • Execution style: Autonomous, multi-step, asynchronous
  • Function type: Agentic functions
  • Autonomy: High - plans and executes multi-step workflows
  • Tools: Can use external tools and APIs
  • Examples: Research agents, coding agents, data analysis agents

Use Cases

Use CaseExample
ResearchGather information from multiple sources
AnalysisAnalyze data and provide insights
Multi-step workflowsComplete complex tasks with multiple steps
Problem solvingDebug code, troubleshoot issues
PlanningCreate implementation plans

Example

interface Agent {
  id: string
  name: string
  type: 'Agent'
  model: Model
  tools: Tool[]
  systemPrompt: string
}

const agent: Agent = {
  id: 'agent_123',
  name: 'Research Agent',
  type: 'Agent',
  model: model,
  tools: [webSearchTool, webScrapeTool, analyzeTool],
  systemPrompt: 'You are a research agent that gathers and analyzes information.'
}

// Agent implements Worker interface
class ResearchAgent implements Worker {
  async ask(prompt: string): Promise<Response> {
    // Single turn interaction
  }

  async do(task: Task): Promise<Result> {
    // Multi-step task execution
    // Agent autonomously plans and executes
    const plan = await this.createPlan(task)
    const results = await this.executePlan(plan)
    return this.synthesizeResults(results)
  }
}

Agent vs Model

AspectModelAgent
InteractionSingle turnMulti-turn
PlanningNoneCreates and follows plans
Tool useNoYes
AutonomyLowHigh
Function typeGenerativeAgentic
Best forDirect generationComplex tasks

When to Use Agents

Use Agents when:

  • The task requires multiple steps
  • Planning and decision-making are needed
  • You need to use external tools or APIs
  • The workflow is exploratory or research-oriented
  • Human-like reasoning over multiple turns is required

Human

A Human is a person that executes human functions by performing tasks.

Characteristics

  • Execution style: Manual, asynchronous, judgment-based
  • Function type: Human functions
  • Autonomy: Full - makes subjective decisions
  • Interface: UI, Slack, email, etc.
  • Examples: Approvers, reviewers, decision-makers

Use Cases

Use CaseExample
ApprovalApprove invoices, sign contracts
ReviewCode review, content review
Decision-makingStrategic decisions, edge cases
Creative workDesign, writing, strategy
Quality controlFinal checks, validation

Example

interface Human {
  id: string
  name: string
  type: 'Human'
  email: string
  roles: string[]
  notificationChannels: ('email' | 'slack' | 'sms')[]
}

const human: Human = {
  id: 'human_123',
  name: 'Alice Johnson',
  type: 'Human',
  email: 'alice@example.com',
  roles: ['approver', 'reviewer'],
  notificationChannels: ['email', 'slack']
}

// Human implements Worker interface
class HumanWorker implements Worker {
  async ask(prompt: string): Promise<Response> {
    // Send prompt to human via Slack/email
    // Wait for response
  }

  async do(task: Task): Promise<Result> {
    // Create HumanTask
    const humanTask = await createHumanTask({
      assignee: this.id,
      description: task.description,
      data: task.data
    })

    // Notify human via Slack/email
    await notify(this, humanTask)

    // Wait for human to complete task
    return await waitForCompletion(humanTask)
  }
}

Human Tasks

Human functions create HumanTasks that render in human-friendly interfaces:

interface HumanTask {
  id: string
  type: 'approval' | 'review' | 'decision' | 'creative'
  assignee: Human
  status: 'pending' | 'in_progress' | 'completed' | 'rejected'
  data: any
  ui: 'slack' | 'email' | 'web'
}

The same MDXLD document renders differently based on the actor:

---
$type: Invoice
amount: 5000
customer: Acme Corp
---

# Invoice Approval

Please review and approve this invoice.

<InvoiceDetails />
<ApprovalButtons />

Renderers:

  • renderSlack() - Slack Block Kit with approve/reject buttons
  • renderEmail() - HTML email with clickable buttons
  • renderHTML() - Web UI with rich interface

When to Use Humans

Use Humans when:

  • The task requires judgment or subjective decision-making
  • Compliance or governance requires human oversight
  • The task is creative or strategic
  • AI cannot reliably handle edge cases
  • Legal or ethical considerations require human involvement

The Worker Interface

Workers are Agents and Humans that perform tasks rather than execute functions directly.

Worker Contract

interface Worker {
  ask(prompt: string): Promise<Response>
  do(task: Task): Promise<Result>
}

Both Agents and Humans implement this interface, making them interchangeable for task execution.

Worker vs Non-Worker Actors

AspectServiceAccount/ModelWorker (Agent/Human)
InterfaceFunction callTask assignment
ExecutionDirectAutonomous
PlanningNoneYes
AsyncSynchronousAsynchronous
ToolsNoYes
JudgmentNoYes

Example: Interchangeable Workers

async function performResearch(task: Task, worker: Worker): Promise<Result> {
  // Works with both Agent and Human
  return await worker.do(task)
}

// Can use Agent
const agentResult = await performResearch(task, researchAgent)

// Or Human
const humanResult = await performResearch(task, researcher)

This enables hybrid workflows where you can:

  • Start with an Agent for routine tasks
  • Escalate to Human for edge cases
  • Use Human for high-stakes decisions
  • Use Agent for scale and speed

How Actors Execute Functions

Each actor type executes a specific function type:

ActorExecutesStyleExample
ServiceAccountCode functionDeterministicprocessPayment(invoice)
ModelGenerative functionLLM generationgenerateDescription(product)
AgentAgentic functionAutonomous taskresearchCompetitor(company)
HumanHuman functionManual taskapproveInvoice(invoice)

Execution Flow

// 1. ServiceAccount executes Code function
const validatedInvoice = await validateInvoice(invoice) // Code function

// 2. Model executes Generative function
const summary = await summarizeInvoice(validatedInvoice) // Generative function

// 3. Agent performs Agentic task
const analysis = await analyzeInvoice(validatedInvoice) // Agentic function

// 4. Human performs Human task
const approved = await approveInvoice(validatedInvoice) // Human function

Actor Selection Guide

Choose the right actor for your function:

Decision Tree

Is the logic deterministic and rule-based?
├─ Yes → ServiceAccount (Code function)
└─ No → Does it require creativity/generation?
    ├─ Yes → Is it a single-turn generation?
    │   ├─ Yes → Model (Generative function)
    │   └─ No → Agent (Agentic function)
    └─ No → Does it require human judgment?
        ├─ Yes → Human (Human function)
        └─ No → Agent (Agentic function)

Quick Reference

RequirementActor
Rules-based logicServiceAccount
Generate text/contentModel
Multi-step researchAgent
Approval/decisionHuman
Data transformationServiceAccount
ClassificationModel
Problem-solvingAgent
Creative workHuman or Agent
Real-time processingServiceAccount
Complex reasoningAgent
Legal complianceHuman

Authentication & Permissions

Each actor type has different authentication mechanisms:

ServiceAccount

interface ServiceAccount {
  apiKey: string
  permissions: string[]
  rateLimit?: number
}

Model

interface Model {
  provider: 'openai' | 'anthropic' | 'google'
  apiKey: string
  model: string
  maxTokens?: number
}

Agent

interface Agent {
  model: Model
  tools: Tool[]
  systemPrompt: string
  maxIterations?: number
}

Human

interface Human {
  email: string
  roles: string[]
  permissions: string[]
  notificationChannels: ('email' | 'slack' | 'sms')[]
}

Next Steps

  • Read Functions to understand what Actors execute
  • See Workflows for coordinating multiple Actors
  • Explore Verbs for action grammar used by Actors

On this page