MCPcopy Index your code
hub / github.com/codeaashu/claude-code / detectPromptTooLong

Function detectPromptTooLong

src/utils/permissions/yoloClassifier.ts:1463–1471  ·  view source on GitHub ↗

* 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,
)

Source from the content-addressed store, hash-verified

1461 * won't help — unlike 429/5xx which sideQuery already retries internally.
1462 */
1463function 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.

Callers 2

classifyYoloActionXmlFunction · 0.85
classifyYoloActionFunction · 0.85

Calls 1

Tested by

no test coverage detected