Task System

Understanding the Manus AI Agent task workflow

Overview

The task system allows users to submit AI agent tasks to Manus and track their progress in real-time.

Task Lifecycle

Created → Queued → Processing → Completed
                            ↘ Failed

Status Definitions

StatusDescription
createdTask submitted, awaiting queue
queuedIn queue, waiting for processing
processingAI agent is working on the task
completedTask finished successfully
failedTask encountered an error

Creating Tasks

Via API

// POST /api/manus/tasks/create
const response = await fetch('/api/manus/tasks/create', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    prompt: 'Your task description here',
    type: 'general',
    priority: 'normal',
  }),
});

const { success, task } = await response.json();

Task Types

TypeDescriptionCredits
generalGeneral purpose tasks1
researchResearch and analysis2
codingCode generation3
creativeCreative content2

Task Schema

interface ManusTask {
  id: string;
  user_id: string;
  account_id: string;
  prompt: string;
  type: string;
  status: TaskStatus;
  priority: 'low' | 'normal' | 'high';
  credits_used: number;
  result: object | null;
  error: string | null;
  started_at: Date | null;
  completed_at: Date | null;
  created_at: Date;
}

Viewing Tasks

Task List

Access your tasks at /manus/tasks:

  • Filter by status, type, or date
  • Sort by creation time or priority
  • View task details and results

Task History

View completed tasks at /manus/tasks/history:

  • Full task execution logs
  • Result download options
  • Credit consumption history

Real-time Updates

Tasks support real-time status updates:

// Subscribe to task updates
const eventSource = new EventSource(`/api/manus/tasks/${taskId}/stream`);

eventSource.onmessage = (event) => {
  const update = JSON.parse(event.data);
  console.log('Task update:', update);
};

Error Handling

Common Errors

ErrorCauseSolution
insufficient_creditsNot enough creditsPurchase more credits
account_unavailableNo bound accountClaim or bind an account
rate_limitedToo many requestsWait and retry
invalid_promptEmpty or invalid inputCheck prompt format

Retry Logic

Failed tasks can be retried:

// POST /api/manus/tasks/{id}/retry
const response = await fetch(`/api/manus/tasks/${taskId}/retry`, {
  method: 'POST',
});

Best Practices

  1. Clear Prompts: Write specific, detailed prompts
  2. Monitor Credits: Track credit usage before submitting
  3. Handle Errors: Implement proper error handling
  4. Use Priorities: Set appropriate priority levels
  5. Check Status: Poll or use streaming for updates