> ## Documentation Index
> Fetch the complete documentation index at: https://docs.compozy.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Tasks

> Tasks are the building blocks of Compozy, representing both individual units of work and flow control that can be executed, monitored, and orchestrated.

export const BrowseRegistry = ({title, description, icon, href}) => <div className="not-prose mb-8">
    <a href={href} className="group relative block overflow-hidden rounded-xl border border-gray-950/10 dark:border-white/10 bg-gradient-to-br from-white to-gray-50 p-1 transition-all hover:border-primary hover:shadow-lg dark:from-background-dark dark:to-background-dark/80">
      <div className="absolute inset-0 bg-gradient-to-r from-primary/0 via-primary/0 to-primary/0 opacity-0 transition-opacity group-hover:opacity-10" />
      <div className="relative flex items-start gap-6 p-5">
        <div className="flex px-8 h-14 w-14 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary shadow-sm dark:bg-primary/20 dark:shadow-none">
          <Icon icon={icon} iconType="solid" size={24} />
        </div>

        <div className="flex-1">
          <div className="flex items-center justify-between">
            <h3 className="m-0 text-xl font-semibold text-gray-900 group-hover:text-primary dark:text-white">
              {title}
            </h3>
            <Icon icon="arrow-right" iconType="solid" size={20} className="text-gray-400 transition-transform group-hover:translate-x-1 group-hover:text-primary" />
          </div>
          <p className="m-0 mt-2 text-gray-500 dark:text-gray-400">
            {description}
          </p>
          <div className="mt-4 flex items-center gap-2 text-sm font-medium text-primary">
            Browse Registry
            <Icon icon="chevron-right" iconType="solid" size={12} className="transition-transform group-hover:translate-x-0.5" />
          </div>
        </div>
      </div>
    </a>
  </div>;

<BrowseRegistry title="Browse Registry Tasks" description="Discover pre-built tasks for automation, data processing, and workflow orchestration in the Compozy registry" icon="list-check" href="/registry/tasks" />

## What are Tasks?

Tasks in Compozy are powerful, configurable units that combine both execution and flow control capabilities. Each task can represent a specific operation (like calling an API or processing data) or control the flow of your automation (like parallel processing or decision making).

<CodeGroup>
  ```yaml Basic Task theme={"dark"}
  tasks:
    - id: fetch_data
      type: basic
      use: tool(http-request)
      with:
        url: "{{ env.API_URL }}"
        method: GET
  ```

  ```yaml Parallel Task theme={"dark"}
  tasks:
    - id: process_batch
      type: parallel
      config:
        max_concurrent: 3
      execute:
        - use: tool(image-processor)
          with:
            operation: resize
        - use: tool(metadata-extractor)
        - use: tool(text-analyzer)
  ```

  ```yaml Decision Task theme={"dark"}
  tasks:
    - id: route_document
      type: decision
      condition: "{{ tasks.analyze.output.type }}"
      routes:
        invoice: process_invoice
        contract: process_contract
        default: unknown_document
      with:
        document: "{{ input.file }}"
  ```

  ```yaml Collection Task theme={"dark"}
  tasks:
    - id: process_documents
      type: collection
      input: "{{ trigger.documents }}"
      config:
        mode: parallel
        batch_size: 10
        max_concurrent: 3
      execute:
        - use: tool(document-processor)
          with:
            document: "{{ item }}"
            format: "{{ input.format || 'pdf' }}"
  ```
</CodeGroup>

## Task Types

<CardGroup cols={1}>
  <Card title="Basic" icon="square" href="/core/tasks/types#basic" horizontal>
    Simple, single-operation tasks for API calls, transformations, and processing steps.
  </Card>

  <Card title="Parallel" icon="layer-group" href="/core/tasks/types#parallel" horizontal>
    Execute multiple operations simultaneously with configurable concurrency limits.
  </Card>

  <Card title="Decision" icon="code-branch" href="/core/tasks/types#decision" horizontal>
    Route execution based on conditions with support for complex business logic.
  </Card>

  <Card title="Collection" icon="list-check" href="/core/tasks/types#collection" horizontal>
    Process arrays of items sequentially or in parallel with advanced execution patterns.
  </Card>

  <Card title="Wait" icon="hourglass-half" href="/core/tasks/types#wait" horizontal>
    Pause execution until specific conditions are met or timeout occurs.
  </Card>

  <Card title="Map" icon="arrows-turn-to-dots" href="/core/tasks/types#map" horizontal>
    Transform data between tasks with type-safe field mapping.
  </Card>

  <Card title="Composite" icon="object-group" href="/core/tasks/types#composite" horizontal>
    Group multiple operations into reusable units.
  </Card>
</CardGroup>

## Key Features

<Steps>
  <Step title="Flexible Integration" icon="plug">
    Connect with tools, MCP servers, and custom implementations seamlessly
  </Step>

  <Step title="Flow Control" icon="diagram-project">
    Built-in support for parallel execution, loops, and conditional branching
  </Step>

  <Step title="Schema Validation" icon="check-double">
    Define input schemas for reliable data validation
  </Step>

  <Step title="Environment Control" icon="gear">
    Task-specific environment variables and configuration
  </Step>

  <Step title="Error Handling" icon="shield">
    Built-in error management and recovery mechanisms
  </Step>

  <Step title="Component Outputs" icon="link">
    Access outputs from executed tools, agents, and MCPs
  </Step>
</Steps>

## Next Steps

* Learn about different [Task Types](/core/tasks/types) and their use cases
* Understand how to [Use Tasks](/core/tasks/usage) in your workflows
* Review the [Task API Reference](/core/tasks/api) for configuration options
* Learn about publishing tasks to the [Registry](/registry/overview)
