mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Stream apply_patch changes (#17862)
Adds new events for streaming apply_patch changes from responses api. This is to enable clients to show progress during file writes. Caveat: This does not work with apply_patch in function call mode, since that required adding streaming json parsing.
This commit is contained in:
committed by
GitHub
Unverified
parent
9effa0509f
commit
7995c66032
@@ -104,6 +104,18 @@ fn response_event_to_json(event: codex_api::ResponseEvent) -> serde_json::Value
|
||||
codex_api::ResponseEvent::OutputTextDelta(delta) => {
|
||||
json!({ "type": "response.output_text.delta", "delta": delta })
|
||||
}
|
||||
codex_api::ResponseEvent::ToolCallInputDelta {
|
||||
item_id,
|
||||
call_id,
|
||||
delta,
|
||||
} => {
|
||||
json!({
|
||||
"type": "response.tool_call_input.delta",
|
||||
"item_id": item_id,
|
||||
"call_id": call_id,
|
||||
"delta": delta,
|
||||
})
|
||||
}
|
||||
codex_api::ResponseEvent::ReasoningSummaryDelta {
|
||||
delta,
|
||||
summary_index,
|
||||
@@ -216,4 +228,22 @@ mod tests {
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tool_call_input_delta_uses_responses_event_name() {
|
||||
let delta = response_event_to_json(codex_api::ResponseEvent::ToolCallInputDelta {
|
||||
item_id: "item-1".to_string(),
|
||||
call_id: Some("call-1".to_string()),
|
||||
delta: "patch".to_string(),
|
||||
});
|
||||
assert_eq!(
|
||||
delta,
|
||||
json!({
|
||||
"type": "response.tool_call_input.delta",
|
||||
"item_id": "item-1",
|
||||
"call_id": "call-1",
|
||||
"delta": "patch",
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user