Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

fix: honor GPT-6.1 and Opus 5.5 contracts

Emre Sokullucc919d6b9838
diff --git a/src/chrome/src/providers/anthropic.js b/src/chrome/src/providers/anthropic.js
index 4d2dbd599..083735366 100644
--- a/src/chrome/src/providers/anthropic.js
+++ b/src/chrome/src/providers/anthropic.js
@@ -45,8 +45,14 @@ export class AnthropicProvider extends BaseLLMProvider {
_prepareRequestBody(body, options = {}, _stream = false) {
const prepared = this._mergeConfiguredRequestBody(body, options);
- const thinkingType = prepared.thinking?.type;
- if (thinkingType === 'disabled') {
+ const opus55 = /^claude-opus-5-5(?:$|[-_.@])/.test(String(this.model || '').toLowerCase());
+ let thinkingType = prepared.thinking?.type;
+ if (opus55 && ['disabled', 'enabled'].includes(thinkingType)) {
+ // Opus 5.5 has mandatory adaptive thinking; effort controls its budget.
+ delete prepared.thinking;
+ prepared.output_config = { ...prepared.output_config, effort: 'low' };
+ thinkingType = undefined;
+ } else if (thinkingType === 'disabled') {
// A per-call disable must fully replace configured adaptive/manual fields.
prepared.thinking = { type: 'disabled' };
} else if (thinkingType === 'adaptive') {
@@ -54,7 +60,10 @@ export class AnthropicProvider extends BaseLLMProvider {
}
const forcedToolChoice = ['any', 'tool'].includes(prepared.tool_choice?.type);
- if (thinkingType === 'enabled' && forcedToolChoice) {
+ if (opus55 && forcedToolChoice) {
+ // Opus 5.5 accepts only auto or none tool choice.
+ prepared.tool_choice = { type: 'auto' };
+ } else if (thinkingType === 'enabled' && forcedToolChoice) {
// Manual extended thinking rejects forced tool choice. Preserve the
// agent's explicit tool contract and disable thinking for this call.
delete prepared.thinking;
@@ -105,6 +114,9 @@ export class AnthropicProvider extends BaseLLMProvider {
_convertToolChoice(toolChoice) {
if (!toolChoice || toolChoice === 'auto') return undefined;
+ if (/^claude-opus-5-5(?:$|[-_.@])/.test(String(this.model || '').toLowerCase())) {
+ return { type: 'auto' };
+ }
if (toolChoice === 'required') return { type: 'any' };
const name = toolChoice?.function?.name || toolChoice?.name;
if (name) return { type: 'tool', name };
diff --git a/src/chrome/src/providers/openai.js b/src/chrome/src/providers/openai.js
index 11cc8650d..c31f61fc8 100644
--- a/src/chrome/src/providers/openai.js
+++ b/src/chrome/src/providers/openai.js
@@ -762,6 +762,13 @@ export class OpenAICompatibleProvider extends BaseLLMProvider {
if (/^gpt-5-pro(?:$|-\d{4}-\d{2}-\d{2}$)/.test(normalizedModel)) {
// GPT-5 Pro only accepts high reasoning effort.
body.reasoning.effort = 'high';
+ } else if (
+ /^gpt-6\.1-sol(?:$|[-_.:])/.test(normalizedModel)
+ && !['low', 'medium', 'high', 'xhigh', 'max'].includes(body.reasoning.effort)
+ ) {
+ // GPT-6.1 Sol rejects `none` and `minimal`, including the compact
+ // classifier override used by plannerRequestBody.
+ body.reasoning.effort = 'low';
} else if (
/^gpt-5\.(?:2|4|5)-pro(?:$|-\d{4}-\d{2}-\d{2}$)/.test(normalizedModel)
&& !['medium', 'high', 'xhigh'].includes(body.reasoning.effort)
diff --git a/src/firefox/src/providers/anthropic.js b/src/firefox/src/providers/anthropic.js
index f54779e7f..8916b2859 100644
--- a/src/firefox/src/providers/anthropic.js
+++ b/src/firefox/src/providers/anthropic.js
@@ -44,8 +44,14 @@ export class AnthropicProvider extends BaseLLMProvider {
_prepareRequestBody(body, options = {}, _stream = false) {
const prepared = this._mergeConfiguredRequestBody(body, options);
- const thinkingType = prepared.thinking?.type;
- if (thinkingType === 'disabled') {
+ const opus55 = /^claude-opus-5-5(?:$|[-_.@])/.test(String(this.model || '').toLowerCase());
+ let thinkingType = prepared.thinking?.type;
+ if (opus55 && ['disabled', 'enabled'].includes(thinkingType)) {
+ // Opus 5.5 has mandatory adaptive thinking; effort controls its budget.
+ delete prepared.thinking;
+ prepared.output_config = { ...prepared.output_config, effort: 'low' };
+ thinkingType = undefined;
+ } else if (thinkingType === 'disabled') {
// A per-call disable must fully replace configured adaptive/manual fields.
prepared.thinking = { type: 'disabled' };
} else if (thinkingType === 'adaptive') {
@@ -53,7 +59,10 @@ export class AnthropicProvider extends BaseLLMProvider {
}
const forcedToolChoice = ['any', 'tool'].includes(prepared.tool_choice?.type);
- if (thinkingType === 'enabled' && forcedToolChoice) {
+ if (opus55 && forcedToolChoice) {
+ // Opus 5.5 accepts only auto or none tool choice.
+ prepared.tool_choice = { type: 'auto' };
+ } else if (thinkingType === 'enabled' && forcedToolChoice) {
// Manual extended thinking rejects forced tool choice. Preserve the
// agent's explicit tool contract and disable thinking for this call.
delete prepared.thinking;
@@ -104,6 +113,9 @@ export class AnthropicProvider extends BaseLLMProvider {
_convertToolChoice(toolChoice) {
if (!toolChoice || toolChoice === 'auto') return undefined;
+ if (/^claude-opus-5-5(?:$|[-_.@])/.test(String(this.model || '').toLowerCase())) {
+ return { type: 'auto' };
+ }
if (toolChoice === 'required') return { type: 'any' };
const name = toolChoice?.function?.name || toolChoice?.name;
if (name) return { type: 'tool', name };
diff --git a/src/firefox/src/providers/openai.js b/src/firefox/src/providers/openai.js
index 253b69e7b..02934bc73 100644
--- a/src/firefox/src/providers/openai.js
+++ b/src/firefox/src/providers/openai.js
@@ -779,6 +779,13 @@ export class OpenAICompatibleProvider extends BaseLLMProvider {
if (/^gpt-5-pro(?:$|-\d{4}-\d{2}-\d{2}$)/.test(normalizedModel)) {
// GPT-5 Pro only accepts high reasoning effort.
body.reasoning.effort = 'high';
+ } else if (
+ /^gpt-6\.1-sol(?:$|[-_.:])/.test(normalizedModel)
+ && !['low', 'medium', 'high', 'xhigh', 'max'].includes(body.reasoning.effort)
+ ) {
+ // GPT-6.1 Sol rejects `none` and `minimal`, including the compact
+ // classifier override used by plannerRequestBody.
+ body.reasoning.effort = 'low';
} else if (
/^gpt-5\.(?:2|4|5)-pro(?:$|-\d{4}-\d{2}-\d{2}$)/.test(normalizedModel)
&& !['medium', 'high', 'xhigh'].includes(body.reasoning.effort)
diff --git a/test/run.js b/test/run.js
index 61d1be8d7..b9e0a7d0f 100644
--- a/test/run.js
+++ b/test/run.js
@@ -75132,6 +75132,54 @@ test('Anthropic and AWS Bedrock forward a required named tool choice', async ()
}
});
+test('Claude Opus 5.5 normalizes mandatory-thinking and tool-choice restrictions', async () => {
+ const tool = {
+ type: 'function',
+ function: {
+ name: 'done',
+ description: 'Finish the run.',
+ parameters: { type: 'object', properties: {} },
+ },
+ };
+ const forced = { type: 'function', function: { name: 'done' } };
+ const originalFetch = globalThis.fetch;
+ try {
+ for (const Provider of [AnthropicProviderCh, AnthropicProviderFx]) {
+ const provider = new Provider({
+ baseUrl: 'https://api.anthropic.com',
+ model: 'claude-opus-5-5',
+ apiKey: 'test-key',
+ });
+ const prepared = provider._prepareRequestBody({
+ thinking: { type: 'disabled' },
+ tool_choice: { type: 'tool', name: 'done' },
+ });
+ assert.equal(prepared.thinking, undefined, `${Provider.name}: Opus 5.5 must not disable thinking`);
+ assert.deepEqual(prepared.output_config, { effort: 'low' }, `${Provider.name}: disabled thinking must become low effort`);
+ assert.deepEqual(prepared.tool_choice, { type: 'auto' }, `${Provider.name}: Opus 5.5 must not force named tools`);
+
+ let requestBody = null;
+ globalThis.fetch = async (_url, init) => {
+ requestBody = JSON.parse(init.body);
+ return new Response(JSON.stringify({
+ content: [{ type: 'tool_use', id: 'done_1', name: 'done', input: {} }],
+ usage: { input_tokens: 1, output_tokens: 1 },
+ }), { status: 200, headers: { 'Content-Type': 'application/json' } });
+ };
+ await provider.chat([{ role: 'user', content: 'Finish.' }], {
+ tools: [tool],
+ toolChoice: forced,
+ extraBody: { thinking: { type: 'disabled' } },
+ });
+ assert.equal(requestBody.thinking, undefined, `${Provider.name}: classifier disable must not reach Opus 5.5`);
+ assert.deepEqual(requestBody.output_config, { effort: 'low' }, `${Provider.name}: classifier must set low effort`);
+ assert.deepEqual(requestBody.tool_choice, { type: 'auto' }, `${Provider.name}: forced tool request must become auto`);
+ }
+ } finally {
+ globalThis.fetch = originalFetch;
+ }
+});
+
test('AWS Bedrock provider normalizes usage and indexes parallel tool calls', () => {
for (const Provider of [AwsBedrockProviderCh, AwsBedrockProviderFx]) {
const provider = new Provider({
@@ -75340,6 +75388,16 @@ test('OpenAI reasoning and GPT-6 ids use the advertised Chat Completions contrac
assert.equal(solBody.model, 'gpt-6.1-sol');
assert.equal(solBody.max_output_tokens, 123);
assert.equal(solBody.reasoning.effort, 'medium');
+ const solPlannerBody = sol._buildResponsesBody(messages, {
+ maxTokens: 123,
+ extraBody: { reasoning: { effort: 'minimal' } },
+ }, false);
+ assert.equal(solPlannerBody.reasoning.effort, 'low', 'GPT-6.1 Sol must replace unsupported minimal effort');
+ const solDisabledBody = sol._buildResponsesBody(messages, {
+ maxTokens: 123,
+ extraBody: { reasoning: { effort: 'none' } },
+ }, false);
+ assert.equal(solDisabledBody.reasoning.effort, 'low', 'GPT-6.1 Sol must replace unsupported none effort');
for (const model of newContractModels) {
const provider = new Provider({