Files
selfheal-lab-apps/ai
seon 2a2f91a32c fix(ai): hand an unanswered external turn out again after 3 minutes
참고 측정 1세트 첫 진단에서 클라이언트가 /external/next 로 가져간 2번째 턴의 출력을
잃어 답이 오지 않았고, 턴은 awaiting_reply 에 남아 진단이 데드라인까지 멈췄다. 가져간
뒤 RequeueAfter(기본 3분) 동안 답이 없는 턴은 새 reply_token 으로 큐 앞에 되돌려
다음 폴링이 다시 받게 한다(requeued 횟수 기록, 이전 토큰은 거부). 출력 유실은
재시도 한 번의 비용으로 끝나고 진단은 이어진다.
2026-10-16 22:22:33 +09:00
..

ai

AI VM services of the self-healing lab (experiment design 6). Module github.com/selfheal-lab/selfheal-lab-apps/ai.

command role port
cmd/agent POST /diagnose: Responses API tool loop over the read-only tools (internal/tools, design 6.2), strict submit_diagnosis (design 6.3, internal/diag), sessions and prompt versions in pgvector (internal/rag), then proposal + HITL post or escalation (design 6.5/6.6, internal/agent) 8080
cmd/hitl Discord gateway bot (internal/hitl): Approve/Reject buttons, harness approval + execution, expiry to the escalation channel, escalation threads with the runbook 8081

Contracts: harness POST /diagnose {"alert","run_id","scenario_id"} -> diagnosis fields at top level plus session_id, model, prompt_version, disposition. Harness side: POST /proposals (registers the proposal at diagnosis time, returns the approval token), POST /proposals/{token}/approve, POST /proposals/{token}/reject, POST /actions/execute.

OpenAI: POST /v1/responses with function tools (strict: true, every property required, additionalProperties: false), previous_response_id chaining, function_call_output items; embeddings text-embedding-3-small (1536). Model id from OPENAI_MODEL.

Build: gcloud builds submit ai --project cms-d-414903 --config ai/cloudbuild.yaml --substitutions=_TAG=$(git rev-parse --short HEAD). Tests: cd ai && go test ./... (mock Responses API and Mimir; no network).