feat: 모델별 도구-스킵(AUTO-RECOVER) 발생 로그 추가
사용자가 "지서버 젬마(gemma4:26b)가 도구를 잘 안 부르는 경향이 있다"고
직접 사용 경험을 보고했다. 이건 mistral-large-3 프로필이 이미 대응하는
것과 같은 실패 클래스(확인 가능한 질문에 도구 없이 답함)인데, 젬마
쪽은 뒷받침할 로그 증거가 없었다 — 있는 거라곤 사용자의 기억뿐이었다.
[[feedback_calibrate_on_real_data]]에 이미 세 번 적힌 교훈대로("가상
케이스로 임계값 잡으면 틀린다"), 기억만으로 프롬프트 경고를 새로
박아넣는 대신 실제 신호를 기록하고 나중에 데이터로 판단하기로 했다.
decideAutoRecover()가 이미 정확히 필요한 이벤트("도구가 필요한 질문에
관련 도구 없이 답함")를 계산하고 있었는데, 그 결과가 닿는 곳이 로테이션
되는 콘솔 로그 한 줄뿐이었고 거기엔 모델 이름도 없었다. usage-log.ts와
같은 형태(같은 디렉터리, 같은 JSONL append 패턴)로 tool-skip.jsonl을
추가해 모델별 집계가 가능하게 했다.
effectiveModel이 try 블록 안에서만 스코프였고 AUTO-RECOVER 체크는 그
catch 이후라서, try 블록 진입 시점에 resolvedModelThisRound에 미리
복사해 바깥에서도 참조 가능하게 했다.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d4e8750400
commit
aa74d4b710
2 files changed
+58
-1
No files matched your search
@@ -75,6 +75,7 @@ import { buildChatSystemPrompt } from './system-prompt';
|
||||
import { replyLooksEmpty } from './reply-content';
|
||||
import { evaluateSearchBudget } from './search-budget';
|
||||
import { decideAutoRecover, shouldForceMessagingRetry as decideMessagingRetry, shouldForceEmptyGroundingRetry as decideEmptyGroundingRetry, GROUNDING_TOOL_PATTERN } from './retry-decisions';
|
||||
import { logToolSkip } from './tool-skip-log';
|
||||
import { checkNumericGrounding } from './numeric-grounding';
|
||||
|
||||
const MAX_TOOL_ROUNDS = 50;
|
||||
@@ -1203,6 +1204,9 @@ async function handleChat(
|
||||
}
|
||||
|
||||
let response: any;
|
||||
// Hoisted above the try block so AUTO-RECOVER (after the catch, where effectiveModel is out
|
||||
// of scope) can still attribute the event to a model — see tool-skip-log.ts.
|
||||
let resolvedModelThisRound: string = '';
|
||||
try {
|
||||
// In multi-agent mode, disable thinking for browser ops — the secondary AI
|
||||
// holds all context and issues exact directives; the primary just executes.
|
||||
@@ -1237,6 +1241,7 @@ async function handleChat(
|
||||
|| _visionFallbackModel
|
||||
|| skillsManager.getModelOverrideForUser(username ? getUserWorkspace(username) : null, message)
|
||||
|| undefined;
|
||||
resolvedModelThisRound = effectiveModel || getModelForRole('executor');
|
||||
// Round 0 only: for models flagged in config (models.profiles[x].forceToolChoiceOnLiveData
|
||||
// — currently just mistral-large-3, see getModelProfileForceToolChoice), mechanically
|
||||
// force a tool call on a live-data/factual question instead of just asking nicely via
|
||||
@@ -1557,7 +1562,15 @@ async function handleChat(
|
||||
if (_recover.shouldRetry) {
|
||||
toolSkipForcedRetries++;
|
||||
const liveDataReason = _recover.reason;
|
||||
console.log(`[v2] AUTO-RECOVER (${toolSkipForcedRetries}/${MAX_TOOL_SKIP_FORCED_RETRIES}): Model dumped ${content.length} chars${liveDataReason || ' of reasoning instead of calling tools'}${allToolResults.length > 0 ? ` [${allToolResults.length} unrelated tool call(s) already made this turn]` : ''}. Re-prompting...`);
|
||||
const autoRecoverModel = resolvedModelThisRound || getModelForRole('executor');
|
||||
console.log(`[v2] AUTO-RECOVER (${toolSkipForcedRetries}/${MAX_TOOL_SKIP_FORCED_RETRIES}) [${autoRecoverModel}]: Model dumped ${content.length} chars${liveDataReason || ' of reasoning instead of calling tools'}${allToolResults.length > 0 ? ` [${allToolResults.length} unrelated tool call(s) already made this turn]` : ''}. Re-prompting...`);
|
||||
logToolSkip({
|
||||
model: autoRecoverModel,
|
||||
kind: _recover.kind,
|
||||
reason: liveDataReason || '(reasoning instead of calling tools)',
|
||||
messagePreview: message.slice(0, 80),
|
||||
contentLength: content.length,
|
||||
});
|
||||
allThinking += (allThinking ? '\n\n' : '') + content;
|
||||
sendSSE('thinking', { thinking: content.slice(0, 500) + '...' });
|
||||
// Inject a forceful nudge and retry this round
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* tool-skip-log.ts
|
||||
* Append-only JSONL log of AUTO-RECOVER firings, broken down by model.
|
||||
*
|
||||
* Created 2026-08-10 to answer a specific question with data instead of a guess: the user
|
||||
* reported gemma4:26b (지서버) "잘 도구를 안 부르는" (doesn't call tools well), which would be
|
||||
* the same failure class mistral-large-3 has a documented profile for — but there was no
|
||||
* evidence for gemma specifically, only the user's impression from live use. Per
|
||||
* [[feedback_calibrate_on_real_data]] (three prior incidents of guessing thresholds from vibes
|
||||
* and getting them wrong), the right move is to log the real signal and check back, not
|
||||
* hardcode a warning off one remembered anecdote.
|
||||
*
|
||||
* decideAutoRecover() in retry-decisions.ts already computes the exact event we need — "the
|
||||
* model answered a question that needed a tool without calling a relevant one" — but its result
|
||||
* only ever reached a console.log line with no model name attached, in a log file that rotates.
|
||||
* This mirrors usage-log.ts's shape (same directory, same JSONL-append pattern) so the same
|
||||
* `python3 -c "import json; ..."` one-liners work on both.
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { getConfig } from '../../config/config';
|
||||
|
||||
const TOOL_SKIP_LOG_PATH = (() => {
|
||||
try { return path.join(getConfig().getConfigDir(), 'logs', 'tool-skip.jsonl'); }
|
||||
catch { return null; }
|
||||
})();
|
||||
|
||||
export interface ToolSkipEvent {
|
||||
model: string;
|
||||
kind: 'browser' | 'desktop' | 'search';
|
||||
reason: string;
|
||||
/** First 80 chars of the user's message — enough to spot-check without logging full content. */
|
||||
messagePreview: string;
|
||||
contentLength: number;
|
||||
}
|
||||
|
||||
export function logToolSkip(event: ToolSkipEvent): void {
|
||||
if (!TOOL_SKIP_LOG_PATH) return;
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(TOOL_SKIP_LOG_PATH), { recursive: true });
|
||||
fs.appendFileSync(TOOL_SKIP_LOG_PATH, JSON.stringify({ ts: new Date().toISOString(), ...event }) + '\n');
|
||||
} catch { /* non-fatal — this is a diagnostic aid, never block the retry it's logging */ }
|
||||
}
|
||||
Reference in new issue
Block a user