Tasks

Tasks are the primary way to define work for Aesoperator to perform. A Task represents a high-level goal or objective that will be broken down into a series of actions and function calls.

Task Structure

A Task consists of:

from aesoperator import Task, TaskConfig

task = Task(
    name="research_topic",
    description="Research and summarize information about a given topic",
    config=TaskConfig(
        max_pages=10,
        max_duration_seconds=300,
        allowed_domains=["wikipedia.org", "arxiv.org"]
    ),
    inputs={
        "topic": "artificial intelligence",
        "depth": "technical"
    },
    memory_scope="session"
)

Key components:

  • name: Unique identifier for the task

  • description: Human-readable description of what the task does

  • config: Runtime constraints and settings

  • inputs: Input parameters that control task behavior

  • memory_scope: How long to persist memory ("session", "permanent", etc.)

Task Configuration

The TaskConfig object lets you control how the task executes:

Executing Tasks

Tasks can be executed synchronously or asynchronously:

Task Lifecycle

A task goes through several states during execution:

  1. pending: Task is queued for execution

  2. running: Task is actively executing

  3. completed: Task finished successfully

  4. failed: Task encountered an error

  5. cancelled: Task was manually cancelled

You can monitor task progress and get detailed status:

Task Memory

Tasks can read and write to memory that persists across function calls:

Task Composition

Tasks can be composed into larger workflows:

Example Tasks

Web Research Task

Data Processing Task

Monitoring Task

Best Practices

  1. Set appropriate resource limits in TaskConfig to prevent runaway tasks

  2. Use memory scoping to control data persistence

  3. Break complex workflows into smaller composed tasks

  4. Include good descriptions and documentation

  5. Handle errors and implement retries for reliability

  6. Monitor task progress and set up alerting

  7. Clean up resources when tasks complete

Learn More

Last updated