Inter-Agent Communication Protocols

Advanced Reference — This document is for developers building custom agents or integrations. For regular usage, see the AI Agent Guide. For getting started, see the Getting Started guide.

Version: v1  ·  Status: Active  ·  Date: 2026-02-23


Overview

This document is the technical reference for Orchestratia's inter-agent communication protocols. It defines the exact schemas, API endpoints, validation rules, and error behaviors for:

  • Task Specs — Machine-parseable task requirements
  • Result Reporting — Structured completion data with contract fulfillment
  • Dependencies — Typed relationships (blocks, input, related) between tasks
  • Contract Exchange — Structured data flow from upstream to downstream tasks
  • Ownership & Delegation — People-owned tasks, session links, Send to Claude, agent delegation

All structured-protocol features are opt-in and backwards-compatible. Tasks that don't use structured specs continue to work exactly as before.

For conceptual overviews, see Platform Overview. For workflow walkthroughs, see End-to-End Workflows. For the agent's perspective, see AI Agent Guide.


1. Task Spec Format

Schema identifier: orchestratia/task-spec/v1

The structured task spec provides a machine-parseable layer on top of the free-form spec text field. Stored in the tasks.structured_spec JSONB column (nullable). The spec text field remains for human readability.

Full Example

{
  "$schema": "orchestratia/task-spec/v1",
  "requirements": [
    {
      "description": "Implement JWT authentication middleware",
      "priority": "must",
      "category": "feature"
    },
    {
      "description": "Support refresh token rotation",
      "priority": "should",
      "category": "feature"
    },
    {
      "description": "Rate limiting on auth endpoints",
      "priority": "could",
      "category": "security"
    }
  ],
  "input_context": {
    "references": [
      {
        "type": "task",
        "id": "uuid-of-upstream-task",
        "description": "API schema definitions from task A"
      },
      {
        "type": "url",
        "url": "https://datatracker.ietf.org/doc/html/rfc7519",
        "description": "JWT RFC specification"
      }
    ]
  },
  "constraints": {
    "languages": ["typescript"],
    "frameworks": ["express"],
    "testing": "required",
    "no_breaking_changes": true,
    "max_files_changed": 15,
    "custom": {
      "node_version": ">=18"
    }
  },
  "output_expectations": {
    "contracts": {
      "auth_middleware": {
        "description": "Express middleware function for JWT validation",
        "format": "module_export",
        "required": true
      }
    },
    "artifacts": ["test_report", "coverage_html"]
  }
}

Field Reference

Top-Level Fields

Field Type Required Description
$schema string Yes Must be "orchestratia/task-spec/v1"
requirements array Yes List of requirement objects (at least one)
input_context object No Context and reference material for the task
constraints object No Technical constraints on implementation
output_expectations object No Expected outputs and contracts

requirements[] Fields

Field Type Required Description
description string Yes What needs to be done
priority enum Yes must | should | could (MoSCoW method)
category string No Free-form category (e.g. "feature", "security", "performance")

Priority semantics:

  • must — Required for task completion. Absence is a failure.
  • should — Expected unless there's a justified reason to omit.
  • could — Nice to have. Implement if time allows.

input_context.references[] Fields

Field Type Required Description
type enum Yes task | file | url
id string Conditional UUID for task type, filename for file type
url string Conditional Required for url type
description string No What this reference provides

constraints Fields

Field Type Required Description
languages string[] No Required programming languages
frameworks string[] No Required frameworks
testing enum No required | recommended | none
no_breaking_changes boolean No If true, must not break existing APIs
max_files_changed integer No Soft limit on scope
custom object No Arbitrary key-value constraints

output_expectations Fields

Field Type Required Description
contracts object No Named contract declarations (see Contract Exchange below)
contracts.{key}.description string Yes What this contract provides
contracts.{key}.format string No Format hint (e.g. "json", "module_export")
contracts.{key}.required boolean No Whether this contract must be fulfilled
artifacts string[] No Expected non-contract artifacts

