OpenSwarm
OpenSwarm copied to clipboard
Codex CLI adapter: streaming, cost tracking, and test coverage
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 codexDiscord 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
--jsonoutput events - [ ] Map Codex model pricing (o3, o4-mini) in
costTracker.ts - [ ] Verify cost aggregation in pipeline results
2. Streaming Improvements
- [ ] Handle
item.streamingevents for real-time dashboard updates - [ ] Parse
tool_callevents for live progress tracking - [ ] Improve reasoning summary extraction from
item.completedevents
3. Git Integration
- [ ] Codex
--full-automanages 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 adaptersrc/adapters/base.ts— Shared spawn logicsrc/adapters/types.ts— Adapter interfacesrc/adapters/codex.test.ts— Tests