Skip to content

[0.12] Run Claude Code and Codex from agent manifests #277

Description

@adrian-lorenzo

Goal

Run Claude Code and Codex inside the persistent workspace using the engine and model from the selected .agents/ file.

Adapter boundary

Each adapter should be limited to starting or resuming a native session, sending a message, streaming output, cancelling a turn, and reporting completion or failure. Facility owns the shared conversation and does not replace the engine's agent loop.

The adapter input includes the workspace, agent prompt, conversation context, model, optional reasoning effort, and native session reference when one exists. The output includes streamed events, the final result, the updated session reference, and enough error detail to retry.

Session handling

Native session files live on durable workspace storage. Database records point to them and record which engine and model created them.

When a later turn uses a compatible session, resume it. If an agent selects another engine or an incompatible model, create another native session in the same workspace and seed it with the shared history and current summary. Keep the earlier session.

A corrupt or unreadable session should be marked unusable and retained for diagnosis. The next turn starts a replacement session without resetting the worktree.

Output and cancellation

Persist the user message before starting the engine. Stream bounded events to MCP and the UI. Save the terminal result and session reference before releasing the story lock.

Cancellation should stop the engine process and leave the workspace recoverable. A lost worker should be able to determine whether the process still runs and either reconnect or close the turn with an actionable error.

Acceptance criteria

  • Claude Code and Codex implement the same adapter contract.
  • The adapter passes the exact model and reasoning effort from the agent manifest.
  • A compatible native session resumes after compute suspension and replacement.
  • Switching agents preserves the worktree and every prior session.
  • Switching engines creates a new session without deleting the old one.
  • Corrupt session state produces a recoverable error and a replacement session.
  • User messages survive a worker crash before engine startup.
  • Output can be consumed incrementally by MCP and the UI.
  • Cancellation leaves Git and local service state untouched.
  • Logs do not contain provider credentials or GitHub tokens.
  • Deterministic fake executables test start, resume, model selection, streaming, cancellation, crash recovery, and corrupt sessions.

Out of scope

Do not normalize every vendor event into a large internal protocol. Store the events the product needs for conversation, progress, diagnosis, and recovery.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions