Skip to content

[Relay] Add a multi-turn Claude session adapter #381

Description

@ranveersequeira

Parent

#377

What to build

Add a provider-neutral session adapter for Claude Code so a broker task can receive streamed public events, explicit follow-up messages, cancellation, and reconnect/resume only where the installed Claude capability genuinely supports it.

Prefer the existing Claude ACP adapter for supervised sessions. Treat Claude agent teams and cross-session messaging as optional provider-native capabilities, not as Agentify's durable source of truth. Preserve a declared one-shot/headless fallback for installations without a compatible session transport.

User story

As a human or parent agent, I can start a Claude worker, observe its public progress, send a bounded follow-up, and cancel it through the same Agentify task contract used for Codex.

Provider-neutral adapter contract

Implement the same adapter/session/turn contract and capability vocabulary established by #380. Provider-specific details must remain behind the adapter.

The capability manifest must distinguish native, emulated, and unavailable for:

  • multi-turn, resume, fork/list/close;
  • stream granularity and subagent/tool events;
  • permission requests and client terminal/filesystem calls;
  • MCP server injection;
  • cooperative cancellation and hard process termination;
  • token/cost telemetry;
  • native budget/turn enforcement versus broker timeout or pre-run checks;
  • optional native cross-session messaging.

Required behavior

  • Agentify task/message/event state remains authoritative across provider restarts.
  • Claude session IDs, messaging sockets/tokens, team names, and process details remain adapter-private.
  • Prefer structured stream output or ACP frames; keep stderr diagnostic-only.
  • Translate Claude permission requests through immutable Agentify policy and fail closed when no authorized controller is available.
  • Respect native max-budget/max-turn controls where supported while recording enforcement provenance.
  • Treat provider-native mailboxes as a transport optimization only; durable Agentify messages must not disappear when a Claude session exits.
  • Cross-session messages are explicit bounded text/content only, never hidden conversation state.
  • One-shot headless fallback must reject follow-up and advertise its capability downgrade.
  • Probe installed Claude version/capabilities and return actionable setup guidance without automatic authentication.

Suggested implementation seams

  • Extend Claude declarations in src/core/provider-registry.js.
  • Reuse the provider-neutral adapter abstraction introduced by [Relay] Add a multi-turn Codex session adapter #380 rather than adding a parallel Claude-only session stack.
  • Reuse src/core/acp/downstream.js process ownership and src/core/acp/inject.js / capture.js safeguards.
  • Preserve current one-writer capture ownership so Claude hooks and relay capture cannot double-record activity.
  • Add golden fixtures for ACP initialization, session start, prompt/update, permission requests, follow-up, cancel, disconnect, and close.

Acceptance criteria

  • probe reports installed Claude transport/version and capability levels without starting paid work.
  • A fake Claude session supports start, streamed public events, explicit follow-up, completion, cancellation, and close through the common adapter contract.
  • Broker state remains usable after the controlling MCP/CLI client disconnects.
  • Permission requests never widen the task's immutable grant.
  • Native budget/turn controls are applied where supported and reported with provenance.
  • Native cross-session messaging is optional; the adapter remains functional without it.
  • Agentify persists explicit messages before attempting provider delivery.
  • One-shot fallback visibly reports no multi-turn support and rejects message.
  • Session resume is advertised only when probed and verified; message replay is not called native resume.
  • Authentication/socket tokens and raw environment data never appear in events or logs.
  • Existing Claude delegate, hooks, capture, ACP, and managed guidance behavior remains backward compatible.
  • Deterministic CI uses fake protocol fixtures; real Claude smoke tests are opt-in and budget-capped.

Out of scope

  • Making Claude native agent teams the Agentify scheduler.
  • Depending on provider mailbox JSON files as the durable store.
  • Nested delegation.
  • Write-capable workspace grants.
  • Transferring a Claude session into Codex.
  • Native Windows support for provider-specific Unix-socket messaging where Claude itself does not provide it.

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentify-readyReady for Agentify automationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions