test('consumeSessionEventsUntilFinish surfaces reasoning_content protocol errors before Finish',async()=>{
constframes=[
`data: ${JSON.stringify({
type:'Message',
request_id:'req-1',
message:{
role:'assistant',
content:[{
type:'text',
text:'Ran into this error: Bad request (400): The reasoning_content in the thinking mode must be passed back to the API.\n\nPlease retry if you think this is a transient or recoverable error.',
test('consumeSessionEventsUntilFinish surfaces provider tool history errors before Finish',async()=>{
constframes=[
`data: ${JSON.stringify({
type:'Message',
request_id:'req-1',
message:{
role:'assistant',
content:[{
type:'text',
text:"Ran into this error: Request failed: Bad request (400): An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'. (insufficient tool messages following tool_calls message).\n\nPlease retry if you think this is a transient or recoverable error.",
test('consumeSessionEventsUntilFinish classifies unsupported visual history as degradable',async()=>{
constmessage=
'Request failed: Bad request (400): Failed to deserialize the JSON body into the target type: messages[8]: unknown variant `image_url`, expected `text`';
assert.equal(
classifySessionProviderErrorMessage(message),
'SESSION_VISUAL_CONTEXT_UNSUPPORTED',
);
constframes=[
`data: ${JSON.stringify({
type:'Message',
request_id:'req-visual',
message:{
role:'assistant',
content:[{
type:'text',
text:`Ran into this error: ${message}\n\nPlease retry if you think this is a transient or recoverable error.`,