ollama-code

Task Tool (task)

This document describes the task tool for Ollama Code.

Description

Use task to launch a specialized subagent to handle complex, multi-step tasks autonomously. The Task tool delegates work to specialized agents that can work independently with access to their own set of tools, allowing for parallel task execution and specialized expertise.

Arguments

task takes the following arguments:

How to use task with Ollama Code

The Task tool dynamically loads available subagents from your configuration and delegates tasks to them. Each subagent runs independently and can use its own set of tools, allowing for specialized expertise and parallel execution.

When you use the Task tool, the subagent will:

  1. Receive the task prompt with full autonomy
  2. Execute the task using its available tools
  3. Return a final result message
  4. Terminate (subagents are stateless and single-use)

Usage:

task(description="Brief task description", prompt="Detailed task instructions for the subagent", subagent_type="agent_name")

Available Subagents

The available subagents depend on your configuration. Common subagent types might include:

You can view available subagents by using the /agents command in Ollama Code.

Task Tool Features

Real-time Progress Updates

The Task tool provides live updates showing:

Parallel Execution

You can launch multiple subagents concurrently by calling the Task tool multiple times in a single message, allowing for parallel task execution and improved efficiency.

Specialized Expertise

Each subagent can be configured with:

task examples

Delegating to a general-purpose agent

task(
  description="Code refactoring",
  prompt="Please refactor the authentication module in src/auth/ to use modern async/await patterns instead of callbacks. Ensure all tests still pass and update any related documentation.",
  subagent_type="general-purpose"
)

Running parallel tasks

# Launch code review and test execution in parallel
task(
  description="Code review",
  prompt="Review the recent changes in the user management module for code quality, security issues, and best practices compliance.",
  subagent_type="code-reviewer"
)

task(
  description="Run tests",
  prompt="Execute the full test suite and analyze any failures. Provide a summary of test coverage and recommendations for improvement.",
  subagent_type="test-runner"
)

Documentation generation

task(
  description="Update docs",
  prompt="Generate comprehensive API documentation for the newly implemented REST endpoints in the orders module. Include request/response examples and error codes.",
  subagent_type="documentation-writer"
)

When to Use the Task Tool

Use the Task tool when:

  1. Complex multi-step tasks - Tasks requiring multiple operations that can be handled autonomously
  2. Specialized expertise - Tasks that benefit from domain-specific knowledge or tools
  3. Parallel execution - When you have multiple independent tasks that can run simultaneously
  4. Delegation needs - When you want to hand off a complete task rather than micromanaging steps
  5. Resource-intensive operations - Tasks that might take significant time or computational resources

When NOT to Use the Task Tool

Don’t use the Task tool for:

Important Notes

Configuration

Subagents are configured through Ollama Code’s agent configuration system. Use the /agents command to:

For more information on configuring subagents, refer to the subagents documentation.