* Detect API 400 "prompt is too long: N tokens > M maximum" errors and * parse the token counts. Returns undefined for any other error. * These are deterministic (same transcript → same error) so retrying * won't help — unlike 429/5xx which sideQuery already retries internally.
( error: unknown, )
| 1461 | * won't help — unlike 429/5xx which sideQuery already retries internally. |
| 1462 | */ |
| 1463 | function detectPromptTooLong( |
| 1464 | error: unknown, |
| 1465 | ): ReturnType<typeof parsePromptTooLongTokenCounts> | undefined { |
| 1466 | if (!(error instanceof Error)) return undefined |
| 1467 | if (!error.message.toLowerCase().includes('prompt is too long')) { |
| 1468 | return undefined |
| 1469 | } |
| 1470 | return parsePromptTooLongTokenCounts(error.message) |
| 1471 | } |
| 1472 | |
| 1473 | /** |
| 1474 | * Get which stage(s) the XML classifier should run. |
no test coverage detected