Fix shell tool output replay consistency#44
Conversation
Greptile SummaryThis PR fixes two interrelated bugs in shell tool output replay:
Confidence Score: 5/5Safe to merge — both the streaming and buffered paths are fixed consistently and covered by focused regression tests. The changes are tightly scoped to the two broken maps (output_pos, item_index) and the missing reorder step. The qualified-key logic for shell items is isolated to index_for and record_output_item, with a clear fallback for all other item types. order_shell_outputs_after_calls is deterministic, handles all edge cases (already-ordered input, orphaned outputs, multi-call interleaving), and is exercised by both new and existing tests. The previous reviewer concern about item_index being unpatched is fully addressed here. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant U as Upstream
participant SR as StreamRewriter
participant DB as Persisted transcript
U->>SR: "output_item.added shell_call id=toolu_1 -> slot 0"
U->>SR: "output_item.added shell_call_output id=toolu_1 -> slot 1"
Note over SR: index_for uses qualified key per type
U->>SR: "output_item.done shell_call_output -> output_items[0]"
U->>SR: "output_item.done shell_call -> output_items[1]"
Note over SR: output_pos uses (type,id) - no collision
U->>SR: response.completed
SR->>SR: ordered_output_items() reorders to call-before-output
SR->>DB: "output[0]=shell_call output[1]=shell_call_output"
Reviews (3): Last reviewed commit: "Review fixes" | Re-trigger Greptile |
No description provided.