Skip to main content
Tasks define specific work for agents to complete with clear objectives.

Quick Start

1

Simple Task

import { Agent, Task } from 'praisonai';

const agent = new Agent({
  instructions: 'You research and summarize topics'
});

const task = new Task({
  description: 'Research AI trends in 2024',
  agent: agent
});

const result = await task.execute();
console.log(result.output);
2

With Expected Output

const task = new Task({
  description: 'Analyze sales data',
  expectedOutput: 'A summary with top 3 insights',
  agent: analyst
});

User Interaction Flow


Configuration Levels

// Level 1: String - Simple description
const task = new Task({
  description: 'Write a blog post about AI',
  agent: writer
});

// Level 2: Dict - With options
const task = new Task({
  description: 'Write a blog post',
  expectedOutput: '500 words, engaging tone',
  agent: writer
});

// Level 3: Instance - Full control
const task = new Task({
  description: 'Write a blog post',
  expectedOutput: '500 words',
  agent: writer,
  context: [researchTask],  // Use output from other tasks
  callback: (result) => console.log('Done!')
});

Task Options

OptionDescription
descriptionWhat the task should accomplish
expectedOutputFormat/structure of result
agentAgent assigned to the task
contextOther tasks to use as input
asyncRun without blocking

API Reference

TaskConfig

Task configuration options

Task

Task class documentation

Best Practices

“Write 500-word blog post about AI benefits” beats “Write about AI”.
Telling the agent what format you want improves results.
Chain tasks by passing earlier outputs as context.