feat(ai): external responder for external-* model ids (reference runs)
모델 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 상태(대기 턴·마지막 폴링 시각)를 추가.
This commit is contained in:
1 parent
85d99324a1
commit
ed3d41d399
8 files changed
+585
-6
No files matched your search
+16
-3
@@ -10,6 +10,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
@@ -226,14 +227,26 @@ func (r *AlertRouter) cancelTimer(fp string) {
|
||||
}
|
||||
}
|
||||
|
||||
// diagnoseTimeout bounds one /diagnose call: 3 minutes for API models (the AI VM gives up at 170 s); external-*
|
||||
// models (reference runs answered by a client outside the VM, apps 2026-10-16) get 26 minutes, one more than the AI
|
||||
// VM's EXTERNAL_DIAGNOSE_TIMEOUT_S default, so the VM's own error reaches the diagnosis event first.
|
||||
func diagnoseTimeout(model string) time.Duration {
|
||||
if strings.HasPrefix(model, "external-") {
|
||||
return 26 * time.Minute
|
||||
}
|
||||
return 3 * time.Minute
|
||||
}
|
||||
|
||||
// diagnose asks the AI VM (design 6.3 strict schema). Until WP-12 the endpoint is absent; the failure is recorded as an event.
|
||||
func (r *AlertRouter) diagnose(alert map[string]any, runID, sid *string) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
|
||||
defer cancel()
|
||||
reqBody := map[string]any{"alert": alert, "run_id": runID, "scenario_id": sid}
|
||||
model := ""
|
||||
if cur := r.app.runs.current(); cur != nil && runID != nil && cur.RunID == *runID && cur.Model != "" {
|
||||
reqBody["model"] = cur.Model // campaign-level model selection (the AI VM falls back to its default when absent)
|
||||
model = cur.Model
|
||||
reqBody["model"] = model // campaign-level model selection (the AI VM falls back to its default when absent)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), diagnoseTimeout(model))
|
||||
defer cancel()
|
||||
b, _ := json.Marshal(reqBody)
|
||||
req, _ := http.NewRequestWithContext(ctx, "POST", r.app.cfg.AIDiagnoseURL, bytes.NewReader(b))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
Reference in new issue
Block a user