Validation: Contract keys must be alphanumeric with underscores. At least one requirement must exist.

API Usage

POST /api/v1/tasks
Authorization: Bearer {jwt}
Content-Type: application/json
 
{
  "title": "Implement JWT auth middleware",
  "spec": "Human-readable description of the task...",
  "type": "feature",
  "priority": "high",
  "target_repo": "api-gateway",
  "structured_spec": {
    "$schema": "orchestratia/task-spec/v1",
    "requirements": [
      {"description": "JWT validation middleware", "priority": "must"}
    ],
    "constraints": {"languages": ["typescript"], "testing": "required"},
    "output_expectations": {
      "contracts": {
        "auth_middleware": {
          "description": "Express middleware for JWT validation",
          "required": true
        }
      }
    }
  }
}

Response (201 Created):

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "title": "Implement JWT auth middleware",
  "status": "pending",
  "type": "feature",
  "priority": "high",
  "created_at": "2026-02-23T10:00:00Z"
}

Tasks can also be created by agents (from within sessions):

POST /api/v1/server/tasks
X-API-Key: orc_...
 
{
  "title": "Implement auth middleware",
  "spec": "Based on the API schema from task A...",
  "priority": "high",
  "session_id": "uuid-of-current-session",
  "structured_spec": { ... }
}

2. Result Reporting Format

Schema identifier: orchestratia/task-result/v1

When an agent completes a task, it reports a structured result. This is stored in the tasks.result JSONB column and used for contract fulfillment, downstream data flow, and review.

Full Example

{
  "$schema": "orchestratia/task-result/v1",
  "summary": "Implemented JWT auth middleware with RS256 signing and refresh token rotation",
  "changes": {
    "files_modified": ["src/middleware/index.ts", "src/types/auth.ts"],
    "files_created": [
      "src/middleware/auth.ts",
      "src/middleware/__tests__/auth.test.ts",
      "src/utils/jwt.ts"
    ],
    "files_deleted": [],
    "lines_added": 342,
    "lines_removed": 18
  },
  "contracts": {
    "auth_middleware": {
      "status": "fulfilled",
      "data": {
        "export_path": "src/middleware/auth.ts",
        "function_name": "validateJWT",
        "usage": "app.use(validateJWT({ publicPaths: ['/health'] }))"
      }
    }
  },
  "tests": {
    "framework": "jest",
    "total": 15,
    "passed": 15,
    "failed": 0,
    "skipped": 0,
    "coverage_percent": 94.2
  },
  "artifacts": {
    "coverage_html": "/tmp/coverage/index.html"
  }
}

Field Reference

Top-Level Fields

Field Type Required Description
$schema string Yes Must be "orchestratia/task-result/v1"
summary string Yes One-line summary of what was accomplished
changes object No Files changed
contracts object No Contract fulfillment data
tests object No Test results
artifacts object No Additional output references

changes Fields

Field Type Required Description
files_modified string[] No Existing files that were changed
files_created string[] No New files created
files_deleted string[] No Files removed
lines_added integer No Total lines added
lines_removed integer No Total lines removed

contracts.{key} Fields

Field Type Required Description
status enum Yes fulfilled | partial | skipped
data object No The actual contract payload (arbitrary structure)

Status semantics:

  • fulfilled — Contract fully satisfied. data contains the promised output.
  • partial — Partially done. Downstream tasks receive the data but should expect gaps.
  • skipped — Intentionally not fulfilled. Must provide reason in data.

tests Fields

Field Type Required Description
framework string No Test framework used (jest, pytest, cargo test)
total integer No Total test count
passed integer No Tests passed
failed integer No Tests failed
skipped integer No Tests skipped
coverage_percent number No Code coverage percentage

API Usage

Agent daemon completes a task:

POST /api/v1/servers/tasks/{task_id}/complete
X-API-Key: orc_...
Content-Type: application/json
 
