Skip to content

[#143]: fix(parser): handle external-agent import item types for Codex v0.140.0/v0.141.0 compat#151

Open
delexw wants to merge 1 commit into
mainfrom
fix-issue-143
Open

[#143]: fix(parser): handle external-agent import item types for Codex v0.140.0/v0.141.0 compat#151
delexw wants to merge 1 commit into
mainfrom
fix-issue-143

Conversation

@delexw

@delexw delexw commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds compatibility handling for Codex v0.140.0/v0.141.0 external-agent import item types introduced by the /import command.

Background

Codex v0.140.0 (PRs #27070, #27071, #27703) added the /import command, which imports setup, project config, and recent chats from external agents (e.g. Claude Code). When used, the import flow writes new event_msg lifecycle entries into session transcripts — including entries that appear before the first task_started event. Codex v0.141.0 (PR #28008) added external_agent_import_result, a new accounting-type response_item that records token/cost totals for imported agent context.

Changes

src-tauri/src/parser/turn.rs

  • Added explicit named handlers in handle_event_msg for /import lifecycle event_msg types (agent_context_import_started, agent_context_imported, external_agent_import_started, external_agent_imported). These are treated as pass-through no-ops with version/PR documentation.
  • Added explicit named handler in handle_response_item for external_agent_import_result (v0.141.0 accounting type). Treated as pass-through.
  • Added 3 tests:
    • v0140_import_event_before_first_turn_does_not_corrupt_turns — import events before task_started must not create spurious synthetic turns
    • v0141_external_agent_import_result_inside_turn_does_not_corrupt_turn — accounting item inside a turn must not break tool calls or agent messages
    • v0140_all_standard_entry_types_plus_import_items_build_correct_turns — full turn integrity regression guard for v0.140.0 sessions with import items

src-tauri/src/parser/entry.rs

  • Added 3 tests:
    • v0140_agent_context_import_event_msg_parses_correctly — import lifecycle event_msg parses without panicking
    • v0141_external_agent_import_result_response_item_parses_correctly — accounting response_item parses correctly
    • v0140_all_standard_entry_types_plus_import_items_parse_correctly — full v0.140.0 session regression guard

Why no structural parser changes?

The RawEntry parser already uses a loosely-typed serde_json::Value model, so new entry types flow through without hard errors. The existing _ => {} catch-alls in handle_event_msg and handle_response_item already silently ignored these types. This PR adds explicit named arms for the known import types to document the intended behaviour for future readers, plus tests to lock in that sessions with imported context parse cleanly.

Verification

All 267 Rust tests pass (cargo test --manifest-path src-tauri/Cargo.toml), all 135 frontend tests pass (npx vitest run), cargo clippy -- -D warnings is clean, and oxlint/oxfmt report no issues.

Fixes #143

…x v0.140.0/v0.141.0 compat

Codex v0.140.0 (PRs #27070, #27071, #27703) added the /import command,
which writes new event_msg lifecycle entries (agent_context_imported,
external_agent_imported, etc.) into session transcripts before the first
task_started. Codex v0.141.0 (PR #28008) added external_agent_import_result,
an accounting-type response_item for imported agent context.

Add explicit named handlers in handle_event_msg for the import lifecycle
event_msg types and in handle_response_item for external_agent_import_result.
Both are treated as pass-through no-ops — the loosely-typed serde_json::Value
model already prevents hard errors, and the catch-all _ => {} handles any
additional undocumented variants. The explicit arms document the known types
for future readers.

Add 6 tests:
- entry.rs: v0.140.0 import event_msg and v0.141.0 external_agent_import_result
  response_item parse correctly without panicking; full v0.140.0 session guard.
- turn.rs: import events before first task_started do not create spurious
  synthetic turns; external_agent_import_result inside a turn does not corrupt
  tool calls or agent messages; full turn integrity regression guard.

Fixes #143
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.

[Compat] Codex v0.140.0: /import command adds new external-agent session item types

1 participant