모델 id가 external- 로 시작하면 ai-agent 가 LLM API 를 부르지 않고 각 턴(시스템 프롬프트·대화 이력·도구 정의·강제 제출 여부)을 GET /external/next 로 내어주고 POST /external/reply 로 답을 받는다. 진단 루프·프롬프트·도구·턴 상한은 다른 모델과 동일하므로, API 경로가 없는 모델(Claude Mythos 5.1 을 Claude Code 서브에이전트가 구동)의 참고 측정에 쓴다. 토큰 사용량은 알 수 없어 0 으로 기록한다. external-* 진단은 EXTERNAL_DIAGNOSE_TIMEOUT_S(기본 1500초), 한 턴은 EXTERNAL_TURN_TIMEOUT_S(기본 1200초)까지 기다리고, 하네스는 같은 모델에 26분을 기다린다. /selfcheck 에 external_responder 상태(대기 턴·마지막 폴링 시각)를 추가.
64 lines
2.1 KiB
Go
64 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// one fault, several alerts with the same name (per-pod label sets, group resend): one diagnosis inside the window
|
|
func TestDedupeSameAlertName(t *testing.T) {
|
|
r := NewAlertRouter(&App{cfg: Config{AlertDedupeS: 300}})
|
|
sid := "C-G2"
|
|
if _, dup := r.dedupe("ApiMemoryPressure", &sid); dup {
|
|
t.Fatal("first alert must be diagnosed")
|
|
}
|
|
if _, dup := r.dedupe("ApiMemoryPressure", &sid); !dup {
|
|
t.Fatal("second alert inside the window must be skipped")
|
|
}
|
|
other := "V-G1"
|
|
if _, dup := r.dedupe("ApiMemoryPressure", &other); dup {
|
|
t.Fatal("another scenario is a new fault")
|
|
}
|
|
// all alerts of that name resolved -> the next firing starts a new diagnosis
|
|
r.setFiring("fp1", "ApiMemoryPressure", true)
|
|
r.clearDedupe("ApiMemoryPressure", &sid) // still firing: keep
|
|
if _, dup := r.dedupe("ApiMemoryPressure", &sid); !dup {
|
|
t.Fatal("still firing: keep the window")
|
|
}
|
|
r.setFiring("fp1", "ApiMemoryPressure", false)
|
|
r.clearDedupe("ApiMemoryPressure", &sid)
|
|
if _, dup := r.dedupe("ApiMemoryPressure", &sid); dup {
|
|
t.Fatal("after resolve the next firing is a new fault")
|
|
}
|
|
// window expiry
|
|
r.lastDiag["ApiMemoryPressure|"+sid] = time.Now().Add(-301 * time.Second)
|
|
if _, dup := r.dedupe("ApiMemoryPressure", &sid); dup {
|
|
t.Fatal("outside the window a new diagnosis is allowed")
|
|
}
|
|
// off
|
|
r2 := NewAlertRouter(&App{cfg: Config{AlertDedupeS: 0}})
|
|
if _, dup := r2.dedupe("X", nil); dup {
|
|
t.Fatal("dedupe off")
|
|
}
|
|
if _, dup := r2.dedupe("X", nil); dup {
|
|
t.Fatal("dedupe off")
|
|
}
|
|
}
|
|
|
|
// external-* models (reference runs served by a client outside the AI VM) get the long diagnose timeout; the model id
|
|
// itself passes the run request bound.
|
|
func TestDiagnoseTimeoutByModel(t *testing.T) {
|
|
if d := diagnoseTimeout("claude-sonnet-5-5"); d != 3*time.Minute {
|
|
t.Fatalf("api model timeout %v", d)
|
|
}
|
|
if d := diagnoseTimeout(""); d != 3*time.Minute {
|
|
t.Fatalf("default model timeout %v", d)
|
|
}
|
|
if d := diagnoseTimeout("external-claude-mythos-5-1"); d != 26*time.Minute {
|
|
t.Fatalf("external model timeout %v", d)
|
|
}
|
|
if !modelRe.MatchString("external-claude-mythos-5-1") {
|
|
t.Fatal("external model id must pass modelRe")
|
|
}
|
|
}
|