MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestCtxPressureTripwire

Function TestCtxPressureTripwire

internal/tui/tui_test.go:761–784  ·  view source on GitHub ↗

TestCtxPressureTripwire: the round_done companion warning fires only when the server-counted prompt reaches 95% of the active window. The char/4 packer undercounts code-heavy history (~1.6x measured on a real run), so the server count is the only signal that the real prompt is about to spill past th

(t *testing.T)

Source from the content-addressed store, hash-verified

759// undercounts code-heavy history (~1.6x measured on a real run), so the server
760// count is the only signal that the real prompt is about to spill past the
761// window into silent server-side truncation.
762func TestCtxPressureTripwire(t *testing.T) {
763 dir := t.TempDir()
764 OpenDebugLog(dir)
765 t.Cleanup(CloseDebugLog)
766 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
767 m.liveContextSize[m.cfg.Active] = 10000
768
769 m.applyDone(llm.Event{PromptTokens: 9499}) // below threshold: silent
770 m.applyDone(llm.Event{}) // server reported nothing: silent
771 m.applyDone(llm.Event{PromptTokens: 9500}) // 95%: fire
772 CloseDebugLog()
773
774 raw, err := os.ReadFile(filepath.Join(dir, "log.txt"))
775 if err != nil {
776 t.Fatal(err)
777 }
778 logStr := string(raw)
779 if got := strings.Count(logStr, "] ctx_pressure"); got != 1 {
780 t.Fatalf("tripwire must fire exactly once (at >=95%% of the window), got %d\n%s", got, logStr)
781 }
782 if !strings.Contains(logStr, "prompt_tokens=9500 at >=95% of ctx=10000") {
783 t.Fatalf("tripwire record must name the offending count and window:\n%s", logStr)
784 }
785}
786
787// TestSlashModelSwitchDropsStickyFallbackState: llm.Client's noReasoningEffort

Callers

nothing calls this directly

Calls 4

OpenDebugLogFunction · 0.85
newTestModelFunction · 0.85
CloseDebugLogFunction · 0.85
applyDoneMethod · 0.80

Tested by

no test coverage detected