Skip to main content

Execution Model

Learn how Deeployd executes tasks, schedules, triggers, and workflows.

Execution Types

Deeployd supports several execution patterns:

TypeTriggerUse Case
ChatUser messageInteractive conversations
TaskManual or API callOne-off jobs
ScheduleCron expressionRecurring jobs
TriggerWebhook eventEvent-driven automation
WorkflowAny of the aboveMulti-step processes

Tasks

Tasks are single executions of an agent with specific input.

Creating a Task

const task = await deeployd.tasks.create({
agentId: 'agent-123',
name: 'Generate Weekly Report',
input: {
message: 'Generate a summary of this week\'s support tickets',
context: { startDate: '2024-01-08', endDate: '2024-01-14' }
}
});

Task Lifecycle

┌─────────┐    ┌─────────┐    ┌─────────┐    ┌───────────┐
│ Pending │───▶│ Running │───▶│ Success │ or │ Failed │
└─────────┘ └─────────┘ └─────────┘ └───────────┘
│ │
│ ┌─────────┐ │
└────────▶│ Timeout │◀────────┘
└─────────┘

Task States

StateDescription
pendingCreated, waiting to execute
runningCurrently executing
successCompleted successfully
failedExecution failed
timeoutExceeded time limit
cancelledManually cancelled

Running Tasks

// Run a task immediately
const result = await deeployd.tasks.run(task.id);

// Run and wait for completion
const result = await deeployd.tasks.runSync(task.id, {
timeout: 60000 // 60 seconds
});

// Check task status
const status = await deeployd.tasks.get(task.id);
console.log(status.state); // 'success'
console.log(status.output); // Agent's response

Schedules

Schedules run agents automatically on a recurring basis.

Creating a Schedule

const schedule = await deeployd.schedules.create({
name: 'Daily Health Check',
agentId: 'monitoring-agent',
cron: '0 9 * * *', // 9 AM daily
timezone: 'America/New_York',
input: {
message: 'Run daily health checks on all systems'
}
});

Cron Syntax

┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of month (1 - 31)
│ │ │ ┌───────────── month (1 - 12)
│ │ │ │ ┌───────────── day of week (0 - 6) (Sunday = 0)
│ │ │ │ │
* * * * *

Common patterns:

PatternCronDescription
Every hour0 * * * *Top of every hour
Daily at 9am0 9 * * *9:00 AM every day
Weekdays at 8am0 8 * * 1-58:00 AM Mon-Fri
Weekly on Monday0 9 * * 19:00 AM Monday
Monthly on 1st0 9 1 * *9:00 AM 1st of month

Managing Schedules

// Pause a schedule
await deeployd.schedules.pause(schedule.id);

// Resume a schedule
await deeployd.schedules.resume(schedule.id);

// Run schedule immediately (ad-hoc)
await deeployd.schedules.runNow(schedule.id);

// View execution history
const history = await deeployd.schedules.getExecutions(schedule.id);

Triggers

Triggers execute agents in response to external events.

Webhook Triggers

Receive HTTP requests from external systems:

const trigger = await deeployd.triggers.create({
name: 'New Support Ticket',
type: 'webhook',
agentId: 'triage-agent',
config: {
path: '/webhooks/tickets',
method: 'POST',
secret: 'whsec_...' // For signature verification
}
});

// Returns a URL like:
// https://api.deeployd.com/webhooks/t/trigger-123/tickets

Processing Webhook Data

The agent receives the webhook payload in context:

// Agent receives:
{
message: 'New webhook received',
context: {
trigger: 'webhook',
payload: {
ticketId: 'TICKET-001',
subject: 'Login not working',
priority: 'high',
customer: 'acme@example.com'
},
headers: {
'content-type': 'application/json',
'x-webhook-signature': '...'
}
}
}

Event Triggers

Listen to platform events:

const trigger = await deeployd.triggers.create({
name: 'On Conversation Complete',
type: 'event',
agentId: 'analytics-agent',
config: {
events: ['conversation.completed', 'conversation.escalated']
}
});

Available events:

