Rewrite oversized tool outputs during remote compaction (#26251)

## Why

When trying to fit history under compaction limit rewrite output items
instead of removing them entirely. Otherwise we're breaking
incrementality in relation to the previous response.
This commit is contained in:
pakrym-oai
2026-06-03 15:25:50 -07:00
committed by GitHub
Unverified
parent 11bceb8f8b
commit 4231472c03
6 changed files with 330 additions and 89 deletions
+4 -4
View File
@@ -185,16 +185,16 @@ async fn run_remote_compact_task_inner_impl(
let mut history = sess.clone_history().await;
let base_instructions = sess.get_base_instructions().await;
let deleted_items = trim_function_call_history_to_fit_context_window(
let rewritten_outputs = trim_function_call_history_to_fit_context_window(
&mut history,
turn_context.as_ref(),
&base_instructions,
);
if deleted_items > 0 {
if rewritten_outputs > 0 {
info!(
turn_id = %turn_context.sub_id,
deleted_items,
"trimmed history items before remote compaction v2"
rewritten_outputs,
"rewrote history outputs before remote compaction v2"
);
}