Improve app-server streaming event throughput

This commit is contained in:
Fabian Ponce
2026-06-23 03:39:31 +00:00
parent 27f22b54ae
commit b78df5cce7
11 changed files with 421 additions and 80 deletions
@@ -432,7 +432,10 @@ pub fn item_event_to_server_notification(
}
EventMsg::ExecCommandOutputDelta(exec_command_output_delta_event) => {
let item_id = exec_command_output_delta_event.call_id;
let delta = String::from_utf8_lossy(&exec_command_output_delta_event.chunk).to_string();
let delta = match String::from_utf8(exec_command_output_delta_event.chunk) {
Ok(delta) => delta,
Err(error) => String::from_utf8_lossy(error.as_bytes()).into_owned(),
};
ServerNotification::CommandExecutionOutputDelta(
CommandExecutionOutputDeltaNotification {
thread_id,
@@ -608,4 +611,27 @@ mod tests {
},
);
}
#[test]
fn exec_command_output_delta_preserves_lossy_utf8_mapping() {
let notification = item_event_to_server_notification(
EventMsg::ExecCommandOutputDelta(ExecCommandOutputDeltaEvent {
call_id: "call-1".to_string(),
stream: ExecOutputStream::Stdout,
chunk: b"hello\xFFworld".to_vec(),
}),
"thread-1",
"turn-1",
);
assert_command_execution_output_delta_server_notification(
notification,
CommandExecutionOutputDeltaNotification {
thread_id: "thread-1".to_string(),
turn_id: "turn-1".to_string(),
item_id: "call-1".to_string(),
delta: "hello\u{FFFD}world".to_string(),
},
);
}
}