Repository navigation
fix(codex): preserve interleaved text and tool call block ordering on export - #56
Merged
NishantJoshi00 merged 4 commits intoOct 23, 2026
Conversation
NishantJoshi00
approved these changes
Oct 23, 2026
NishantJoshi00
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed the Codex export ordering change against current main. Flushing pending message content before thinking, tool calls, and tool results preserves block order without changing other harnesses. The new ordering regression fails with the base serializer and passes with this fix.
Refreshed the branch against main and added the missing lineage: None to the test fixture. All 28 Codex integration tests pass. The full local pre-push gate also passes: formatting, both Clippy configurations, all workspace tests, and both WASM feature configurations on Rust 1.96.1. Required GitHub CI is running on this exact head.
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.
When converting transcripts from Common to Codex via
Codex::from_common,push_message_linesbuffered all text and artifact blocks across the entire message while pushingThinking,ToolUse, andToolResultitems immediately. At the end of the turn, the buffered text was flushed as a single response item.In assistant turns where text precedes a tool call (for example
[Block::Text("Checking directory..."), Block::ToolUse { ... }]), this inverted the order in the exported rollout JSONL: the tool call was emitted first, followed by the explanation text. In turns with text before and after a tool call, both text segments were lumped together after the tool call.This change flushes any accumulated text content before emitting
reasoning,function_call, orfunction_call_outputrecords, preserving the chronological sequence across interleaved turns.Testing
from_common_preserves_interleaved_block_orderingintests/integration/codex.rsverifying that text before and after a tool call maintains exact line ordering in the emitted rollout.codec_fixpoint_through_common_loses_nothingcontinues to pass.cargo test -p txcript --no-default-features --features opencode,hermes,search --test integration codexpassed.cargo clippy -p txcript --no-default-features --features opencode,hermes,search --all-targets -- -D warningsclean.