Skip to content

Fix Claude Code and Codex trace import parsing#4

Merged
x0ba merged 3 commits into
stagingfrom
fix/trace-import-parsers
Jun 9, 2026
Merged

Fix Claude Code and Codex trace import parsing#4
x0ba merged 3 commits into
stagingfrom
fix/trace-import-parsers

Conversation

@x0ba

@x0ba x0ba commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Treat Claude/Anthropic thinking and related content block types as known blocks, and extract thinking text when present
  • Parse Codex rollout event_msg user_message and agent_message entries so the visible conversation imports completely
  • Correct Codex function_call_output handling before generic function call matching and preserve call IDs
  • Add importer regression tests for Claude Code thinking/tool blocks and Codex rollout event/function output shapes

Sources checked

Verification

  • vp check --fix (passes with existing shaderElement warning)
  • vp test

@vercel

vercel Bot commented Jun 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
peek Ready Ready Preview, Comment Jun 8, 2026 9:16pm

@x0ba
x0ba marked this pull request as ready for review June 8, 2026 06:27
@greptile-apps

greptile-apps Bot commented Jun 8, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes two importer parsers — Claude Code and Codex — to correctly handle content types that were previously unknown or misclassified. It also adds a regression test suite covering the new paths.

  • Claude Code: adds a extractClaudeContent wrapper that extracts thinking block text before delegating to the shared utility; extends the allowlist and tool-event loop to cover thinking, redacted_thinking, server_tool_use, and web_search_tool_result; sharpens inputSummary/outputSummary assignment and adds toolUseId to metadata.
  • Codex: introduces a pre-scan (hasEventMessages) to prefer event_msg user/agent messages over response_item/message duplicates; adds an agent_message branch; moves function_call_output matching ahead of function_call to fix mis-classification; preserves call_id on all tool events; adds rawInputRedacted to function-call events.

Confidence Score: 5/5

Safe to merge — all changed parsing paths are exercised by the new regression tests and produce the expected outputs.

The changes are narrowly scoped to two importers: adding thinking-block extraction in Claude Code and fixing event-message deduplication plus function_call_output ordering in Codex. The new test file covers each modified path (thinking blocks, server_tool_use, web_search_tool_result, event_msg user/agent messages, function_call_output, and the legacy response_item fallback). No existing behaviour is removed; the only control-flow change (function_call_output checked before function_call) is a clear correctness fix, not a regression risk.

No files require special attention.

Important Files Changed

Filename Overview
src/lib/importers/claude-code.ts Adds thinking-block extraction and server_tool_use / web_search_tool_result tool-event support; logic is correct and well-covered by the new test.
src/lib/importers/codex.ts Adds event_msg deduplication logic and fixes function_call_output ordering; all changed paths are exercised by the new tests.
src/lib/importers/importers.test.ts New regression tests cover Claude Code thinking/tool blocks and Codex rollout event/function-output shapes; assertions are precise and match expected parsing outputs.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[JSONL row] --> B{item.type?}

    B -->|event_msg| C{payload.type?}
    C -->|user_message| D[codexUserMessageContent\n→ push user message]
    C -->|agent_message| E[extractTextContent\n→ push assistant message]

    B -->|response_item| F{payload.type?}
    F -->|message| G{hasEventMessages\n&& isConversation?}
    G -->|No → include| H[push message\nwith role]
    G -->|Yes → skip| I[deduplicated]

    B -->|assistant/user| J[extractClaudeContent\non content array]
    J --> K{block.type?}
    K -->|thinking| L[return block.thinking]
    K -->|text / tool_use\nredacted_thinking| M[extractTextContent]
    K -->|server_tool_use\nweb_search_tool_result\ntool_result| N[push ToolEvent\ninputSummary or outputSummary\n+ toolUseId]

    A --> O{candidateType regex?}
    O -->|function.*output\ntool.*output| P[ToolEvent\noutputSummary + call_id]
    O -->|function_call\ntool_call\nshell\ncommand| Q[ToolEvent\ninputSummary + call_id\n+ rawInputRedacted]
Loading

Reviews (3): Last reviewed commit: "address greptile review feedback (greplo..." | Re-trigger Greptile

Comment thread src/lib/importers/codex.ts Outdated
Comment thread src/lib/importers/utils.ts Outdated
Comment thread src/lib/importers/claude-code.ts
@x0ba
x0ba changed the base branch from main to staging June 9, 2026 19:22
@x0ba
x0ba merged commit f9261ab into staging Jun 9, 2026
6 checks passed
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