From 15d8e4ff9f4b92cbd320b44e06630721d653a4f6 Mon Sep 17 00:00:00 2001 From: Danielle Maywood Date: Thu, 16 Apr 2026 17:25:34 +0100 Subject: [PATCH] feat: accept xhigh effort for Anthropic (#24439) --- coderd/x/chatd/chatprovider/chatprovider.go | 1 + coderd/x/chatd/chatprovider/chatprovider_test.go | 6 ++++++ codersdk/chats.go | 2 +- docs/ai-coder/agents/models.md | 8 ++++---- go.mod | 5 +++-- go.sum | 4 ++-- site/src/api/chatModelOptionsGenerated.json | 2 +- .../ChatModelAdminPanel/modelConfigFormLogic.test.ts | 11 +++++++++++ 8 files changed, 29 insertions(+), 10 deletions(-) diff --git a/coderd/x/chatd/chatprovider/chatprovider.go b/coderd/x/chatd/chatprovider/chatprovider.go index 0c3f84cf0b..af106cd5f5 100644 --- a/coderd/x/chatd/chatprovider/chatprovider.go +++ b/coderd/x/chatd/chatprovider/chatprovider.go @@ -663,6 +663,7 @@ func ReasoningEffortFromChat(provider string, value *string) *string { string(fantasyanthropic.EffortLow), string(fantasyanthropic.EffortMedium), string(fantasyanthropic.EffortHigh), + string(fantasyanthropic.EffortXHigh), string(fantasyanthropic.EffortMax), ) case fantasyopenrouter.Name: diff --git a/coderd/x/chatd/chatprovider/chatprovider_test.go b/coderd/x/chatd/chatprovider/chatprovider_test.go index fa2a6a1e03..e762491ee7 100644 --- a/coderd/x/chatd/chatprovider/chatprovider_test.go +++ b/coderd/x/chatd/chatprovider/chatprovider_test.go @@ -208,6 +208,12 @@ func TestReasoningEffortFromChat(t *testing.T) { input: ptr.Ref("max"), want: ptr.Ref(string(fantasyanthropic.EffortMax)), }, + { + name: "AnthropicXHighEffort", + provider: "anthropic", + input: ptr.Ref("xhigh"), + want: ptr.Ref(string(fantasyanthropic.EffortXHigh)), + }, { name: "OpenRouterEffort", provider: "openrouter", diff --git a/codersdk/chats.go b/codersdk/chats.go index d738cbe24b..d3b5d53e04 100644 --- a/codersdk/chats.go +++ b/codersdk/chats.go @@ -925,7 +925,7 @@ type ChatModelAnthropicThinkingOptions struct { type ChatModelAnthropicProviderOptions struct { SendReasoning *bool `json:"send_reasoning,omitempty" description:"Whether to include reasoning content in the response"` Thinking *ChatModelAnthropicThinkingOptions `json:"thinking,omitempty" description:"Configuration for extended thinking"` - Effort *string `json:"effort,omitempty" label:"Reasoning Effort" description:"Controls the level of reasoning effort" enum:"low,medium,high,max"` + Effort *string `json:"effort,omitempty" label:"Reasoning Effort" description:"Controls the level of reasoning effort" enum:"low,medium,high,xhigh,max"` DisableParallelToolUse *bool `json:"disable_parallel_tool_use,omitempty" description:"Whether to disable parallel tool execution"` WebSearchEnabled *bool `json:"web_search_enabled,omitempty" description:"Enable Anthropic web search tool for grounding responses with real-time information"` AllowedDomains []string `json:"allowed_domains,omitempty" label:"Web Search: Allowed Domains" description:"Restrict web search to these domains (cannot be used with blocked_domains)"` diff --git a/docs/ai-coder/agents/models.md b/docs/ai-coder/agents/models.md index 52d6976699..7f37657fb6 100644 --- a/docs/ai-coder/agents/models.md +++ b/docs/ai-coder/agents/models.md @@ -160,10 +160,10 @@ fields appear dynamically in the admin UI when you select a provider. #### Anthropic -| Option | Description | -|------------------------|---------------------------------------------------------| -| Thinking Budget Tokens | Maximum tokens allocated for extended thinking. | -| Effort | Thinking effort level (`low`, `medium`, `high`, `max`). | +| Option | Description | +|------------------------|------------------------------------------------------------------| +| Thinking Budget Tokens | Maximum tokens allocated for extended thinking. | +| Effort | Thinking effort level (`low`, `medium`, `high`, `xhigh`, `max`). | #### OpenAI diff --git a/go.mod b/go.mod index f9dd04d8bd..a108775354 100644 --- a/go.mod +++ b/go.mod @@ -82,8 +82,9 @@ replace github.com/spf13/afero => github.com/aslilac/afero v0.0.0-20250403163713 // 3) ibetitsmike/fantasy#4 — skip ephemeral replay items when store=false // 4) (anthropic-sdk-go) dannykopping's appendCompact performance fixes // 5) (anthropic-sdk-go) DirectEncoder to eliminate nested MarshalJSON allocation chain -// See: https://github.com/coder/fantasy/commits/190272ce52f0 -replace charm.land/fantasy => github.com/coder/fantasy v0.0.0-20260415162245-190272ce52f0 +// 6) Anthropic EffortXHigh constant for Claude Opus 4.7 +// See: https://github.com/coder/fantasy/commits/959aa39579d2 +replace charm.land/fantasy => github.com/coder/fantasy v0.0.0-20260416152503-959aa39579d2 // coder/coder uses a fork of charmbracelet's fork of the Anthropic Go SDK with some // additional performance improvements. diff --git a/go.sum b/go.sum index 2391296fda..e67ef75e7d 100644 --- a/go.sum +++ b/go.sum @@ -324,8 +324,8 @@ github.com/coder/bubbletea v1.2.2-0.20241212190825-007a1cdb2c41 h1:SBN/DA63+ZHwu github.com/coder/bubbletea v1.2.2-0.20241212190825-007a1cdb2c41/go.mod h1:I9ULxr64UaOSUv7hcb3nX4kowodJCVS7vt7VVJk/kW4= github.com/coder/clistat v1.2.1 h1:P9/10njXMyj5cWzIU5wkRsSy5LVQH49+tcGMsAgWX0w= github.com/coder/clistat v1.2.1/go.mod h1:m7SC0uj88eEERgvF8Kn6+w6XF21BeSr+15f7GoLAw0A= -github.com/coder/fantasy v0.0.0-20260415162245-190272ce52f0 h1:qv8PhuP2tbbR/CR3qnbLWwf+zn/nD+8LcQMWrktxZcQ= -github.com/coder/fantasy v0.0.0-20260415162245-190272ce52f0/go.mod h1:wZ0e3lEPqrM0XiIdAUQLvMKCLYhc3gi96MRX2wjbX44= +github.com/coder/fantasy v0.0.0-20260416152503-959aa39579d2 h1:bZoww6da3tFbiYHLgIZuRNTMgsiQDSgblDMSOSmmlzE= +github.com/coder/fantasy v0.0.0-20260416152503-959aa39579d2/go.mod h1:wZ0e3lEPqrM0XiIdAUQLvMKCLYhc3gi96MRX2wjbX44= github.com/coder/flog v1.1.0 h1:kbAes1ai8fIS5OeV+QAnKBQE22ty1jRF/mcAwHpLBa4= github.com/coder/flog v1.1.0/go.mod h1:UQlQvrkJBvnRGo69Le8E24Tcl5SJleAAR7gYEHzAmdQ= github.com/coder/go-httpstat v0.0.0-20230801153223-321c88088322 h1:m0lPZjlQ7vdVpRBPKfYIFlmgevoTkBxB10wv6l2gOaU= diff --git a/site/src/api/chatModelOptionsGenerated.json b/site/src/api/chatModelOptionsGenerated.json index 8abb65ead6..8af34d6d2c 100644 --- a/site/src/api/chatModelOptionsGenerated.json +++ b/site/src/api/chatModelOptionsGenerated.json @@ -109,7 +109,7 @@ "description": "Controls the level of reasoning effort", "label": "Reasoning Effort", "required": false, - "enum": ["low", "medium", "high", "max"], + "enum": ["low", "medium", "high", "xhigh", "max"], "input_type": "select" }, { diff --git a/site/src/pages/AgentsPage/components/ChatModelAdminPanel/modelConfigFormLogic.test.ts b/site/src/pages/AgentsPage/components/ChatModelAdminPanel/modelConfigFormLogic.test.ts index 7f7b77aff1..aef8ae351b 100644 --- a/site/src/pages/AgentsPage/components/ChatModelAdminPanel/modelConfigFormLogic.test.ts +++ b/site/src/pages/AgentsPage/components/ChatModelAdminPanel/modelConfigFormLogic.test.ts @@ -753,6 +753,17 @@ describe("buildModelConfigFromForm", () => { expect(anthropic.disable_parallel_tool_use).toBe(true); }); + it("accepts xhigh for Anthropic effort", () => { + const result = buildModelConfigFromForm( + "anthropic", + formWith({ anthropic: { effort: "xhigh" } }), + ); + expect(result.fieldErrors).toEqual({}); + const anthropic = result.modelConfig?.provider_options + ?.anthropic as Record; + expect(anthropic.effort).toBe("xhigh"); + }); + it("reports error for invalid Anthropic effort option", () => { const result = buildModelConfigFromForm( "anthropic",