Skip to main content

Overview

Outputs are the results generated by agents executing tasks within orbits. OrbitAI provides a comprehensive output system that supports multiple formats, type-safe structured data, and rich metadata about execution.

Multiple Formats

Text, JSON, Markdown, CSV, XML, and structured

Type Safety

Strongly-typed structured outputs with Codable

Rich Metadata

Usage metrics, tool usage, timestamps

Fallback Parsing

Automatic error recovery for malformed outputs

Validation

Schema validation for structured data

Traceability

Track which agent produced which output

What are Outputs?

Outputs are the structured results from task execution that contain:
  • The actual generated content (raw or structured)
  • Metadata about execution (agent, task, timestamps)
  • Usage metrics (tokens, API calls)
  • Tool execution information
  • Validation results
Outputs provide complete traceability and observability into what agents produced and how they accomplished their tasks.

Key Characteristics

Outputs can be in various formats to suit different use cases:
Every output includes comprehensive metadata:
Use Swift’s type system for compile-time safety:
Automatic fallback strategies for parsing failures:

Output Types

TaskOutput

The result from a single task execution.

OrbitOutput

The aggregated result from an entire orbit execution.

StructuredOutput

Parsed structured data with optional schema validation.

Output Formats

OrbitAI supports multiple output formats to suit different use cases.
Format: Plain text output
Use Cases:
  • Human-readable reports
  • Summaries
  • Descriptions
  • General text generation

Structured Outputs

Comprehensive guide to creating and using type-safe structured outputs.

Creating Structured Outputs

1

Define Data Structure

Create a Codable struct representing your desired output:
Use nested types to organize complex data structures logically.
2

Create Task with Structured Output

Use the withStructuredOutput factory method:
The system automatically:
  • Generates appropriate JSON schema from the type
  • Instructs the LLM to return structured JSON
  • Validates the output against the schema
  • Provides type-safe decoding
3

Execute and Access

Execute the orbit and decode the structured output:
4

Handle Decoding Errors

Implement fallback strategies:

Assigning Structured Outputs

Benefits:
  • Automatic schema generation
  • Type-safe at compile time
  • Clean, readable API

Using Structured Outputs

Fallback Parsing

OrbitAI includes sophisticated fallback strategies for handling malformed outputs:
1

Direct Decoding

First attempt: Standard JSONDecoder
2

Wrapper Unwrapping

Handle common wrapper patterns:
3

Field Normalization

Map alternative field names:
4

Partial Extraction

Extract available fields with defaults:
5

Markdown Cleaning

Remove markdown formatting artifacts:

Error Handling

Common Output Errors

Missing Output

Error: Task completes but produces no output
Causes:
  • Task failed silently
  • Agent produced empty response
  • Output filtering removed content

Malformed JSON

Error: Cannot parse JSON output
Causes:
  • LLM generated invalid JSON
  • Extra text before/after JSON
  • Unclosed brackets/quotes

Schema Mismatch

Error: Output doesn’t match expected structure
Causes:
  • LLM misunderstood schema
  • Field name variations
  • Type differences

Empty Content

Error: Output exists but content is empty
Causes:
  • Task execution issue
  • Agent configuration problem
  • LLM returned empty response

Error Recovery Strategies

Best Practices

Output Design

Clear Structure

Do: Define clear, well-organized structures

Appropriate Types

Do: Use specific types

Optional vs Required

Do: Make intentional choices

Documentation

Do: Document expected structures

Performance

1

Minimize Output Size

2

Use Streaming for Large Outputs

3

Cache Common Outputs

Type Safety

Troubleshooting

Symptoms: Task completes but no outputDebug Steps:
Solutions:
  • Verify agent has proper configuration
  • Check task description is clear
  • Enable verbose logging
  • Verify LLM provider is working
Symptoms: DecodingError when parsing outputDebug Steps:
Solutions:
Symptoms: Valid JSON but doesn’t match schemaDebug:
Solutions:
  • Adjust schema to match actual output
  • Provide clearer instructions to LLM
  • Use examples in task description
  • Lower validation strictness
Symptoms: DecodingError.typeMismatchCommon Causes:
Solutions:
Symptoms: Output missing expected fieldsDebug:
Solutions:

Next Steps

Inputs

Learn about orbit inputs

Tasks

Configure task output formats

Agents

Understand agent output generation

Orbits

Access orbit-level outputs
For additional support, consult the GitHub Discussions or check the Issue Tracker.