* Dump classifier input prompts + context-comparison diagnostics on API error. * Written to a session-scoped file in the claude temp dir so /share can collect * it (replaces the old Desktop dump). Includes context numbers to help diagnose * projection divergence (classifier tokens >> main loop to
(
systemPrompt: string,
userPrompt: string,
error: unknown,
contextInfo: {
mainLoopTokens: number
classifierChars: number
classifierTokensEst: number
transcriptEntries: number
messages: number
action: string
model: string
},
)
| 211 | * Returns the dump path on success, null on failure. |
| 212 | */ |
| 213 | async function dumpErrorPrompts( |
| 214 | systemPrompt: string, |
| 215 | userPrompt: string, |
| 216 | error: unknown, |
| 217 | contextInfo: { |
| 218 | mainLoopTokens: number |
| 219 | classifierChars: number |
| 220 | classifierTokensEst: number |
| 221 | transcriptEntries: number |
| 222 | messages: number |
| 223 | action: string |
| 224 | model: string |
| 225 | }, |
| 226 | ): Promise<string | null> { |
| 227 | try { |
| 228 | const path = getAutoModeClassifierErrorDumpPath() |
| 229 | await mkdir(dirname(path), { recursive: true }) |
| 230 | const content = |
| 231 | `=== ERROR ===\n${errorMessage(error)}\n\n` + |
| 232 | `=== CONTEXT COMPARISON ===\n` + |
| 233 | `timestamp: ${new Date().toISOString()}\n` + |
| 234 | `model: ${contextInfo.model}\n` + |
| 235 | `mainLoopTokens: ${contextInfo.mainLoopTokens}\n` + |
| 236 | `classifierChars: ${contextInfo.classifierChars}\n` + |
| 237 | `classifierTokensEst: ${contextInfo.classifierTokensEst}\n` + |
| 238 | `transcriptEntries: ${contextInfo.transcriptEntries}\n` + |
| 239 | `messages: ${contextInfo.messages}\n` + |
| 240 | `delta (classifierEst - mainLoop): ${contextInfo.classifierTokensEst - contextInfo.mainLoopTokens}\n\n` + |
| 241 | `=== ACTION BEING CLASSIFIED ===\n${contextInfo.action}\n\n` + |
| 242 | `=== SYSTEM PROMPT ===\n${systemPrompt}\n\n` + |
| 243 | `=== USER PROMPT (transcript) ===\n${userPrompt}\n` |
| 244 | await writeFile(path, content, 'utf-8') |
| 245 | logForDebugging(`Dumped auto mode classifier error prompts to ${path}`) |
| 246 | return path |
| 247 | } catch { |
| 248 | return null |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | const yoloClassifierResponseSchema = lazySchema(() => |
| 253 | z.object({ |
no test coverage detected