Skip to content

feat: add AgentAdapter abstraction with Codex CLI support#95

Open
ayeo wants to merge 5 commits intomainfrom
feat/agent-adapter-codex
Open

feat: add AgentAdapter abstraction with Codex CLI support#95
ayeo wants to merge 5 commits intomainfrom
feat/agent-adapter-codex

Conversation

@ayeo
Copy link
Copy Markdown

@ayeo ayeo commented Apr 3, 2026

Description

Replace hardcoded Claude Code transcript parsing with an extensible AgentAdapter trait and registry. Each AI coding agent gets its own adapter for event mapping, file change extraction, and transcript record parsing. Adds full Codex CLI support.

What's included

  • AgentAdapter trait with ClaudeCode, Codex, and Default adapters in tracevault-core
  • Codex transcript parsing — handles response_item/message, custom_tool_call, event_msg, apply_patch file changes from transcript chunks
  • CLI changes — protocol v2, --agent flag for stream command, Codex-compatible hook response format
  • tracevault init --agent codex — installs Codex hooks in .codex/hooks.json
  • AgentBadge component — shows agent type with icon on session list and detail views
  • Cleanup — removed old hardcoded extract_file_change/is_file_modifying_tool from streaming.rs
  • 34 adapter tests, UTF-8 safe truncation, code review fixes

How it works

The server resolves the adapter from sessions.tool column (set by CLI via --agent flag). During ingestion (stream.rs), the adapter extracts tokens and file changes. During display (session_detail.rs, traces_ui.rs), it parses transcript chunks into TranscriptRecords for the frontend.

Codex file modifications come exclusively through transcript chunks (custom_tool_call with apply_patch), not through hook ToolUse events — the adapter handles this via extract_file_changes_from_transcript.

Checklist

  • Tests added or updated
  • cargo fmt passes
  • cargo clippy passes

🤖 Generated with Claude Code

Michał Grabowski and others added 5 commits April 3, 2026 20:49
Replace hardcoded Claude Code transcript parsing with an extensible
AgentAdapter trait and registry. Each agent gets its own adapter for
event mapping, file change extraction, and transcript record parsing.

- AgentAdapter trait with ClaudeCode, Codex, and Default adapters
- Codex transcript parsing (response_item/message, custom_tool_call,
  event_msg, apply_patch file changes from transcript chunks)
- CLI: protocol v2, --agent flag, Codex hook response format
- tracevault init --codex installs .codex/hooks.json
- AgentBadge component with per-agent icon on session list and detail
- Remove old hardcoded extract_file_change/is_file_modifying_tool
- 34 adapter tests, UTF-8 safe truncation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allow multiple agents via --agent flag (e.g. --agent codex --agent gemini)
instead of single --codex bool. Extensible for future agents.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codex sends model in turn_context chunks which may arrive in a
separate batch from token_count chunks. Previously model was only
saved when the batch contained tokens.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant