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