OpenSwarm icon indicating copy to clipboard operation
OpenSwarm copied to clipboard

Codex CLI adapter: streaming, cost tracking, and test coverage

Open unohee opened this issue 8 months ago • 0 comments

Context

OpenSwarm v0.2.0 ships with a pluggable CLI adapter system supporting both Claude Code (claude -p) and OpenAI Codex (codex exec). The Codex adapter is functional but needs hardening.

Current State

  • src/adapters/codex.ts — Codex CLI adapter (stream-json parsing, worker/reviewer output extraction)
  • src/adapters/codex.test.ts — Basic unit tests
  • Runtime provider switching via !provider codex Discord command
  • Per-role adapter overrides in config (e.g., Codex for workers, Claude for reviewers)

Remaining Work

1. Cost Tracking

  • [ ] Extract token usage from Codex --json output events
  • [ ] Map Codex model pricing (o3, o4-mini) in costTracker.ts
  • [ ] Verify cost aggregation in pipeline results

2. Streaming Improvements

  • [ ] Handle item.streaming events for real-time dashboard updates
  • [ ] Parse tool_call events for live progress tracking
  • [ ] Improve reasoning summary extraction from item.completed events

3. Git Integration

  • [ ] Codex --full-auto manages its own git — detect and skip OpenSwarm's git snapshot/diff tracking
  • [ ] Handle worktree mode interactions with Codex's auto-commit behavior
  • [ ] PR creation flow when Codex has already committed changes

4. Test Coverage

  • [ ] Integration test: full pipeline run with Codex adapter (mock)
  • [ ] Edge cases: empty output, malformed JSON events, timeout handling
  • [ ] Provider switching mid-session behavior

5. Documentation

  • [x] README updated with Codex adapter docs (v0.2.0)
  • [ ] config.example.yaml: add Codex adapter examples

Related Files

  • src/adapters/codex.ts — Codex CLI adapter
  • src/adapters/base.ts — Shared spawn logic
  • src/adapters/types.ts — Adapter interface
  • src/adapters/codex.test.ts — Tests

unohee avatar Mar 20 '26 13:03 unohee