Skip to content

Epic: Migrate ADF Claude agents to Agent SDK #689

@AlexMikhalev

Description

@AlexMikhalev

Context

ADF spawns Claude agents as claude -p subprocesses with stdout/stderr capture. This causes SIGPIPE bugs, fragile output parsing, cold-start waste, and no native cost tracking. The Claude Agent SDK (renamed from Claude Code SDK) provides query() async iterator with typed hooks, native session resume/fork, and in-process cost tracking.

Proposal

Replace subprocess spawning for Claude-based agents with Agent SDK query() calls. Codex agents remain as subprocesses (no SDK equivalent).

Migration Strategy

  1. Create thin Python wrapper per agent that calls Agent SDK query() and forwards typed JSONL events to stdout using the RPC envelope (Implement JSONL RPC envelope for agent-orchestrator communication #688)
  2. Migrate one agent at a time: product-development first (lowest risk), then security-sentinel
  3. Preserve orchestrator reconciliation loop, Safety/Core/Growth layers, NightwatchMonitor

What This Eliminates

  • SIGPIPE bug (async iterator, no pipes)
  • Stdout/stderr parsing fragility (typed message stream)
  • Cold-start waste (native resume=session_id)
  • Cost tracking complexity (hooks on every API call vs output parsing)
  • Session management complexity (ClaudeSDKClient handles state)

Open Question: Bridge Architecture

  • Option A: Rust orchestrator -> thin Python wrapper (subprocess) -> Agent SDK
  • Option B: Rust orchestrator -> local HTTP server running Agent SDK -> typed responses
  • Option C: Implement Agent SDK protocol directly in Rust (high effort, fragile)
  • Spike needed to determine which approach best preserves Rust orchestrator while gaining SDK benefits

Sub-issues (to be created during design phase)

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions