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

Function TestRunawayNudgeFiresOnceAtMaxToolRounds

internal/tui/tui_test.go:1961–1985  ·  view source on GitHub ↗

TestRunawayNudgeFiresOnceAtMaxToolRounds: the per-turn tool-call counter trips exactly one soft system note when it reaches maxToolRounds, and never before or after. A once-per-turn latch keeps a long turn from double-firing it.

(t *testing.T)

Source from the content-addressed store, hash-verified

1959// the repeated-failure backstop's counters.
1960func TestClearResetsFailureStreak(t *testing.T) {
1961 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
1962 m.failKey = tools.BashName + "|make build"
1963 m.failStreak = maxToolFailStreak - 1
1964 out, _ := m.runSlash("/clear")
1965 final := out.(Model)
1966 if final.failStreak != 0 || final.failKey != "" {
1967 t.Fatalf("/clear must reset the failure streak, got key=%q streak=%d",
1968 final.failKey, final.failStreak)
1969 }
1970}
1971
1972// countSystem counts RoleSystem messages, the shape every nudge appends.
1973func countSystem(history []chmctx.Message) int {
1974 n := 0
1975 for _, msg := range history {
1976 if msg.Role == chmctx.RoleSystem {
1977 n++
1978 }
1979 }
1980 return n
1981}
1982
1983// TestRunawayNudgeFiresOnceAtMaxToolRounds: the per-turn tool-call counter trips
1984// exactly one soft system note when it reaches maxToolRounds, and never before
1985// or after. A once-per-turn latch keeps a long turn from double-firing it.
1986func TestRunawayNudgeFiresOnceAtMaxToolRounds(t *testing.T) {
1987 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
1988

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
countSystemFunction · 0.85
maybeRunawayNudgeMethod · 0.80

Tested by

no test coverage detected