import test from 'node:test'; import assert from 'node:assert/strict'; import { convertOpenAIRequestToAnthropic } from '../../src/format/openai-compat.js'; test('assistant tool_calls and tool results convert to Anthropic blocks', () => { const converted = convertOpenAIRequestToAnthropic({ model: 'gemini-3.5-flash-low', messages: [ { role: 'user', content: 'weather?' }, { role: 'assistant', content: null, tool_calls: [{ id: 'call_weather', type: 'function', function: { name: 'get_weather', arguments: '{"city":"Delhi"}' } }] }, { role: 'tool', tool_call_id: 'call_weather', content: '{"temperature":32}' } ], tools: [{ type: 'function', function: { name: 'get_weather', description: 'Get weather', parameters: { type: 'object', properties: { city: { type: 'string' } }, required: ['city'] } } }] }); assert.equal(converted.messages[1].content[0].type, 'tool_use'); assert.deepEqual(converted.messages[1].content[0].input, { city: 'Delhi' }); assert.equal(converted.messages[2].content[0].name, 'get_weather'); }); test('OpenAI web_search tool becomes built-in googleSearch', () => { const converted = convertOpenAIRequestToAnthropic({ model: 'gemini-3.5-flash-low', messages: [{ role: 'user', content: 'Find current information.' }], tools: [{ type: 'web_search' }] }); assert.deepEqual(converted.tools, [{ googleSearch: {} }]); });