Skip to content

AHP host: synchronized multi-client view of managed sessions #119

Open

Description

@androidand
Proposal

Parent: Phase 7 (AHP and Mission Control). Proves charter Scenario G.

Why

The charter (§12) requires a standardized, synchronized, multi-client interface to managed
agent sessions. Today a session is only visible from the client that created it (a TUI or
CLI). AHP (microsoft/agent-host-protocol) is the standard for exactly this: "one host sits
between many clients and many agents," with immutable state, pure reducers, and
write-ahead reconciliation. This is a P2 capability — it adds a presentation and
synchronization layer on top of the execution plane; it is not the workflow database
(charter §4.4).

Research (R2, answered): AHP is JSON-RPC 2.0 over any reliable ordered transport. Channels
are URI routing keys (ahp-root://, ahp-session:/<uuid>, ahp-chat:/<cid>,
ahp-automations://, ahp-automation-run:/<id>, ahp-terminal, ahp-otlp:,
ahp-mcp). Every action is stamped with a monotonic serverSeq and broadcast to all
subscribers; clients apply optimistically and reconcile against the server echo. Official
client libraries exist in TypeScript (@microsoft/agent-host-protocol), Rust, Go, Kotlin,
Swift, and .NET. Conforming hosts already exist: the VS Code agent host (reference),
pi-ahp, ahpd (@ahpd/sdk), hydra-ahp, and ahp-acp-gateway (a universal AHP
WebSocket host that runs ACP agents with persistent sessions, replay + reconnect,
permissions, and cancellation).

What Changes

  1. Add an independent AHP host (a small service) that projects one or more managed
    opencode-skein sessions onto AHP channels. It reuses ACP as the runtime interface where
    practical (charter §12.2) and does not modify OpenCode's internal chat implementation.
  2. Read-only first (charter §12.5): expose one managed session and connect two
    independent AHP clients. Both see the same conversation and tool activity.
  3. Implement AHP reconciliation: ordered serverSeq actions, a snapshot on subscribe, and
    reconnect without duplicated or missing visible actions (charter §12.4, §12.6).
  4. Then add interactive commands (prompt, cancel) and permission state, and finally
    multi-session discovery to feed the dashboard.

Build approach (needs-research R8)

Three candidate approaches, decided in design.md before implementation:

  • A. Reuse ahp-acp-gateway — a universal AHP WebSocket host that runs ACP agents
    with persistent sessions, replay + reconnect, permissions, and cancellation. Fastest
    path; least control over Skein-specific projections.
  • B. Build on @ahpd/sdk — a plugin host where the agent, ports, and server tools are
    installed. More control; more work.
  • C. Build a thin host on the @microsoft/agent-host-protocol TS client lib directly,
    projecting from the opencode-skein ACP agent. Most control; most work.

The decision depends on how much opencode-skein-specific state (work items, claims, gates)
must be projected — which AHP's standard channels may not express (charter §4.4 keeps
those in the control plane, exposed through AHP extensions "where suitable").

Non-goals

  • AHP is not the global workflow database (charter §4.4). Skein work graphs, approvals,
    fleet scheduling, dependencies, and policies stay in the control plane.
  • No experimental AHP channels beyond what the current specification defines.
  • No changes to the ACP agent or the execution plane for AHP's sake.

Risks

  1. Labeling a custom WebSocket as AHP. The charter (§12.3) forbids calling a custom
    event WebSocket "AHP-compatible" unless it conforms. Mitigation: use the official
    client lib or a conforming host; validate against the AHP JSON Schema.
  2. Competing mutable state. Mitigation: keep internal event sourcing separate from AHP
    projection state (charter §12.4); the AHP host is a read projection, not an authority.
  3. Scope creep into the control plane. Mitigation: read-only first; Skein-specific
    state via clearly defined extensions only.

Impact

A new small service (the AHP host), an ACP→AHP projection adapter, two test clients, and
evidence. No changes to the execution plane.

Tasks

Phase 0: Decide the build approach (R8)

  • 0.1 Evaluate ahp-acp-gateway vs @ahpd/sdk vs a thin host on the TS client lib.
    Criteria: how much Skein-specific state must be projected, maintenance burden, and
    conformance to the AHP spec.
  • 0.2 Write the decision into design.md as ADR Proposal: Context-aware, slot-aware local sub-agent placement #4 (charter §22).
  • 0.3 Pin the AHP protocol version and the client/host library versions.

Phase 1: Read-only single session (charter §12.5)

  • 1.1 Stand up the AHP host exposing one managed opencode-skein session.
  • 1.2 Project session state, chat turns, and tool events onto AHP channels
    (ahp-session:/, ahp-chat:/).
  • 1.3 Connect two independent AHP clients; both observe the same conversation and tool
    activity.
  • 1.4 A subscribe returns a snapshot; subsequent actions arrive ordered by
    serverSeq.

Phase 2: Reconciliation (charter §12.4, §12.6)

  • 2.1 Disconnect one client; execution continues; on reconnect the client receives a
    correct state with no duplicated or missing visible actions.
  • 2.2 Handle missed notifications, duplicate observations, and out-of-order arrivals at
    the adapter boundary.
  • 2.3 Handle session termination and protocol version mismatch.

Phase 3: Interactive (after read-only is proven)

  • 3.1 Add interactive commands (prompt, cancel) through AHP.
  • 3.2 Add permission state where supported.
  • 3.3 Add multi-session discovery for the dashboard (feeds mission-control).

Phase 4: Evidence

  • 4.1 Record the AHP protocol version, the chosen host approach, and the client/host
    library versions.
  • 4.2 Capture the two-client synchronized transcript and the reconnect reconciliation
    as evidence (Scenario G).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions