(msg: AssistantMessage)
| 62 | export const PROMPT_TOO_LONG_ERROR_MESSAGE = 'Prompt is too long' |
| 63 | |
| 64 | export function isPromptTooLongMessage(msg: AssistantMessage): boolean { |
| 65 | if (!msg.isApiErrorMessage) { |
| 66 | return false |
| 67 | } |
| 68 | const content = msg.message.content |
| 69 | if (!Array.isArray(content)) { |
| 70 | return false |
| 71 | } |
| 72 | return content.some( |
| 73 | block => |
| 74 | block.type === 'text' && |
| 75 | block.text.startsWith(PROMPT_TOO_LONG_ERROR_MESSAGE), |
| 76 | ) |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Parse actual/limit token counts from a raw prompt-too-long API error |
no outgoing calls
no test coverage detected