Multi-Agent Collaboration Overview
A four-layer division of work with Codex as the core coordinator
Codex - Primary Coordinator
Decomposes tasks, schedules resources, generates images, edits files, validates outputs, and prepares final delivery while retaining core project decisions.
Antigravity IDE - Parallel Coordinator
Coordinates long-running work, video or subtitle analysis, parallel subtask decomposition, and visible IDE-based progress.
Gemini CLI - Cloud Advisor
Provides advanced reasoning, web-search context, cross-tool synthesis, and a fallback when parallel IDE coordination is unavailable.
Ollama - Local Draft Executor
Runs local GPU or NPU inference for low-risk drafts, summaries, rewrites, translations, and classifications. The example default is gemma3-tw-edu:4b.
Architecture Relationship Map
Parallel Coordination] A2[Gemini CLI
Cloud Reasoning] A3[Ollama
Local Drafting] end subgraph Skills["Skill Package Layer"] S1[external-agent-orchestrator] S2[skill-registry.yaml] S3[dispatch-task.ps1] S4[detect-tools.ps1] S5[log-event.ps1] end U --> C1 C1 -->|long-running / media / parallel| A1 C1 -->|research / planning / review| A2 C1 -->|draft / summary / translation| A3 C1 --> S1 S1 --> S2 S1 --> S3 S3 --> S4 S3 --> S5 style Core fill:#dbeafe,stroke:#1e40af style Agents fill:#fef3c7,stroke:#92400e style Skills fill:#d1fae5,stroke:#065f46 style User fill:#e9d5ff,stroke:#6b21a8
Tool Detection and Routing
Automatic detection with detect-tools.ps1 and policy-based dispatch with dispatch-task.ps1
Tool Detection Flow
Automatic Routing Logic
Dispatch Template System
@(
"research" = @{ targets=@("gemini","ollama","antigravity"); model="gemma4:e4b"
gemini="Lead researcher: compare options and recommend"; ollama="Local analyst: draft summaries and lists"; antigravity="Decomposition assistant: parallel subtasks" }
"agent-collab" = @{ targets=@("antigravity","gemini","ollama")
gemini="Cloud advisor: complex reasoning"; ollama="Local executor: summary and translation"; antigravity="IDE coordinator: long-running work" }
"translation" = @{ targets=@("ollama") }
"video-analysis" = @{ targets=@("antigravity","gemini") }
"subtitle" = @{ targets=@("antigravity","gemini") }
)Fallback Strategy
- ✓ If Antigravity is unavailable, fall back to Gemini CLI
- ✓ If both video or subtitle routes are unavailable, stop rather than routing the task to Ollama
- ✓ If an explicitly requested tool is unavailable, log the error and stop
- ✓ If only one tool is available, reserve it for the highest-value stage and let Codex integrate
- ✓ For current-information or high-risk tasks, log the exception and escalate
Skill Package and Version Management
Central registration, dependency declarations, and SHA-256 verification through skill-registry.yaml
Skill Registry Structure
schema_version: 1
audited_at: "2026-07-23"
policy: "Codex owns implementation and validation; Ollama is a reviewed low-risk draft option."
skills:
- name: external-agent-orchestrator
short_description: "Auditable cross-tool coordination"
applies_to: "Cross-tool, long-running, or evidence-logged work"
excludes: "Ordinary simple questions"
dependencies: ollama-simple-answer-review
version: "2"
- name: crossref-apa-bibliography
dependencies: documents, spreadsheets
version: "1"
- name: journal-manuscript-writer
dependencies: crossref-apa-bibliography, documents, pdf
version: "1"
- name: ena-network-figure
dependencies: journal-manuscript-writer
version: "1"
- name: pd-survey-analysis-report
dependencies: spreadsheets, documents, ena-network-figure
version: "1"
Dependency Map (arrows point to dependencies)
Version Control and Validation
Git Version Control
- • Use a dedicated Git repository or monorepo
- • Apply semantic versioning
- • Record breaking changes in CHANGELOG.md
SHA-256 Verification
- • Calculate hashes with quick_validate.py
- • Compare with the registry value
- • Block damaged or mismatched packages
Dependency Resolution
- 1. Topologically sort the dependency graph
- 2. Load dependency-free foundational skills first
- 3. Report circular dependencies
Implementation Examples and Good Practices
Practical dispatch, structured logging, and bilingual report production with dispatch-task.ps1
Example 1: Research Dispatch
powershell -ExecutionPolicy Bypass -File ".\scripts\dispatch-task.ps1"
-Task "Compare three RAG architectures and recommend an option"
-Template research -Target auto
-ContextFiles @("docs/rag-options.md")
-OutputRoot "C:\Projects\outputs\rag-research"Output: .external-agent-orchestrator/logs/runs/20260728-XXXXX/ contains request.txt, gemini.md, ollama.md, antigravity-launch.md, and manifest.json
Example 2: Multi-Agent Collaboration
powershell -ExecutionPolicy Bypass -File ".\scripts\dispatch-task.ps1"
-Task "Design an architecture document for a teaching website"
-Template agent-collab -Target all
-ContextFiles @(
"skills/external-agent-orchestrator/SKILL.md",
"skills/external-agent-orchestrator/scripts/dispatch-task.ps1",
"skills/skill-registry.yaml"
)
-OutputRoot "C:\Projects\opencodex\teaching-site"Log Format (JSONL)
{
"timestamp": "2026-07-28T07:05:38.329+08:00",
"actor": "ollama",
"event": "run-complete",
"status": "ok",
"summary": "Ollama dispatch completed with model gemma3-tw-edu:4b.",
"task": "Teaching website architecture design",
"outputs": ["\outputs\\ollama.md"],
"cwd": ""
} Good-Practice Checklist
Before Dispatch
- ☐ Run detect-tools.ps1 to confirm tool availability
- ☐ Select a template based on task type
- ☐ Prepare ContextFiles using explicit paths
- ☐ Set OutputRoot to a project-specific directory
During and After Execution
- ☐ Call log-event.ps1 at each critical step
- ☐ Retain manifest.json for audit tracing
- ☐ Produce bilingual HTML or DOCX process reports
- ☐ Visually inspect diagrams before delivery
Visual Workflow Diagrams (Mermaid)
The complete dispatch lifecycle, tool-selection decision tree, and skill dependency topology
Dispatch Lifecycle
Tool-Selection Decision Tree
Skill Dependency Topology
Reading note: resolve cycles before loading
The current registry declares bidirectional dependencies between external-agent-orchestrator and ollama-simple-answer-review, as well as among several media skills. The diagrams retain these links as audit signals. If the loader requires a strict directed acyclic graph, revise the registry before topological sorting.
Reference Files and Configuration
A practical reference for project files and key configuration fields
Core File List
| File Path | Purpose | Key Content |
|---|---|---|
| skills/external-agent-orchestrator/SKILL.md | Primary skill file | Routing policy, logging rules, report production, and dispatch templates |
| skills/external-agent-orchestrator/scripts/detect-tools.ps1 | Tool detection | PATH and fallback resolution with JSON output |
| skills/external-agent-orchestrator/scripts/dispatch-task.ps1 | Task dispatch | Templates, automatic routing, manifest generation, and dry runs |
| skills/external-agent-orchestrator/scripts/log-event.ps1 | Structured logging | JSONL records, retry-safe writes, and actor/event/status fields |
| skills/external-agent-orchestrator/scripts/read-log.ps1 | Log reader | Tail, JSON, table output, and filters |
| skills/skill-registry.yaml | Skill registry | Version, dependencies, inclusion and exclusion scope, and policy |
| .external-agent-orchestrator/logs/agent-events.jsonl | Event log | Append-only records of dispatch events |
| .external-agent-orchestrator/logs/runs/ | Run artifacts | A separate directory and manifest.json for each dispatch |
Environment Path Configuration
SKILL_ROOT = "<user-home>\.codex\skills\external-agent-orchestrator" PROJECT_STATE = "<project-root>\.external-agent-orchestrator" EVENT_LOG = "<project-root>\.external-agent-orchestrator\logs\agent-events.jsonl" RUNS_ROOT = "<project-root>\.external-agent-orchestrator\logs\runs" gemini: <user-profile>\AppData\Roaming\npm\gemini.ps1 ollama: <user-profile>\AppData\Local\Programs\Ollama\ollama.exe antigravity: <install-root>\Antigravity IDE\bin\antigravity-ide.cmd
Ollama Model List
| Model | Size | Purpose | Notes |
|---|---|---|---|
| gemma3-tw-edu:4b | 3.3 GB | Teaching and Traditional Chinese | Example default ✓ |
| gemma4:e4b | 9.6 GB | High-quality general use | dispatch-task fallback |
| gemma3n:e4b | 7.5 GB | Architecture experiments | |
| qwen3:4b | 2.5 GB | Chinese and multilingual | Lightweight alternative |
| minicpm-v:latest | 5.5 GB | Vision model | Multimodal tasks |