EventDescription
conversation.startedNew conversation begins
conversation.completedConversation ends
conversation.escalatedAgent escalates to another
task.completedTask finishes
task.failedTask fails
schedule.executedSchedule runs
agent.errorAgent encounters error

Workflows

Workflows orchestrate multiple agents and steps.

Workflow Structure

┌─────────────────────────────────────────────────────┐
│ WORKFLOW │
├─────────────────────────────────────────────────────┤
│ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Step 1 │───▶│ Step 2 │───▶│ Step 3 │ │
│ │ Triage │ │Classify │ │ Route │ │
│ └─────────┘ └─────────┘ └────┬────┘ │
│ │ │
│ ┌──────────────┼────────────┤
│ │ │ │
│ ▼ ▼ │
│ ┌─────────┐ ┌─────────┐ │
│ │ Step 4a │ │ Step 4b │ │
│ │Tech Sup │ │Billing │ │
│ └─────────┘ └─────────┘ │
│ │
└─────────────────────────────────────────────────────┘

Creating a Workflow

const workflow = await deeployd.workflows.create({
name: 'Support Ticket Processing',
trigger: {
type: 'webhook',
path: '/tickets'
},
steps: [
{
id: 'triage',
type: 'agent',
agentId: 'triage-agent',
input: {
message: 'Analyze this support ticket: {{trigger.payload}}'
}
},
{
id: 'classify',
type: 'agent',
agentId: 'classifier-agent',
dependsOn: ['triage'],
input: {
message: 'Classify: {{steps.triage.output}}'
}
},
{
id: 'route',
type: 'condition',
dependsOn: ['classify'],
conditions: [
{
if: '{{steps.classify.output.category}} == "technical"',
goto: 'tech-support'
},
{
if: '{{steps.classify.output.category}} == "billing"',
goto: 'billing-support'
}
],
default: 'general-support'
},
{
id: 'tech-support',
type: 'agent',
agentId: 'tech-agent'
},
{
id: 'billing-support',
type: 'agent',
agentId: 'billing-agent'
},
{
id: 'general-support',
type: 'agent',
agentId: 'general-agent'
}
]
});

Step Types

TypeDescription
agentExecute an agent
conditionBranch based on conditions
parallelRun steps concurrently
waitPause for time or event
httpMake HTTP request
transformTransform data
humanWait for human approval

Workflow Variables

Access data from triggers and previous steps:

// Trigger data
'{{trigger.payload.ticketId}}'
'{{trigger.headers.x-custom-header}}'

// Previous step output
'{{steps.triage.output}}'
'{{steps.classify.output.category}}'

// Built-in variables
'{{workflow.id}}'
'{{workflow.startedAt}}'
'{{env.API_KEY}}'

Error Handling

Configure how workflows handle failures:

{
id: 'risky-step',
type: 'agent',
agentId: 'agent-123',
onError: {
strategy: 'retry',
maxRetries: 3,
backoff: 'exponential',
fallback: 'fallback-step' // Go here if all retries fail
}
}

Error strategies:

StrategyDescription
failStop workflow immediately
retryRetry with backoff
skipSkip step, continue workflow
fallbackGo to fallback step

Execution Limits

Default limits for executions:

ResourceLimitNotes
Task timeout5 minutesConfigurable up to 30 min
Workflow timeout30 minutesConfigurable up to 24 hours
Steps per workflow50Contact support for more
Concurrent tasks10Per tenant, varies by plan
Schedules100Per tenant
Webhooks/sec100Per endpoint

Monitoring Executions

View Execution Status

// Get workflow execution
const execution = await deeployd.workflows.getExecution(executionId);

console.log(execution.state); // 'running'
console.log(execution.currentStep); // 'classify'
console.log(execution.steps); // Status of each step

Execution Dashboard

Monitor all executions in the Dashboard:

Dashboard → Executions
├── Active (currently running)
├── Recent (last 24 hours)
├── Failed (errors)
└── Scheduled (upcoming)

Webhooks for Execution Events

Get notified when executions complete:

await deeployd.webhooks.create({
url: 'https://your-app.com/webhooks',
events: [
'workflow.completed',
'workflow.failed',
'task.completed',
'task.failed'
]
});

Next: Learn about Memory & Context to understand how agents remember information.