v2.2.256: 코어 채팅 큰 입력 청킹·통합 + 실제 컨텍스트 창 정렬 + 모델 핸들 race 수정

큰 입력 시 "Failed to acquire LM Studio model handle … Operation canceled"
로 턴 전체가 죽던 문제를 3계층으로 해결. 일반 채팅(코어 경로)은 그동안
단일 예산 호출이라 약한 모델·큰 입력에서 무너졌다 — 그 갭을 메움.

- 핸들 race 수정: getModelHandle 을 재시도 루프 안으로 이동. 취소/죽은-핸들
  류 에러는 SDK 재생성 후 1회 자동 재시도(실제 사용자 취소는 존중). 라이프
  사이클의 동시 로드가 abort 되며 SDK 가 coalesce 한 JIT 조회까지 죽던 것.
- Phase 1 실제 창 정렬: llm.getContextLength()(캐시)로 실측 창에 예산 클램프.
  설정값보다 작은 창으로 로드된 경우 서버 truncation/빈 답변 차단. 배지에 표시.
- Phase 2 코어 Map-Reduce: 단일 입력이 (유효 창 × ratio) 초과 시 청크→질의
  인지형 추출→통합. 부분/전체 폴백, 무관 시 정직 신호. 동시성 기본 2.
- Phase 3 메타 노출: 진행/결과 배지 표시, [조각 k] 출처 옵트인.

신규 설정 5종. /meet·/review 전용 경로는 불변. 테스트 +25건, 전체 684 통과.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-19 18:05:44 +09:00
parent 6adbc2a6fa
commit 76d5fedfb5
13 changed files with 883 additions and 19 deletions
+58
View File
@@ -0,0 +1,58 @@
/**
* Phase 1 — context-window alignment.
*
* The budgeter must clamp to the model's ACTUALLY-loaded window when it's
* smaller than the user's `contextLength` setting, so a model loaded with a
* smaller window than the setting never silently overflows the server.
*/
import { computeBudgetedRequest } from '../src/agent/handlePrompt/computeBudgetedRequest';
import type { ChatMessage } from '../src/agent';
const baseConfig = {
contextLength: 32768,
maxOutputTokens: 4096,
contextSafetyMargin: 512,
smallModelContextCap: 0, // disabled
autoCompactHistory: false,
};
function run(overrides: { actualContextLength?: number; config?: Partial<typeof baseConfig> } = {}) {
const reqMessages: ChatMessage[] = [{ role: 'user', content: 'hello' }];
return computeBudgetedRequest({
fullSystemPrompt: 'You are a helpful assistant.',
reqMessages,
actualModel: 'some-13b-model',
config: { ...baseConfig, ...overrides.config },
imageCount: 0,
actualContextLength: overrides.actualContextLength,
});
}
describe('computeBudgetedRequest — real-window alignment', () => {
test('clamps to the actual loaded window when it is smaller than the setting', () => {
const r = run({ actualContextLength: 8192 });
expect(r.windowMismatch).toBe(true);
expect(r.effectiveContextLength).toBe(8192);
expect(r.ctxLimits.contextLength).toBe(8192);
});
test('keeps the configured window when the actual window is unknown', () => {
const r = run({ actualContextLength: undefined });
expect(r.windowMismatch).toBe(false);
expect(r.effectiveContextLength).toBe(32768);
expect(r.ctxLimits.contextLength).toBe(32768);
});
test('does not raise the window when the actual window is larger than the setting', () => {
const r = run({ actualContextLength: 131072 });
expect(r.windowMismatch).toBe(false);
expect(r.effectiveContextLength).toBe(32768); // setting is the lower bound here
});
test('ignores a non-positive / non-finite actual window (falls back to setting)', () => {
expect(run({ actualContextLength: 0 }).effectiveContextLength).toBe(32768);
expect(run({ actualContextLength: -5 }).effectiveContextLength).toBe(32768);
expect(run({ actualContextLength: NaN }).effectiveContextLength).toBe(32768);
});
});