.do
Execution

agents

Autonomous agent framework for building AI-powered digital workers

agents

Agentic Functions - One of the 4 function types (see functions) that exhibit autonomous decision-making, multi-step execution, and goal-oriented behavior.

Overview

The agents primitive represents Agentic Functions - the third of 4 fundamental function types:

  1. Code Functions - Pure code execution
  2. Generative Functions - AI-powered generation (via ai)
  3. Agentic Functions - Autonomous agents with agency ← You are here
  4. Human Functions - Human-in-the-loop execution (via user)

What makes an Agent "Agentic":

  • Autonomy - Makes decisions without explicit instructions for each step
  • Goal-Oriented - Works toward objectives, not just executing fixed steps
  • Multi-Step Reasoning - Plans and executes complex sequences
  • Environment Interaction - Perceives context and adapts behavior
  • Tool Use - Leverages APIs, databases, and external services

Agents are digital workers that combine AI models with autonomous execution patterns to automate business processes that require judgment, research, and decision-making.

SDK Object Mapping

Agentic functions primarily use the ai SDK object (1 of 8 core) for decision-making and reasoning:

import { ai, agent, $, on, send } from 'sdk.do'

// Agent uses AI for autonomous decision-making
const salesAgent = await agent.create({
  name: 'sales-assistant',
  role: 'Sales Development Representative',
  capabilities: ['lead-qualification', 'outreach', 'research'],

  async execute({ lead }) {
    // AI-powered research (ai is 1 of 8 core SDK objects)
    const research = await ai.generate({
      model: 'gpt-5',
      prompt: `Research company: ${lead.company}`,
      tools: ['web-search', 'linkedin-api', 'crunchbase-api'],
    })

    // Autonomous scoring
    const score = await ai.generate({
      model: 'claude-sonnet-4.5',
      prompt: 'Score this lead based on research',
      context: { lead, research },
    })

    // Decision-making
    const decision = await ai.decide({
      question: 'Should we pursue this lead?',
      context: { lead, research, score },
      criteria: ['company size', 'industry fit', 'budget indicators'],
    })

    if (decision.pursue) {
      // Autonomous outreach
      const email = await ai.generate({
        model: 'gpt-5',
        prompt: 'Write personalized outreach email',
        context: { lead, research },
      })

      await send($.Email.send, { to: lead.email, content: email })
    }

    return { lead, research, score, decision }
  },
})

// ON - Agent responds to events (on is 1 of 8 core SDK objects)
on($.Lead.created, async ({ lead }) => {
  await $.Agent.qualify.Lead({ leadId: lead.id })
})

Agent Pattern: $.Agent.verb.Object

Agents use a specific semantic pattern for autonomous actions:

// Agent Pattern: $.Agent.verb.Object
await $.Agent.qualify.Lead({ leadId: 'lead-123' })
await $.Agent.generate.Report({ type: 'market-analysis' })
await $.Agent.analyze.Competitor({ competitorId: 'comp-456' })
await $.Agent.research.Market({ industry: 'technology' })
await $.Agent.score.Opportunity({ opportunityId: 'opp-789' })
await $.Agent.draft.Proposal({ rfpId: 'rfp-999' })

// Agents with context
await $.Agent.qualify.Lead.in.Campaign({ leadId, campaignId })
await $.Agent.generate.Report.for.Executive({ reportType, executiveId })

Autonomous vs Generative

Key Distinction:

  • Generative Functions (ai.generate) - Generate single outputs
  • Agentic Functions (agent) - Autonomous multi-step execution with decision-making
// GENERATIVE: Single-step generation
const description = await ai.generate({
  model: 'gpt-5',
  prompt: 'Write product description for laptop',
})

// AGENTIC: Multi-step autonomous execution
const agent = await $.Agent.create({
  name: 'product-marketer',
  task: async ({ product }) => {
    // Step 1: Agent autonomously researches competitors
    const competitors = await agent.research('competitor products')

    // Step 2: Agent analyzes competitive landscape
    const analysis = await agent.analyze({ product, competitors })

    // Step 3: Agent decides positioning strategy
    const strategy = await agent.decide('positioning', { product, analysis })

    // Step 4: Agent generates marketing materials
    const description = await agent.generate('description', { product, strategy })
    const ads = await agent.generate('ad-campaigns', { product, strategy })

    // Step 5: Agent validates and refines
    const validated = await agent.validate({ description, ads })

    return { description, ads, strategy, competitors }
  },
})

Quick Example

import { agent } from 'sdk.do'

const salesAgent = await agent.create({
  name: 'sales-assistant',
  role: 'Sales Development Representative',
  capabilities: ['lead-qualification', 'email-outreach'],
})

await salesAgent.assign.task({
  type: 'qualify-lead',
  data: { leadId: 'lead-123' },
})

Core Capabilities

  • Autonomous Decision-Making - Makes decisions without explicit step-by-step instructions
  • Multi-Step Reasoning - Plans and executes complex sequences of actions
  • Goal-Oriented Behavior - Works toward objectives, adapting to context
  • Tool Use - Leverages APIs, databases, and external services autonomously
  • AI-Powered - Uses LLMs (via ai SDK object) for reasoning and generation
  • Environment Perception - Gathers context and adapts behavior
  • Human Collaboration - Escalates to humans when needed (via user SDK object)
  • Semantic Patterns - Uses $.Agent.verb.Object pattern for actions

Access Methods

SDK

TypeScript/JavaScript library for programmatic agent management

await agent.create({ name: 'sales-assistant', role: 'SDR', capabilities: ['qualify-leads'] })

SDK Documentation

CLI

Command-line tool for agent operations

do agent create sales-assistant --role SDR --capabilities lead-qualification

CLI Documentation

API

REST/RPC endpoints for agent integration

curl -X POST https://api.do/v1/agents -d '{"name":"sales-assistant","role":"SDR"}'

API Documentation

MCP

Model Context Protocol for AI assistant integration

Create an agent named "sales-assistant" with role SDR and capability "lead-qualification"

MCP Documentation

Named Agents

Pre-configured agent personas for specific roles:

  • Priya - Product Manager
  • Tom - Tech Lead & TypeScript Expert

Parent Concept

  • functions - Agents ARE agentic functions (one of 4 function types)

SDK Object Mappings

  • ai - Agent reasoning and generation (SDK object - 1 of 8 core)
  • on - Event-driven agent triggers (SDK object - 1 of 8 core)
  • user - Human-in-the-loop escalation (SDK object - 1 of 8 core)