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
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.
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
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.