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