# Agent Adapter Contract

An adapter must expose the portable lifecycle without depending on a provider's private conversation object:

```text
receive user text
  -> begin-run
  -> append-user
  -> invoke provider Agent
  -> append-assistant
  -> finish-run
```

## Command-shaped agents

For an Agent that reads one prompt and writes one visible response, use `agent-continuity-run` with an explicit session ID and the provider command after `--`. The wrapper must persist the user text before starting the child, capture stdout, preserve partial output on interruption or non-zero exit, and close the run.

Provider presets such as `agent-continuity-codex`, `agent-continuity-claude`, `agent-continuity-opencode`, and `agent-continuity-pi` follow the same contract. They must not assume a permanent provider command line; the local installation supplies the command after `--`.

## SDK, desktop, and streaming agents

Implement the same lifecycle directly. Persist the request before the provider call, append the final or partial visible response, and checkpoint before handoff or context exhaustion. Provider-native conversation IDs may supplement portable messages but never replace them.
