Skip to main content

Overview

OrbitAI Tasks are the fundamental execution units in the OrbitAI framework. A task represents a specific piece of work that needs to be completed by an AI agent, with defined requirements, constraints, and expected outputs.

Type Safety

Built with Swift’s strong typing for compile-time safety

Async/Await

Native Swift concurrency for efficient execution

Structured Outputs

Support for text and structured data outputs

Validation

Built-in guardrails and validation mechanisms

Monitoring

Comprehensive telemetry and performance tracking

Flexibility

Various output formats and execution patterns

Architecture

OrbitAI’s task system consists of several key components working together to orchestrate task execution:

Key Components

The main task definition structure containing all task specifications, requirements, and configuration.
Central orchestrator that manages task execution across agents, handles concurrency, and enforces constraints.
Success/failure result wrapper that encapsulates execution outcomes and errors.
Contains execution results, metadata, usage metrics, and tool execution information.
Provides execution context including metadata and outputs from dependent tasks.

Task Parameters

Core Properties

Output Formats

OrbitAI supports multiple output formats to meet different use cases:

Text

Plain text output for human-readable results

JSON

Generic JSON output for flexible data structures

Markdown

Markdown formatted text for documentation

CSV

Comma-separated values for tabular data

XML

XML structured output for legacy systems

Structured

Schema-validated structured output

Structured Output Example

Use structured outputs with Swift’s Codable types for type-safe data handling and compile-time validation.

Task Execution

Execution Patterns

Tasks execute one after another, with context updated between tasks:
Use when:
  • Tasks depend on previous results
  • Order of execution matters
  • Context needs to build progressively
Sequential execution is the default and most common pattern for task workflows.

Agent Selection

The TaskExecutionEngine uses a multi-step approach for optimal agent selection:
1

Explicit Assignment

Respects task-agent assignments when specified:
2

Compatibility Scoring

Evaluates tool compatibility and role relevance:
3

LLM-Based Selection

Uses LLM reasoning for close decisions when scores are similar.
4

Caching

Caches selections for similar tasks to improve performance.

Task Dependencies

Context Dependencies

Tasks can depend on outputs from previous tasks:
Reference previous task outputs using {task_N_output} syntax in task descriptions, where N is the task index.

Conditional Tasks

Execute tasks based on previous results:

Dependency Resolution

The system automatically handles dependency resolution:
Tasks are automatically sorted to ensure dependencies execute in the correct order:
The system automatically detects and prevents circular dependencies, throwing an error when detected.
Circular dependencies will cause task execution to fail with OrbitAIError.taskExecutionFailed.

Task Results

Result Structure

Task Output Components

Type-Safe Decoding

Validation & Guardrails

OrbitAI includes a comprehensive type-safe guardrail system for validation and safety:

Content Safety

NoHarmfulContentGuardrailChecks for harmful keywords and patterns in content.

Token Limits

TokenLimitGuardrailEnforces maximum token limits for content.

Rate Limiting

RateLimitGuardrailPrevents excessive requests from agents.

Custom Guardrails

OrbitGuardrail ProtocolImplement custom validation logic.

Validation Strictness

Control how strictly task outputs are validated:

Manager Validation

Tasks can be validated by manager agents with feedback:

Metrics & Monitoring

Usage Metrics

Comprehensive metrics are collected for each task execution:

Tool Usage Tracking

Performance Monitoring

Key metrics tracked include:
  • Task completion duration
  • LLM token consumption
  • Tool execution statistics
  • Success/failure ratios
Per-agent execution metrics:
  • Average task completion time
  • Success rate
  • Token efficiency
  • Tool utilization
Resource consumption tracking:
  • Memory usage
  • API call counts
  • Cache hit rates
  • Concurrent task counts

Best Practices

Task Design

Clear Descriptions

Write specific, actionable task descriptionsGood:
Bad:

Defined Outputs

Specify expected output format clearlyGood:
Bad:

Appropriate Scope

Keep tasks focused and reasonably sized
Break large tasks into smaller, manageable subtasks for better control and debugging.

Tool Selection

Choose relevant tools for requirements

Error Handling

Configure appropriate error handling and retry mechanisms:
Always set reasonable execution timeouts to prevent tasks from running indefinitely.

Structured Outputs

Use strongly-typed output structures when possible:

Troubleshooting

Symptoms: Tasks fail with timeout errorsCauses:
  • Insufficient execution time limits
  • Complex tasks requiring more processing
  • Agent inefficiency or loops
Solutions:
Symptoms: JSON parsing errors, type mismatchesCauses:
  • LLM returning malformed JSON
  • Unexpected output format
  • Missing required fields
Solutions:
Symptoms: Tasks assigned to inappropriate agentsCauses:
  • Insufficient capability matching
  • Missing tool assignments
  • Poor role alignment
Solutions:
Symptoms: High memory usage, slow executionCauses:
  • Too many concurrent tasks
  • Insufficient resource limits
  • Memory leaks
Solutions:
Symptoms: Tasks fail due to guardrail violationsCauses:
  • Content safety issues
  • Token limits exceeded
  • Rate limits hit
Solutions:

Debugging Tips

1

Enable Verbose Logging

2

Monitor Execution Status

3

Analyze Task Metrics

4

Test with Simple Tasks

Next Steps

Agents

Learn how agents execute tasks

Orbits

Orchestrate tasks in workflows

Tools

Extend task capabilities with tools

Guardrails

Implement validation and safety
For additional support, consult the GitHub Discussions or check the Issue Tracker.