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
ORTask
ORTask
The main task definition structure containing all task specifications, requirements, and configuration.
TaskExecutionEngine
TaskExecutionEngine
Central orchestrator that manages task execution across agents, handles concurrency, and enforces constraints.
TaskResult
TaskResult
Success/failure result wrapper that encapsulates execution outcomes and errors.
TaskOutput
TaskOutput
Contains execution results, metadata, usage metrics, and tool execution information.
TaskExecutionContext
TaskExecutionContext
Provides execution context including metadata and outputs from dependent tasks.
Task Parameters
Core Properties
- Required
- Optional
- Execution Control
- Execution State
| Property | Type | Description |
|---|---|---|
id | OrbitAIID | Unique identifier (UUID) for the task |
description | String | Detailed description of what to accomplish |
expectedOutput | String | Specification of output format and content |
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
Task Execution
Execution Patterns
- Sequential
- Hierarchical
- Flow-Based
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:Topological Sorting
Topological Sorting
Tasks are automatically sorted to ensure dependencies execute in the correct order:
Circular Dependency Detection
Circular Dependency Detection
The system automatically detects and prevents circular dependencies, throwing an error when detected.
Task Results
Result Structure
Task Output Components
Type-Safe Decoding
- Direct Decoding
- Safe Decoding
- Fallback 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
Execution Metrics
Execution Metrics
Key metrics tracked include:
- Task completion duration
- LLM token consumption
- Tool execution statistics
- Success/failure ratios
Agent Performance
Agent Performance
Per-agent execution metrics:
- Average task completion time
- Success rate
- Token efficiency
- Tool utilization
Resource Usage
Resource Usage
Resource consumption tracking:
- Memory usage
- API call counts
- Cache hit rates
- Concurrent task counts
Best Practices
Task Design
Clear Descriptions
Write specific, actionable task descriptions✅ Good:❌ Bad:
Defined Outputs
Specify expected output format clearly✅ Good:❌ Bad:
Appropriate Scope
Keep tasks focused and reasonably sized
Tool Selection
Choose relevant tools for requirements
Error Handling
Configure appropriate error handling and retry mechanisms:Structured Outputs
Use strongly-typed output structures when possible:Troubleshooting
Task Execution Timeouts
Task Execution Timeouts
Symptoms: Tasks fail with timeout errorsCauses:
- Insufficient execution time limits
- Complex tasks requiring more processing
- Agent inefficiency or loops
Structured Output Parsing Failures
Structured Output Parsing Failures
Symptoms: JSON parsing errors, type mismatchesCauses:
- LLM returning malformed JSON
- Unexpected output format
- Missing required fields
Agent Selection Issues
Agent Selection Issues
Symptoms: Tasks assigned to inappropriate agentsCauses:
- Insufficient capability matching
- Missing tool assignments
- Poor role alignment
Memory & Performance Issues
Memory & Performance Issues
Symptoms: High memory usage, slow executionCauses:
- Too many concurrent tasks
- Insufficient resource limits
- Memory leaks
Guardrail Violations
Guardrail Violations
Symptoms: Tasks fail due to guardrail violationsCauses:
- Content safety issues
- Token limits exceeded
- Rate limits hit
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.