| 628 | } |
| 629 | |
| 630 | fn normalize_stop_raw(mut raw: Value) -> Value { |
| 631 | if let Some(obj) = raw.as_object_mut() { |
| 632 | // `stop_hook_active` means a previous Stop hook requested a |
| 633 | // continuation; it is not a model finish reason. Codex emits a real |
| 634 | // SessionEnd event for terminal lifecycle work, so Stop only closes |
| 635 | // the current response/turn. |
| 636 | obj.entry("finish_reason".to_string()) |
| 637 | .or_insert_with(|| Value::String("stop".to_string())); |
| 638 | } |
| 639 | raw |
| 640 | } |
| 641 | |
| 642 | fn normalize_tool_raw(mut raw: Value) -> Value { |
| 643 | let Some(response) = raw.get("tool_response").cloned() else { |