You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(truncate): unique cache keys per payload + read_cache truncation observability
Follow-ups from PR #480 review:
1. Multi-block cache-key collision. cache.GenerateKey mixed the timestamp
in at second granularity. forwardContentResult truncates each oversized
TextContent block independently and the truncator derives the key from
toolName+args+time.Now(); two blocks truncated in the same wall-clock
second produced the SAME key, so the second Store overwrote the first
and the first banner resolved to the wrong payload. Same hazard for
rapid recursive read_cache truncation. Now nanosecond granularity.
2. Doc wording. maybeTruncateAndCacheText doc now states termination is
agent-driven (not strictly algorithmic) and that successive identical
calls are NOT idempotent (distinct timestamped keys), bounded only by
cache TTL + cleanup.
3. read_cache truncation observability. handleReadCache discarded
wasTruncated; it has no token-metrics plumbing (reports via activity
log). A recursively re-truncated page was invisible to operators — now
surfaced as a structured Info log with key/offset/limit/size.
Tests: new GenerateKey sub-second regression assertion;
TestForwardContentResult_MultipleTextBlocksDistinctKeys. Full
internal/server, internal/cache, internal/truncate pass (incl. -race).
0 commit comments