fix(tooling): surface non-executable tool-use warnings
This commit is contained in:
@@ -69,4 +69,40 @@ describe('OpenAIClient OAuth (Codex)', () => {
|
||||
expect(resp.content).toBe('hello');
|
||||
expect(resp.usage).toEqual({ inputTokens: 2, outputTokens: 2 });
|
||||
});
|
||||
|
||||
it('adds provider warning when tools are requested in OAuth mode', async () => {
|
||||
const sse = makeSse([
|
||||
{ event: 'response.output_text.delta', data: { type: 'response.output_text.delta', delta: 'result body' } },
|
||||
{ event: 'response.completed', data: { type: 'response.completed', response: { usage: { input_tokens: 1, output_tokens: 1 } } } },
|
||||
]);
|
||||
|
||||
globalThis.fetch = vi.fn(async () => {
|
||||
const stream = new ReadableStream({
|
||||
start(controller) {
|
||||
controller.enqueue(new TextEncoder().encode(sse));
|
||||
controller.close();
|
||||
},
|
||||
});
|
||||
return new Response(stream, { status: 200 });
|
||||
}) as typeof fetch;
|
||||
|
||||
const client = new OpenAIClient({ model: 'gpt-5.3-codex', useOAuth: true });
|
||||
const resp = await client.chat({
|
||||
system: 'You are helpful.',
|
||||
messages: [{ role: 'user', content: 'use tools' }],
|
||||
tools: [{
|
||||
name: 'gmail_read',
|
||||
description: 'Read Gmail message',
|
||||
input_schema: {
|
||||
type: 'object',
|
||||
properties: { id: { type: 'string' } },
|
||||
required: ['id'],
|
||||
},
|
||||
}],
|
||||
});
|
||||
|
||||
expect(resp.content).toContain('[provider-warning] OpenAI OAuth (Codex backend) does not support tool execution in Flynn yet.');
|
||||
expect(resp.content).toContain('Requested tools were not sent to the provider');
|
||||
expect(resp.content).toContain('result body');
|
||||
});
|
||||
});
|
||||
|
||||
+11
-1
@@ -213,8 +213,18 @@ export class OpenAIClient implements ModelClient {
|
||||
}
|
||||
}
|
||||
|
||||
const toolsRequested = Boolean(request.tools && request.tools.length > 0);
|
||||
const content = toolsRequested
|
||||
? [
|
||||
'[provider-warning] OpenAI OAuth (Codex backend) does not support tool execution in Flynn yet.',
|
||||
'Requested tools were not sent to the provider, so any textual tool_use output is not executable.',
|
||||
'',
|
||||
outputText,
|
||||
].join('\n')
|
||||
: outputText;
|
||||
|
||||
return {
|
||||
content: outputText,
|
||||
content,
|
||||
stopReason: 'end_turn',
|
||||
usage: usage ?? { inputTokens: 0, outputTokens: 0 },
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user