Optionalfraction?: numberFraction of the model's context size to keep
Optionalmessages?: numberOptionaltokens?: numberNumber of tokens to keep
Optionalfraction?: numberFraction of the model's context size to use as the trigger
Optionalmessages?: numberNumber of messages to use as the trigger
Optionaltokens?: numberNumber of tokens to use as the trigger
Optionalfraction?: numberFraction of the model's context size to use as the trigger
Optionalmessages?: numberNumber of messages to use as the trigger
Optionaltokens?: numberNumber of tokens to use as the trigger
Apply an edit to the message list, returning the new token count.
This method should:
tokens parametermessages array in-place (if needed)Parameters for the editing operation
The updated token count after applying edits
Strategy for clearing tool outputs when token limits are exceeded.
This strategy mirrors Anthropic's
clear_tool_uses_20250919behavior by replacing older tool results with a placeholder text when the conversation grows too large. It preserves the most recent tool results and can exclude specific tools from being cleared.Example