Repository navigation
fix(codex): keep code-mode exec results and wrap freeform inputs for opencode - #109
Merged
Merged
Conversation
…opencode
Codex code mode writes custom_tool_call_output.output as an array of
input_text content items; the reader only accepted strings, so the result
was dropped for every target. Collapse all-text item lists to text (keep
other lists as JSON) for both custom_tool_call_output and
function_call_output.
The OpenCode writer passed a non-object tool input (the raw JS of an exec
call) into state.input, which opencode import rejects. Wrap it as
{"input": ...}, matching the Claude Code export.
Fixes #104
…from opencode Follow-ups to #104. Codex never writes a call's `success` flag to the rollout; a content-item list serializes as the bare array. For code mode the only on-disk failure signal is the status header Codex inserts as the first item ("Script failed\nWall time ... seconds\nOutput:\n"). Array results in custom_tool_call_output and function_call_output now set is_error from that header (matched whole, so script output that merely starts with the words is not mistaken for it); lists without it stay non-errors. The OpenCode writer wraps a non-object tool input as {"input": <value>} because `opencode import` requires an object. It now flags that wrap in state.metadata (txcriptWrappedInput: true), and the reader unwraps only flagged parts whose input is still exactly that one-key object, so Codex -> OpenCode -> common restores the original freeform input while a genuine {"input": ...} tool input is left untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #104
Problem
custom_tool_call_output.outputas an array ofinput_textcontent items. The reader only accepted strings, so every code-mode exec result was lost on export and on conversion to every target.state.input, whichopencode importrejects.Fix
custom_tool_call_outputandfunction_call_outputthat are all text collapse to text; other lists are kept as JSON.successflag, so the only on-disk signal is the status header it inserts as the first item (Script failed\nWall time … seconds\nOutput:\n); it is matched whole, so output that merely starts with those words isn't misread.{"input": <value>}(matching the Claude Code export) and marks the wrap instate.metadata(txcriptWrappedInput: true). The reader unwraps only flagged parts that are still exactly that one-key object, so Codex → OpenCode → back restores the original input, while a genuine{"input": …}tool input is left alone.Tests
tests/regression/codex_code_mode.rscovers results, failure flagging, and the OpenCode wrap/unwrap round trip; it fails on main and passes here.cargo fmt --check,cargo clippy --workspace --all-targets --all-features -D warnings, andcargo test --workspace --all-featurespass.Try it
Run a Codex session that uses code mode, then
txcript export <id> --from codexortxcript continue <id> --from codex --with opencode; the exec results are present and the import succeeds.