{
  "result": {
    "$schema": "orchestratia/task-result/v1",
    "summary": "Implemented JWT auth middleware",
    "contracts": {
      "auth_middleware": {
        "status": "fulfilled",
        "data": {"export_path": "src/middleware/auth.ts"}
      }
    }
  }
}

Response (200 OK):

{"status": "ok"}

Agent-internal endpoint (also accepts string results):

POST /api/v1/server/tasks/{task_id}/complete
X-API-Key: orc_...
 
{"result": "Implemented JWT auth middleware with full test coverage"}

String results are auto-wrapped as {"summary": "...", "completed_by": "agent:{name}"}.

Legacy Results

Results without the $schema field are treated as legacy format:

  • No contract validation or fulfillment checking
  • No structured data flow to downstream tasks
  • Stored as-is in the result column

What Happens After Completion

When a task transitions to done, the hub triggers a cascade:

flowchart TD
    Start["Task A completes with result"]
    Start --> B["1. Contract Check"]
    B --> C["2. Resolve Dependencies"]
    C --> D["3. Unblock Check"]
    D --> E["4. Notify Assignee"]
    E --> F["5. Broadcast"]

    B -.- B1["Compare result.contracts against<br/>output_expectations. Log:<br/>contract_fulfilled or contract_missing"]
    C -.- C1["For each downstream dep:<br/>blocks → resolve<br/>input → extract data, resolve<br/>related → resolve"]
    D -.- D1["For each downstream task:<br/>ALL blocking deps resolved?<br/>Yes → UNBLOCKED"]
    E -.- E1["For each newly unblocked task:<br/>report it as UNBLOCKED<br/>and notify its assignee"]
    F -.- F1["WebSocket → dashboards<br/>Event Bus → Telegram<br/>Activity log → database"]

    style Start fill:#00B8D9,stroke:#0A7A92,color:#fff
    style B fill:#E6F8FB,stroke:#00B8D9
    style C fill:#E6F8FB,stroke:#00B8D9
    style D fill:#E6F8FB,stroke:#00B8D9
    style E fill:#E6F8FB,stroke:#00B8D9
    style F fill:#E6F8FB,stroke:#00B8D9
    style B1 fill:#FAF8F5,stroke:#E8E3DA,color:#706961
    style C1 fill:#FAF8F5,stroke:#E8E3DA,color:#706961
    style D1 fill:#FAF8F5,stroke:#E8E3DA,color:#706961
    style E1 fill:#FAF8F5,stroke:#E8E3DA,color:#706961
    style F1 fill:#FAF8F5,stroke:#E8E3DA,color:#706961

Contract validation is advisory — missing contracts log warnings but never block task completion or downstream unblocking. This is intentional: it's better to unblock waiting tasks with partial data than to deadlock the pipeline.


3. Dependency Declarations

Dependencies define ordering and data-flow relationships between tasks. Stored in the task_dependencies table.

Dependency Types

Type Blocking? Data Transfer? When Resolved
blocks Yes No Upstream task reaches done
input Yes Yes (via contracts) Upstream completes AND contract key found in result
related No No Immediately (informational only)

Field Reference

Field Type Required Description
depends_on_task_id UUID Yes The upstream task
dependency_type enum No blocks (default) | input | related
contract_key string Conditional Required when type is input. Must match a contract key in the upstream task's result.

Creating Dependencies

Method 1: Typed dependencies (recommended)

POST /api/v1/tasks
Authorization: Bearer {jwt}
 
{
  "title": "Implement API client",
  "spec": "Build the client based on the API schema...",
  "dependencies": [
    {
      "depends_on_task_id": "uuid-of-schema-task",
      "dependency_type": "input",
      "contract_key": "api_schema"
    },
    {
      "depends_on_task_id": "uuid-of-setup-task",
      "dependency_type": "blocks"
    }
  ]
}

Method 2: Legacy UUID list (backwards-compatible)

