Files
compaction-mcp/tokens.go
T
lukaszraczylo 0ddd0e4598 Initial implementation of compaction MCP server
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.
2026-03-07 16:57:12 +00:00

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
}