Skip to content

Commit f1d7c7b

Browse files
committed
Document keepDuringTruncation trade-off in orphaned tool result drop
1 parent 441947e commit f1d7c7b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/agent-runtime/src/util/messages.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff 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>) => {

0 commit comments

Comments
 (0)