# Task Server

The Task Server is a distributed task processing component in Canso's AI Agentic System that empowers AI agents the ability with to execute **long running** or **computationally intensive** tasks asynchronously.

The diagram below illustrates how the task server integrates with your AI Agent. ![Task Server Functionality](/files/JcOiEl2nXmng2sZF7Y7L)

The [tools](/ai-agents/toolkit.md) provided by Canso integrate seamlessly with the Task Server. All you need to do is set up the [Broker](/ai-agents/concepts/broker.md) and the Task Server, which involves executing a simple CLI command, and add the Canso tools to your AI Agent.

## Core Design Philosophy

The Task Server implements a fundamental architectural principle: the separation between agent decision-making and task execution. This separation provides several key advantages:

1. **Clean Separation of Concerns**
   * Agents focus purely on decision-making and workflow orchestration
   * Task execution is handled independently by specialized workers
   * Clear boundaries between thinking (agents) and doing (tasks)
2. **Scalability and Resource Optimization**
   * Agent processes remain lightweight and responsive
   * Compute-intensive tasks are offloaded to appropriate workers
   * Independent scaling of agent instances and task workers
3. **Enhanced Reliability**
   * Task failures don't impact agent stability
   * Retry mechanisms are handled separately from agent logic
   * Better error isolation and recovery

This architecture enables AI agents to orchestrate complex workflows while maintaining responsiveness and reliability, making it ideal for production deployments.

### Setting up the Task Server

To set up the task server, define a YAML file:

```yaml
task_server:
  type: celery
  name: task_server
  replicas: 4
  concurrency_per_replica: 1
  broker_resource_name: redis
```

The table below explains the configuration attribues:

| Attribute                 | Description                    | Example             |
| ------------------------- | ------------------------------ | ------------------- |
| `type`                    | Type of task server being used | `celery`            |
| `name`                    | Unique name of the task server | `agent-task-server` |
| `replicas`                | Number of worker replicas      | `4`                 |
| `concurrency_per_replica` | Tasks per worker               | `1`                 |
| `broker_resource_name`    | Associated broker instance     | `redis`             |

**Note**: Before setting up a task server, setting up a Broker is a prerequisite. See [Broker](/ai-agents/concepts/broker.md) for more details.

Run the `gru` command to to set up the task server:

```bash
gru component setup --cluster-name <cluster-name> --config-file config.yaml
```

## Tool Tips

* See [Broker](/ai-agents/concepts/broker.md) ➡️
* Learn about [Checkpoint DB](/ai-agents/concepts/db.md) ➡️
* Explore [Memory](/ai-agents/concepts/conversations.md) ➡


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.canso.ai/ai-agents/concepts/task-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
