Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

Enable GPT-5.6 tools through chat completions

Louis Beaumont7eeffccde57c
diff --git a/packages/ai-gateway/src/providers/openai.ts b/packages/ai-gateway/src/providers/openai.ts
index af1df3789..16810448a 100644
--- a/packages/ai-gateway/src/providers/openai.ts
+++ b/packages/ai-gateway/src/providers/openai.ts
@@ -181,6 +181,17 @@ export class OpenAIProvider implements AIProvider {
(params as ChatCompletionCreateParams & { max_tokens?: number }).max_tokens = maxTokens;
}
+ private applyToolCompatibilityOptions(params: ChatCompletionCreateParams, body: RequestBody): void {
+ // GPT-5.6 accepts function tools through Chat Completions only when
+ // reasoning_effort is "none". Pi speaks the Chat Completions protocol,
+ // so preserve tool support there rather than silently cascading a Luna
+ // request to another provider. Agentic callers that need reasoning plus
+ // tools can use the Responses API directly.
+ if (body.model.toLowerCase().startsWith('gpt-5.6') && Array.isArray(body.tools) && body.tools.length > 0) {
+ (params as ChatCompletionCreateParams & { reasoning_effort?: 'none' }).reasoning_effort = 'none';
+ }
+ }
+
async createCompletion(body: RequestBody): Promise<Response> {
const messages = this.formatMessages(body.messages);
const responseFormat = this.formatResponseFormat(body.response_format);
@@ -196,6 +207,7 @@ export class OpenAIProvider implements AIProvider {
this.applyGenerationOptions(params, body);
this.applyTokenLimit(params, body);
+ this.applyToolCompatibilityOptions(params, body);
const response = await this.createWithUnsupportedParamRetry(params, (p) =>
this.client.chat.completions.create(p),
@@ -227,6 +239,7 @@ export class OpenAIProvider implements AIProvider {
this.applyGenerationOptions(params, body);
this.applyTokenLimit(params, body);
+ this.applyToolCompatibilityOptions(params, body);
const stream = (await this.createWithUnsupportedParamRetry(params, (p) =>
this.client.chat.completions.create(p as ChatCompletionCreateParams & { stream: true }),
diff --git a/packages/ai-gateway/src/test/provider-usage.unit.test.ts b/packages/ai-gateway/src/test/provider-usage.unit.test.ts
index 424cd0bef..a4b55e589 100644
--- a/packages/ai-gateway/src/test/provider-usage.unit.test.ts
+++ b/packages/ai-gateway/src/test/provider-usage.unit.test.ts
@@ -112,6 +112,26 @@ describe('OpenAIProvider usage reporting', () => {
expect(calls[0].tools).toEqual(tools);
expect(calls[0].tool_choice).toBe('required');
+ expect(calls[0].reasoning_effort).toBe('none');
+ });
+
+ it('does not disable reasoning for GPT-5.6 requests without tools', async () => {
+ async function* stream() {
+ yield { choices: [{ delta: { content: 'ok' }, finish_reason: 'stop' }] };
+ }
+ const { provider, calls } = makeOpenAIProvider(async () => {
+ const s: any = stream();
+ s.controller = { abort: () => {} };
+ return s;
+ });
+
+ await new Response(await provider.createStreamingCompletion({
+ ...body,
+ model: 'gpt-5.6-luna',
+ stream: true,
+ })).text();
+
+ expect(calls[0].reasoning_effort).toBeUndefined();
});
it('drops stream_options and retries when an OpenAI-compatible server rejects it', async () => {