mirror of
https://github.com/Twigpine/zero.git
synced 2026-11-10 05:01:28 -10:00
* polish: cut per-turn overhead, stabilize cache, add /new Context economy - Compaction: preserveLast 8->6, triggerRatio 0.8->0.7 (both copies in sync). - System prompt: kill the "ELABORATE summary" directive; scale summary to the work. Comment discipline moved into the core prompt for all model families (was Anthropic-only); Minimax/DeepSeek/Qwen/etc. now get it. - Token-budget regression test ratchets the fixed per-turn overhead (base prompt + eager tool schemas) using the runtime's own estimator, so silent prompt/schema growth fails CI. Response quality - defaultResponseStyle balanced->concise. Reversible via /style. Tool discovery - <available_skills> block in the system prompt lists installed skills (name + one-line description) so the model loads the right one on the first call instead of guessing and reading the failure. Budget-capped at 640 bytes with an "...and N more" fallback; renders nothing when no skills are installed (byte-identical to prior prompt). Session lifecycle - /new starts a fresh session in place; previous session stays on disk and is named in the confirmation for /resume. Guards against mid-run reset. - /clear now notes that context persists and points to /new. Performance & caching - partitionTools no longer alpha-sorts the whole tools array every turn, which inserted a loaded deferred tool mid-array and shifted the cached prefix on every load. It now builds append-only regions [eager sorted] + [tool_search] + [loaded deferred sorted] so a mid-session load grows the tail instead of busting the eager prefix. Regression test asserts the eager block precedes any loaded tool. - /context now shows cache hit rate (flags low rate over >5 turns as a possible unstable prefix) and rolling average turn latency with time-to-first-token. Both reset on /new. Measured baselines (auto-mode, no workspace): base prompt 3162 tokens, eager tool schemas 2433 across 12 tools. Budget ceilings set ~10% above. Deliberately deferred (need a decision): inverted safety-policy rewrite (sandbox doesn't catch ~half the B-tier rules), core-tool/web_fetch deferral (activation-semantics blocker), aggressive prompt slim. * fix(tui): clear staged attachments + queued message on /new CodeRabbit: startNewSession reset conversation/usage/latency state but not the staged input (pendingImages, pendingImageLabels, pendingDocuments, queuedMessage), which is only consumed at prompt-submit. Without clearing it, the fresh session's first prompt silently inherited the previous session's images/documents/queued text. Test now stages all four and asserts they clear.
24 lines
717 B
Go
24 lines
717 B
Go
package usage
|
|
|
|
import "testing"
|
|
|
|
func TestSummaryCacheHitRate(t *testing.T) {
|
|
s := Summary{InputTokens: 13100, CachedInputTokens: 8200}
|
|
if got := s.CacheHitRate(); got < 0.62 || got > 0.63 {
|
|
t.Fatalf("CacheHitRate = %v, want ~0.626", got)
|
|
}
|
|
if got := (Summary{}).CacheHitRate(); got != 0 {
|
|
t.Fatalf("empty CacheHitRate = %v, want 0", got)
|
|
}
|
|
}
|
|
|
|
func TestFormatCacheEfficiency(t *testing.T) {
|
|
s := Summary{InputTokens: 13100, CachedInputTokens: 8200}
|
|
if got := FormatCacheEfficiency(s); got != "63% (8,200 cached / 13,100 input)" {
|
|
t.Fatalf("FormatCacheEfficiency = %q", got)
|
|
}
|
|
if got := FormatCacheEfficiency(Summary{}); got != "n/a" {
|
|
t.Fatalf("empty FormatCacheEfficiency = %q, want n/a", got)
|
|
}
|
|
}
|