Skip to content

[Feature] Agent-Orchestrator Protocol: extract 3-layer protocol as universal standard #9810

Open

Description

@leiyikang-tech

Summary

Orca already implements a de-facto 3-layer protocol for agent-orchestrator communication. This issue proposes extracting and documenting it as a universal standard that any orchestrator or agent can adopt.

Current State

Orca has 3 protocol layers already working across 30+ agent integrations:

  • Layer 1 (Transport): HTTP POST to 127.0.0.1:{port} with token auth, stdin bridge, endpoint file
  • Layer 2 (Status): Normalized AgentStatusPayload with 4 states (working/blocked/waiting/done), 9 event types, tool tracking
  • Layer 3 (Orchestration): Task DAG, CLI message protocol (8 message types), Coordinator polling, group addressing

Proposal

Layer 1: Transport Protocol

Standardize the HTTP POST + Token + Stdin Bridge pattern:

Element Orca Current Proposed Standard
Transport HTTP POST to 127.0.0.1:{port} ✅ Adopt directly
Auth X-Orca-Agent-Hook-Token (UUID) → X-Agent-Orchestrator-Token
Response Always 204 No Content (fail-open) ✅ Critical design — hooks must not block agents
Routing /hook/{agentType} → /agent-event/{agentType}
Stdin Bridge Agent → stdin → Script → HTTP POST ✅ Core pattern — any CLI agent works without modification
Endpoint File endpoint.env (restart recovery) ✅ Optional extension
Env Vars ORCA_AGENT_HOOK_PORT/TOKEN/PANE_KEY/... → AO_PORT/AO_TOKEN/AO_PANE_KEY/... (unified prefix)
Protocol Version ORCA_HOOK_PROTOCOL_VERSION = 1 → AO_PROTOCOL_VERSION

Layer 2: Status Protocol

Standardize the normalized status schema and state machine:

type AgentStatusPayload = {
  state: "working" | "blocked" | "waiting" | "done"  // Required
  prompt: string           // Required (empty string = unknown)
  agentType?: string       // Agent type identifier
  toolName?: string        // Current tool name
  toolInput?: string       // Tool input preview
  interactivePrompt?: string  // Full interactive question JSON
  lastAssistantMessage?: string  // Latest assistant message
  interrupted?: boolean    // Was done triggered by interruption
  subagents?: SubagentSnapshot[]  // Sub-agent snapshots
}

4-state semantics (the core of the standard):

State Semantics Orchestrator Behavior
working Agent executing task Kanban → Working lane, heartbeat timer reset
blocked Agent awaiting approval Kanban → Attention lane, approval UI popup
waiting Agent awaiting user input Kanban → Attention lane, prompt user
done Agent completed current turn Kanban → Idle lane, re-dispatchable

9 universal event types (extracted from 17 agents):

Event Semantics State Mapping
prompt_submit User submitted prompt → working
tool_start Tool call started → working
tool_end Tool call ended → working
tool_fail Tool call failed → working
permission_request Permission requested → blocked
session_stop Session ended → done
session_fail Session ended abnormally → done
subagent_start Sub-agent started (sub-roster update)
subagent_stop Sub-agent stopped (sub-roster update)

Layer 3: Orchestration Protocol

Standardize the task DAG + message protocol:

  • Task model: id, spec, status, deps, parent_id
  • State machine: pending → ready → dispatched → completed/failed/blocked
  • 8 message types: status, dispatch, worker_done, merge_ready, escalation, handoff, decision_gate, heartbeat
  • Group addressing: @all, @idle, @worktree:id, @agentType
  • Circuit breaker: 3 failures → circuit_broken
  • Heartbeat: 5min interval, 10min stale threshold

Standardization blockers (need abstraction):

  1. Preamble is Orca-specific — teaches orca orchestration send/check/ask commands. Standard needs abstract orchestrator CLI interface.
  2. Agent identity is Orca-specific — ORCA_PANE_KEY. Standard needs abstract agent identity.
  3. Decompose not implemented — AI-driven task decomposition is future work.

Deliverables

  • Protocol spec document (Markdown) covering all 3 layers
  • Reference implementation: standalone hook server that any orchestrator can embed
  • Agent SDK: minimal library for agents to emit status events
  • Migration guide: how to adapt existing Orca hooks to the standard
  • Test suite: validate protocol compliance

Related Code

  • src/main/agent-hooks/server.ts — Hook server implementation
  • src/shared/agent-hook-types.ts — Hook event types
  • src/shared/agent-status-types.ts — Status state machine
  • src/main/agent-hooks/hook-stdin-contract.ts — Stdin bridge protocol
  • src/main/runtime/orchestration/ — Orchestration protocol
  • src/main/runtime/orchestration/db.ts — Task DAG schema
  • src/main/runtime/orchestration/preamble.ts — Dispatch preamble
  • src/main/runtime/orchestration/groups.ts — Group addressing

Priority

High — This is foundational work that enables ecosystem growth. Any agent that adopts the standard works with any orchestrator that implements it.

Activity

  1. added
    enhancement
    on Jul 27, 2026
  2. str0203 commented on Aug 10, 2026

    @str0203

    Firstmate is a concrete downstream consumer for this protocol work. Its current Orca backend still reconstructs supervision from raw worktree/terminal operations, while the tmux reference path relies on years of stable process/session semantics. A small, versioned Orca contract would let Firstmate adopt native orchestration incrementally.

    Related downstream planning:

    To make this adoptable without waiting for the full universal-standard effort, I suggest defining a minimal v1 consumer contract first:

    1. Capability handshake

      • protocol/schema version
      • supported commands and optional features
      • explicit degraded/fallback states
    2. Stable identity

      • durable worker/dispatch/session ID
      • transient terminal connection handles kept separate
      • a supported way to resolve current routing after restart
    3. Cursor-based event stream

      • ordered sequence
      • replay after reconnect/restart
      • consumer deduplication key
      • at minimum: started, working, blocked/waiting, completed, failed, interrupted, endpoint_exited
    4. Delivery receipt semantics

      • distinguish PTY written from prompt submitted, agent accepted, and first turn working
      • unconfirmed delivery must remain safely retryable with an idempotency key
    5. Lifecycle safety

      • stop, abandon/unknown, retain, and release as distinct operations
      • release idempotent and bound to proven ownership
      • destructive actions use durable identity, not a cached terminal handle

    A small conformance fixture would make this especially useful: create a worker, consume ordered events, restart/reconnect, re-resolve identity, deliver one idempotent follow-up, and release exactly once.

    That narrower v1 would already unlock a high-quality Firstmate adapter and provide real downstream feedback for the broader universal protocol, while the naming/SDK/generalization work can continue independently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions