Skip to content

[Phase 4] Agent Adapter Architecture: Delegate to Frontier Coding Agents #408

Description

@frankbria

Summary

Refactor CodeFrame's execution layer so that frontier coding agents (Claude Code, Codex, OpenCode, Kilocode, etc.) are first-class execution engines, with CodeFrame's built-in ReactAgent as a fallback. CodeFrame becomes the orchestrator (PRD → tasks → dependencies → verification → PR) while delegating the actual code writing to whatever tool does it best.

Problem Statement

CodeFrame currently implements its own ReAct agent with 7 custom tools, a 4-level fuzzy editor, 3-tier token compaction, and adaptive iteration budgets. This is fundamentally trying to compete with Claude Code, Codex, OpenCode, and Kilocode — tools backed by entire engineering teams dedicated to making the best coding agent.

CodeFrame's actual value is everything around the coding agent:

  • PRD generation and task decomposition
  • Dependency graph analysis and batch scheduling
  • Verification gates (ruff, pytest) with self-correction loops
  • Human-in-the-loop blocker resolution
  • State machine and lifecycle management
  • PR workflow and Git integration
  • Workspace hooks and configuration

None of this exists in Claude Code, Codex, or OpenCode. They write code for a single task. CodeFrame manages the full development lifecycle.

Architectural Vision

Current (CodeFrame IS the agent)

CLI → Runtime → ReactAgent → Anthropic API → custom tools → files
                    ↑
         CodeFrame owns ALL of this

Proposed (CodeFrame ORCHESTRATES agents)

CLI → Runtime → AgentAdapter → ┌─ claude-code (subprocess)
                    │          ├─ codex (app-server protocol)
                    │          ├─ opencode (subprocess)
                    │          ├─ kilocode (extension protocol)
                    │          ├─ custom (configurable)
                    │          └─ built-in (ReactAgent fallback)
                    │
         CodeFrame still owns:
         ✅ Task context assembly
         ✅ Verification gates + self-correction
         ✅ Stall detection & blocker escalation
         ✅ State machine & lifecycle
         ✅ Batch orchestration
         ✅ Workspace hooks
         ✅ PR workflow

Key Design Principle

The AgentAdapter protocol defines what CodeFrame needs from any coding agent:

  1. Input: Task description + context (files, PRD, constraints)
  2. Output: Modified files + status (success/failure/blocked)
  3. Streaming: Progress events for observability

CodeFrame doesn't care how the agent writes code. It cares what happened (files changed, tests pass, blockers hit).

Sub-Issues

Implementation is broken into atomic sub-issues:

#413 — Aider adapter (closed, replaced by #416 OpenCode and #417 Kilocode)

Dependency Graph

#409 (protocol) ──┬──> #411 (Claude Code adapter)
                  ├──> #412 (Codex adapter)
                  ├──> #416 (OpenCode adapter)
                  ├──> #417 (Kilocode adapter)
                  ├──> #414 (engine registry) ──> needs ≥1 adapter
                  └──> #415 (verification wrapper)
                  
#410 (context packager) ──> feeds into #411, #412, #416, #417

#409 and #410 are independent foundations.
#411, #412, #416, #417 are independent adapters (can be done in parallel).
#414 ties everything together.
#415 can be done in parallel with adapters.

What Stays the Same

  • core/react_agent.py — remains as the --engine built-in fallback
  • core/context.py — context loading (feeds into the new packager)
  • core/gates.py — verification gates
  • core/runtime.py — run lifecycle (extended with new engine types)
  • core/conductor.py — batch orchestration
  • All CLI commands — just the --engine flag gets new values

What This Means for the Roadmap

This should be early Phase 4 work because:

  1. It unblocks multi-agent by making agents interchangeable
  2. It dramatically reduces CodeFrame's maintenance burden
  3. It makes CodeFrame immediately useful today with Claude Code or OpenCode
  4. The built-in ReactAgent becomes the "no internet / no subscription" fallback

Acceptance Criteria

  • cf work start <id> --execute --engine claude-code delegates to Claude Code CLI
  • cf work start <id> --execute --engine opencode delegates to OpenCode
  • cf work start <id> --execute --engine built-in uses existing ReactAgent
  • All engines receive the same rich task context from CodeFrame
  • Verification gates run after ANY engine completes (not just built-in)
  • Self-correction loop works: gate failure → re-invoke engine with error context
  • Batch execution works with any engine
  • Engine is configurable per-workspace (CODEFRAME.md/AGENTS.md)

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureSystem architecture and design patternsenhancementNew feature or requestphase-4.1Phase 4.1: Agent Adapter Foundation (protocol, registry, verification wrapper)symphony-inspiredInspired by OpenAI Symphony spec analysis

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions