mirror of
https://github.com/lukaszraczylo/compaction-mcp.git
synced 2026-06-05 23:14:02 +00:00
0ddd0e4598
Ephemeral, per-session context management for LLMs with 8 MCP tools: store, query, status, compact, pin, forget, configure, update. Features: scoring with decay/importance/access, Jaccard dedup, summary promotion, budget-based eviction, auto-detection of client context window via MCP hooks.
11 lines
212 B
Go
11 lines
212 B
Go
package main
|
|
|
|
// EstimateTokens returns a rough token count for a string.
|
|
// Uses ~4 characters per token heuristic.
|
|
func EstimateTokens(s string) int {
|
|
if len(s) == 0 {
|
|
return 0
|
|
}
|
|
return (len(s) + 3) / 4
|
|
}
|