This project demonstrates the advanced capabilities of Apple's Foundation Models framework, specifically showcasing how to use tool calling to create multi-agent LLM architectures. The system includes two distinct modes: Normal (direct LLM interaction) and Agentic (multi-agent orchestration).
The system implements two distinct architectures that showcase different LLM capabilities:
Direct LLM interaction without orchestration:
- Simple prompt → response flow
- Useful for baseline comparison with the multi-agent approaches
- Full call history tracking for performance analysis
A coordinator-based architecture where a root LLM orchestrates tasks between specialized sub-agents:
- Coordinator Agent - The main orchestrator that manages the flow between agents
- Planner Agent - Breaks down complex tasks into manageable subtasks
- Worker Agent - Executes individual subtasks (can run multiple instances in parallel)
- Synthesizer Agent - Combines all worker outputs into a coherent final result
- Each agent is implemented as a Tool conforming to the Foundation Models
Toolprotocol - Tools use
@Generablefor structured input/output with guided generation - The coordinator can call multiple worker tools in parallel for efficient execution
- Uses
@Guideannotations to constrain parameters (ranges, values, maximum counts) - Structured output formats ensure consistent agent communication
- Type-safe argument passing between agents
- Comprehensive error handling with custom
AgentErrortypes - Graceful degradation when models are unavailable
- Detailed error reporting through the transcript system
- Execute Tab: Input tasks and view results with mode selection (Normal, Agentic)
- History Tab: Hierarchical view of all LLM calls with parent-child relationships
- Model Info Tab: System status and architecture overview
PlannerTool(task_planner): Takes a task description and breaks it into subtasks with dependenciesWorkerTool(task_worker): Executes individual subtasks with time trackingSynthesizerTool(result_synthesizer): Combines worker results with quality scoring and insights
All response types use @Generable for structured generation:
- Agentic Mode:
TaskPlan,WorkerResult,SynthesisResult
- macOS 26.0+ or iOS 26.0+
- Device with Apple Intelligence support
- Apple Intelligence enabled in Settings
- Xcode 26.0+
- Open the app and ensure the model status shows "Available"
- Select a mode using the segmented control:
- Normal Mode: Direct LLM response (default)
- Agentic Mode: Multi-agent orchestration
- Enter a task description in the main interface
- Click "Execute Task" to see the selected architecture in action
- View the History tab to see the hierarchical call structure
- "Explain quantum-computing"
- "What is recursion in programming?"
- "Create a plan for a trip to Morocco"
This implementation demonstrates:
- Tool protocol implementation with async/await
- Concurrent tool execution capabilities
- Session management with role-specific instructions
- Call hierarchy tracking for debugging
- SwiftUI integration with ObservableObject agents
- Mode switching between two different architectures
- Tools as LLM instances (not just function calls)
- Structured output parsing with fallback handling
- Comparison framework for evaluating different approaches