{
  "title": "Implement API client",
  "spec": "...",
  "dependency_ids": ["uuid-of-schema-task", "uuid-of-setup-task"]
}

Legacy dependency_ids are treated as blocks type with no contract linking.

Querying Dependencies

GET /api/v1/tasks/{task_id}

Returns the task detail including dependency status:

{
  "id": "...",
  "title": "Implement API client",
  "status": "pending",
  "dependencies": [
    {
      "depends_on_task_id": "uuid-of-schema-task",
      "dependency_type": "input",
      "contract_key": "api_schema",
      "resolved": false,
      "resolved_at": null
    },
    {
      "depends_on_task_id": "uuid-of-setup-task",
      "dependency_type": "blocks",
      "contract_key": null,
      "resolved": true,
      "resolved_at": "2026-02-23T10:05:00Z"
    }
  ]
}

Resolution Behavior

When an upstream task completes:

Dependency Type Resolution Condition What Downstream Receives
blocks Upstream status = done Nothing (ordering only)
input Upstream status = done AND result.contracts.{contract_key} exists Contract data in resolved_inputs.{contract_key}
related Always resolved immediately Nothing (informational)

Edge case: If an input dependency's upstream completes but the specified contract_key is missing from the result, the dependency is still resolved (with a contract_missing warning logged). This prevents deadlocks.


4. Contract Exchange

Contracts are the mechanism for structured data flow between tasks. An upstream task declares what it will produce, and a downstream task declares what it consumes. The hub validates, extracts, and delivers the data.

Lifecycle

sequenceDiagram
    participant A as Task A (upstream)
    participant Hub as Orchestratia Hub
    participant B as Task B (downstream)

    Note over A: 1. DECLARE<br/>structured_spec.output_expectations<br/>contracts: { api_schema: ... }
    Note over B: 2. DEPEND<br/>dependencies: [{ depends_on: A,<br/>type: "input", contract_key: "api_schema" }]

    A->>Hub: Complete with result.contracts.api_schema<br/>{ status: "fulfilled", data: { endpoints: [...] } }

    Hub->>Hub: 3. Validate contract key exists
    Hub->>Hub: 4. Extract contract data
    Hub->>Hub: 5. Mark dependency resolved
    Hub->>Hub: 6. Check: all B's deps resolved?

    Hub->>B: 7. Inject resolved_inputs.api_schema<br/>+ notify Task B's assignee (unblocked)

    Note over B: B receives:<br/>resolved_inputs.api_schema = <br/>{ endpoints: [...], types: {...} }

How Agents Receive Contract Data

When an agent polls for assigned tasks, contract data from upstream tasks is included as resolved_inputs:

GET /api/v1/servers/tasks/poll
X-API-Key: orc_...

Response:

[
  {
    "id": "task-b-uuid",
    "title": "Implement API client",
    "spec": "Build the client based on the API schema...",
    "structured_spec": { ... },
    "resolved_inputs": {
      "api_schema": {
        "endpoints": [
          {"path": "/users", "method": "GET", "response": "User[]"},
          {"path": "/users/{id}", "method": "GET", "response": "User"}
        ],
        "types": {
          "User": {"id": "uuid", "name": "string", "email": "string"}
        }
      }
    }
  }
]

resolved_inputs is assembled by the hub from all resolved input-type dependencies. Each key corresponds to a contract_key in the dependency declaration.

Contract Validation Behavior

Scenario Result Logged Event
Contract declared as required, found in result Dependency resolved, data delivered contract_fulfilled
Contract declared as required, missing from result Dependency still resolved (advisory), warning logged contract_missing
Contract not declared in spec, found in result Accepted, delivered to downstream contract_fulfilled
No contracts in result, no contracts expected Normal completion, no contract events —

Design decision: Contract validation is advisory, not enforcing. Missing contracts log warnings but never block task completion or downstream unblocking. This prevents pipeline deadlocks while still providing visibility into contract compliance.


5. Task Ownership & Delegation

