Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //go:embed prompts/compaction-system.txt SystemPrompt string //go:embed prompts/compaction-user.txt UserPrompt string )
Functions ¶
func EstimateMessageTokens ¶
EstimateMessageTokens returns a rough token-count estimate for a single chat message based on its text length. This is intentionally conservative (overestimates) so that proactive compaction fires before we hit the limit.
The estimate accounts for message content, multi-content text parts, reasoning content, tool call arguments, and a small per-message overhead for role/metadata tokens.
func ShouldCompact ¶
ShouldCompact reports whether a session's context usage has crossed the compaction threshold. It returns true when the total token count (input + output + addedTokens) exceeds [contextThreshold] (90%) of contextLimit.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.