Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
변경 요약
keep-warm 창이 끝날 때 이유가 있으면(
stoppedWhy가 설정되는 경우) 서버 로그에 한 줄을 남깁니다:keep-warm <threadId>: stopped, <이유>.server/cache-keepwarm.ts:KeepWarmDeps에 선택 의존성log?를 추가하고end()가 이유가 있을 때 호출합니다.warm-summary-host의deps.log?.(...)와 같은 방식이라 기존 테스트 하네스는 바꾸지 않았습니다.server/index.ts:createCacheKeepWarm에log: (line) => console.info(line)을 넘깁니다(warm summary와 동일).이유
"종료된 턴의 claude CLI 자식 프로세스가 30~45분 뒤에야 사라진다"는 보고를 추적했는데 reap 누수가 아니라 keep-warm hold였습니다.
closeSession이 stdin EOF 후 5초 뒤stopSession으로 강제 종료하고killCliTree가 자식 트리를 정리합니다. 재부팅 전 관측에서도 18개 → 11개 → 0개로 줄었습니다.~/.openmausbot/native/*.ndjson의claude.sessionclose 이벤트(최근 3일): idle close 118건 중 77건이 마지막result뒤 59~90분(중앙값 60.1분, 최대 83.6분)에 닫혔습니다. 10분 이하는 31건입니다. 77건 모두 contextTokens ≥ 50k인claudeinstance로, keep-warm 대상 조건과 같습니다.noteTurnCompleted가hold(target, now+180분)→ 첫 ping은 +50분(PING_AFTER_MS) → ping이 실패하거나 cold로 판정되면end()가 hold를 풀고 → idle 10분 뒤 닫힘. 합이 약 60분이라 분포와 맞습니다.stoppedWhy는 메모리와 UI에만 있고server.log에는 keep-warm 줄이 없습니다. 그래서 hold 세션 수십 개(합 2GB 안팎)가 왜 매번 ping 한 번으로 끝나는지 지금은 판정할 수 없습니다.이 PR은 원인을 고치는 것이 아니라, 원인을 하루치 로그로 판정할 수 있게 하는 관측만 추가합니다. 구조 변경(hold 상한, 게이트웨이 사용 시 대상 제외, 프로세스 대신 contract만 hold)은 설계 합의가 필요해 포함하지 않았습니다.
검증
npx vitest run server/cache-keepwarm.test.ts server/cache-keepwarm-target.test.ts: 2 files, 21 tests 통과npx tsc -p tsconfig.server.json --noEmit: 오류 없음npx oxlint --deny-warnings server/cache-keepwarm.ts server/index.ts: 경고 없음2 changed file(s) checkedcreateCacheKeepWarm에 가짜 시계·ping 실패 응답을 넣고 +50분까지 진행하는 프로브/private/tmp/claude-502/a-repro/probe.mjs <루트경로>Before / After
같은 입력(턴 완료 → +50분 ping이
API Error: 404 model not found로 실패)을 main 체크아웃과 이 브랜치에서 실행했습니다. before는 이유가 상태에만 있고 로그에 없는 것, after는 이유가 로그에 한 줄 남는 것입니다.5e466f711)status.stoppedWhy(메모리·UI)만[]status.stoppedWhy+ 서버 로그["keep-warm thread-1: stopped, API Error: 404 model not found"]확인하지 못한 것
~/.claude/settings.json의ANTHROPIC_BASE_URL이 게이트웨이를 가리키는데claudeBilling()은ANTHROPIC_API_KEY·api-key계정만 보고 metered를 판정하므로 게이트웨이 사용도 "subscription"으로 분류되어 keep-warm 대상이 됩니다. 게이트웨이 뒤에서는 캐시 가정이 안 맞아 ping이 cold로 끝날 수 있습니다.