There is no automatic assignment and no capability matching. Every task is owned by a person — the assignee — and sessions are where the work happens.

Task Keys

Tasks have keys like ORC-42 (project prefix + number). A key is accepted anywhere a task id is: the dashboard API and the orchestratia task ... CLI (agent 0.34.0 and later).

Linking and Sending

Action Effect
Link a session Records the session against the task. Nothing is typed into the session.
Send to Claude Pushes the task into the linked session. Requires drive access; plan mode and approval gates still apply.
Withdraw from Claude Takes the task back before Claude starts.

Agent Delegation

orchestratia task assign <task> --session <name>

The assignee becomes the person who started that session, and the task is sent to it. Only pending or assigned tasks that are unassigned, the caller's own, or that session owner's can be delegated this way.

Unblocking

When a task's last blocking dependency resolves, the cascade reports the task as UNBLOCKED and notifies its assignee. It is not auto-assigned.

Epics and Notifications

Epics group tasks (people's and Claude's) with progress derived from their status; orchestratia task view shows a task's epic, and orchestratia task create --epic ORC-12 adds a task to one. People are notified in the in-app inbox, by email, and in a per-project Slack incoming webhook when a task is assigned to them, they are mentioned, Claude needs help, a task moves to review or fails, a plan awaits approval, a task is unblocked, or a task is due.


6. Complete API Reference

Task Protocol Endpoints

Method Path Auth Purpose
POST /api/v1/tasks JWT Create task with structured spec, assignee, dependencies
GET /api/v1/tasks/{id} JWT Get task detail including dependency status and resolved_inputs
PUT /api/v1/tasks/{id} JWT Update task fields (title, spec, structured_spec, priority, due date, labels, epic)
POST /api/v1/tasks/{id}/assign JWT Set the assignee: {user_id} (a person; null clears)
GET/POST /api/v1/tasks/{id}/sessions JWT Link history / link a session (records only)
POST /api/v1/tasks/{id}/send JWT Send to Claude in the linked session (needs drive access)
POST /api/v1/tasks/{id}/withdraw JWT Withdraw from Claude before it starts
POST /api/v1/tasks/{id}/notes JWT Add note to task
GET /api/v1/tasks/{id}/notes JWT List task notes
POST /api/v1/tasks/{id}/approve-plan JWT Approve worker's submitted plan
POST /api/v1/tasks/{id}/revise-plan JWT Request plan revision with feedback
POST /api/v1/server/tasks API Key Agent creates a sub-task

Agent Task Lifecycle Endpoints (Daemon)

Method Path Auth Purpose
GET /api/v1/servers/tasks/poll API Key Poll for assigned tasks (includes resolved_inputs)
POST /api/v1/servers/tasks/{id}/start API Key Transition: assigned → running (rejects if unresolved blocking deps)
POST /api/v1/servers/tasks/{id}/complete API Key Transition: running → done (with result)
POST /api/v1/servers/tasks/{id}/fail API Key Transition: running → failed
POST /api/v1/servers/tasks/{id}/help API Key Transition: running → needs_human
POST /api/v1/server/tasks/{id}/notes API Key Agent adds note to task
POST /api/v1/server/tasks/{id}/plan API Key Worker submits plan (planning → plan_review)

Agent CLI / Orchestrator Endpoints

These endpoints power the orchestratia CLI tool and orchestrator agents. They provide full task management capabilities without requiring JWT authentication — API key auth only.

