fix(codex): preserve interleaved text and tool call block ordering on export - #56
Open
Adityakk9031 wants to merge 1 commit into
Open
Adityakk9031 wants to merge 1 commit into
Adityakk9031 wants to merge 1 commit into
Conversation
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.