fix(capture-prior): extract tool calls via adapter protocol method#455
fix(capture-prior): extract tool calls via adapter protocol method#455rsnodgrass merged 3 commits intomainfrom
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (14)
📝 WalkthroughWalkthroughThis PR introduces a new "capture-prior" adapter capability that enables session history retrieval. It defines the protocol types, extends the adapter runtime with capture-prior dispatch, implements the handler in the Claude adapter with enhanced session parsing for tool correlation, adds session history conversion utilities, and updates the CLI to delegate capture operations to adapters with stdin/file fallback. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI<br/>(capture-prior)
participant AdapterMgr as Adapter<br/>Discovery
participant Adapter as External<br/>Adapter
participant SessionMgr as Session<br/>Manager
participant History as History<br/>Converter
CLI->>CLI: Parse --session-id, detect project root
CLI->>AdapterMgr: Find adapter with capture-prior capability
AdapterMgr-->>CLI: Return selected adapter
CLI->>Adapter: Call CapturePrior(session_id, repo_root, agent_id, ...)
Adapter->>Adapter: Construct CLI args and invoke<br/>adapter capture-prior subcommand
Adapter-->>CLI: Return CapturePriorResult<br/>(entries, metadata, agent_type)
CLI->>History: ConvertProtocolEntriesToHistory(entries, agent_id, agent_type)
History-->>CLI: Return CapturedHistory<br/>(with metadata, time range)
CLI->>SessionMgr: CapturePriorFromHistory(history, opts)
SessionMgr->>SessionMgr: Validate, redact secrets,<br/>compute metadata
SessionMgr->>SessionMgr: StoreCapturedHistory(...)
SessionMgr-->>CLI: Return CaptureResult<br/>(path, entry count, agent_id)
CLI-->>CLI: Output result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Co-Authored-By: SageOx <ox@sageox.ai> SageOx-Session: https://sageox.ai/repo/repo_019c5812-01e9-7b7d-b5b1-321c471c9777/sessions/2026-04-07T19-54-ryan-OxiU0Y/view
1079795 to
6437127
Compare
Co-Authored-By: SageOx <ox@sageox.ai> SageOx-Session: https://sageox.ai/repo/repo_019c5812-01e9-7b7d-b5b1-321c471c9777/sessions/2026-04-07T19-54-ryan-OxiU0Y/view
Co-Authored-By: SageOx <ox@sageox.ai> SageOx-Session: https://sageox.ai/repo/repo_019c5812-01e9-7b7d-b5b1-321c471c9777/sessions/2026-04-08T01-38-ryan-Ox06mo/view
Summary
capture-priorsilently dropped tool calls (Read, Edit, Write, Bash) and their results from Claude Code sessions — only high-level user/assistant text was capturedcapture-prioras a first-class adapter protocol method so each adapter (Claude Code, Codex, Gemini, etc.) owns its own session parsing logictool_useblocks (with call IDs) from assistant messages andtool_resultblocks from user messages--from-claudeflag needed; falls back to JSONL stdin/file when no adapter is availableChanges
graph LR CLI["ox capture-prior"] -->|DetectAdapter| A["Active Adapter"] A -->|capture-prior protocol| CP["handleCapturePrior"] CP --> Parse["Parse native JSONL"] Parse --> Entries["[]RawEntry with tools"] Entries -->|ConvertProtocolEntriesToHistory| H["CapturedHistory"] H --> Redact["Secret redaction"] Redact --> Store["Ledger storage"] CLI -->|stdin/--file fallback| V["ValidateCapturePriorInput"] V --> RedactProtocol layer (
pkg/adapterprotocol,pkg/adapterruntime):CapturePriorParams/CapturePriorResulttypes andCapCapturePriorcapabilitycapture-priorsubcommand dispatch in adapter runtimeClaude Code adapter (
cmd/ox-adapter-claude-code):handleCapturePrior— finds and parses the native session fileextractToolResults— extractstool_resultcontent blocks from user messagestool_useblocks now preservecallIDfor call/result correlationSession internals (
internal/session):ConvertProtocolEntriesToHistory— bridges[]RawEntry→CapturedHistoryCapturePriorFromHistory— stores pre-parsed history (skips JSONL validation)Test plan
--session-id,--filemake lint— 0 issuesmake test— 12321 tests passCo-Authored-By: SageOx
Summary by CodeRabbit
New Features
Enhancements
Tests