Method Path Auth Purpose
POST /api/v1/server/tasks API Key Create task (with type, repo, deps, acceptance criteria)
GET /api/v1/server/tasks API Key List tasks (filter by project_id, status)
GET /api/v1/server/tasks/check API Key Check for tasks assigned to a session
GET /api/v1/server/tasks/{id} API Key View task detail (with deps, resolved_inputs, server name)
PUT /api/v1/server/tasks/{id} API Key Update task fields (title, spec, priority, type, repo, etc.)
DELETE /api/v1/server/tasks/{id} API Key Cancel a task
POST /api/v1/server/tasks/{id}/start API Key Transition to running (rejects if unresolved blocking deps)
POST /api/v1/server/tasks/{id}/complete API Key Transition to done (string or structured result)
POST /api/v1/server/tasks/{id}/fail API Key Transition to failed (with error message)
POST /api/v1/server/tasks/{id}/help API Key Request intervention (intervention_type: help/question/approval)
POST /api/v1/server/tasks/{id}/assign API Key Assign task to session by name (supports require_plan)
POST /api/v1/server/tasks/{id}/dependencies API Key Add typed dependency (blocks/input/related)
DELETE /api/v1/server/tasks/{id}/dependencies/{dep_id} API Key Remove dependency
POST /api/v1/server/tasks/{id}/notes API Key Add note to task
GET /api/v1/server/tasks/{id}/notes API Key List notes for task
POST /api/v1/server/tasks/{id}/plan API Key Submit plan for review
GET /api/v1/server/servers API Key List all servers (name, status, repos, capabilities)
GET /api/v1/server/interventions API Key List interventions (filter by task_id, status)
POST /api/v1/server/interventions/{id}/respond API Key Respond to intervention programmatically

WebSocket Task Subscriptions

Server daemons can subscribe to real-time task events via the /ws/server WebSocket:

// Subscribe to task events
{"type": "subscribe_task", "task_id": "uuid-..."}
// → Response: {"type": "subscribed", "task_id": "uuid-..."}
 
// Unsubscribe
{"type": "unsubscribe_task", "task_id": "uuid-..."}
// → Response: {"type": "unsubscribed", "task_id": "uuid-..."}

After subscribing, the server receives all task_event messages for that task — status changes, notes added, interventions requested/responded, completions, and failures. This eliminates the need for REST polling in orchestrator agents.

Tunnel & Remote Access Endpoints

Method Path Auth Purpose
POST /api/v1/sessions/{id}/tunnel-token JWT Generate tunnel token (SSH or observe mode)
WS /ws/tunnel Tunnel JWT Bidirectional TCP relay (client ↔ hub ↔ agent)
POST /api/v1/server/remote/exec API Key Execute command on another session in same project

Tunnel Token Claims: type: "tunnel", session_id, server_id, project_id, user_id, mode (ssh/observe), target_port, hub_url, exp.

Tunnel Flow: Client connects to /ws/tunnel, sends {"type": "auth", "token": "<jwt>"}. Hub validates JWT, verifies session is active, then opens a relay. For SSH mode, hub sends tunnel_open to the agent daemon which opens a TCP connection to the target port. All TCP data is base64-encoded in tunnel_data messages. For observe mode, the client receives read-only session screen updates.

Remote Exec Flow: Agent sends POST /server/remote/exec with {session_name, command, timeout}. Hub resolves the target session in the same project, sends remote_exec to the target agent via WebSocket, and returns {exit_code, stdout, stderr} when complete.

Agent Registration & Capabilities

Method Path Auth Purpose
POST /api/v1/servers/register Token Register with capabilities
POST /api/v1/servers/heartbeat API Key Update capabilities and system info

7. Backwards Compatibility

All protocol features are opt-in. The table below shows what changes and what stays the same:

Feature Without Protocol With Protocol
Task creation spec text only spec + structured_spec
Task result Freeform JSONB (or string) $schema + contracts + tests + changes
Dependencies UUID list (dependency_ids), blocks only Typed: blocks / input / related + contract_key
Task ownership Optional assignee Every task owned by a person; sessions linked, tasks sent on request
Data flow None (agents work in isolation) Contract exchange via resolved_inputs

Existing tasks without structured_spec continue to work identically. No migration needed.

Version Checking

All structured schemas include a $schema field that identifies the protocol version:

  • orchestratia/task-spec/v1 — Task specification
  • orchestratia/task-result/v1 — Task result

The hub validates schemas by prefix. Unknown versions are accepted but logged as warnings.