File tree Expand file tree Collapse file tree
packages/agent-runtime/src/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -234,7 +234,10 @@ export function trimMessagesToFitTokenLimit(params: {
234234 // then reaches the provider without its call and is rejected with
235235 // "tool_call_id does not exist", failing the whole step. Drop results whose
236236 // call this trim removed — but only those, so orphans that were already in
237- // the input history pass through unchanged.
237+ // the input history pass through unchanged. This also overrides
238+ // keepDuringTruncation on a tool result whose call was removed: keeping the
239+ // pair together would exceed the budget and keeping the result alone would
240+ // be rejected, so a result cannot outlive its call.
238241 const removedCallIds = new Set < string > ( )
239242 const survivingCallIds = new Set < string > ( )
240243 const collectCallIds = ( message : Message , into : Set < string > ) => {
You can’t perform that action at this time.
0 commit comments