codexwright

Migrate a Claude Agent SDK workflow to codexwright

codexwright rebuilds the workflow on the Codex SDK. The Codex SDK is the only target runtime: the migrated workflow does not keep the Claude Agent SDK query loop or a second agent runtime running beside it.

When to migrate

Migrate a Claude Agent SDK workflow when:

Do not migrate yet when the workflow depends on tool permissions, hooks, or session behavior you have not captured, or when you cannot run representative prompts to compare results.

What the migration preserves

The migration keeps the external behavior contract:

The Claude Agent SDK query loop, options, and dependency are retired only after the new workflow passes its checks. Captured inputs, outputs, errors, permissions, side effects, and recovery criteria belong in the migration evidence.

The migration envelope

Register the selected project, then invoke migrate. invoke prepares a proposal; it does not modify the target.

codexwright_preflight({})
codexwright_register({"path": "/absolute/path/to/project"})

codexwright_invoke({"envelope": {
  "workspace_id": "ws_RETURNED_ID",
  "goal": "Migrate the incident summarizer to a Codex SDK workflow. Preserve the severity vocabulary, first-sentence summary rule, next-action mapping, and empty-input default.",
  "operation": "migrate",
  "idempotency_key": "claude-incident-migrate-v1",
  "inputs": [
    {"kind": "file", "path": "agent.py", "source": "user"},
    {"kind": "file", "path": "tests/test_agent.py", "source": "user"}
  ]
}})

Read every page of the returned proposal with codexwright_read, then call codexwright_apply only after the user approves the exact diff.

Golden case

The example lives at examples/migrations/claude-agent-sdk and contains:

Run it:

python -m pytest tests/test_migration_examples.py -q -k claude_agent_sdk

The test loads both files by path and asserts that every case matches the expected output. It is an adapter-agreement check, not a real Claude Agent SDK run.

Limits