* Is this a max_output_tokens error message? If so, the streaming loop should * withhold it from SDK callers until we know whether the recovery loop can * continue. Yielding early leaks an intermediate error to SDK callers (e.g. * cowork/desktop) that terminate the session on any `error` field —
( msg: Message | StreamEvent | undefined, )
| 173 | * Mirrors reactiveCompact.isWithheldPromptTooLong. |
| 174 | */ |
| 175 | function isWithheldMaxOutputTokens( |
| 176 | msg: Message | StreamEvent | undefined, |
| 177 | ): msg is AssistantMessage { |
| 178 | return msg?.type === 'assistant' && msg.apiError === 'max_output_tokens' |
| 179 | } |
| 180 | |
| 181 | export type QueryParams = { |
| 182 | messages: Message[] |