-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: add configurable reasoning effort to Coder agents #26974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8f4025c
feat: replace fixed per-provider reasoning effort with per-model defa…
DanielleMaywood e737c0a
feat(site): surface reasoning effort configuration on the models page…
DanielleMaywood 6038eb2
feat: add per-turn reasoning effort selection to chat API (#26975)
DanielleMaywood f7ab024
Merge remote-tracking branch 'origin/main' into dm/reasoning-effort-1…
DanielleMaywood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
coderd/database/migrations/000542_chat_reasoning_effort.down.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| DROP VIEW IF EXISTS chats_expanded; | ||
|
|
||
| -- The up migration left the legacy per-provider effort keys in | ||
| -- place, so removing the reasoning_effort key restores the previous | ||
| -- state exactly. | ||
| UPDATE chat_model_configs | ||
| SET options = options - 'reasoning_effort' | ||
| WHERE options ? 'reasoning_effort'; | ||
|
|
||
| ALTER TABLE chats DROP COLUMN last_reasoning_effort; | ||
| ALTER TABLE chat_messages DROP COLUMN reasoning_effort; | ||
| ALTER TABLE chat_queued_messages DROP COLUMN reasoning_effort; | ||
| DROP TYPE chat_reasoning_effort; | ||
|
|
||
| CREATE VIEW chats_expanded AS | ||
| SELECT c.id, | ||
| c.owner_id, | ||
| c.workspace_id, | ||
| c.title, | ||
| c.status, | ||
| c.worker_id, | ||
| c.started_at, | ||
| c.heartbeat_at, | ||
| c.created_at, | ||
| c.updated_at, | ||
| c.parent_chat_id, | ||
| c.root_chat_id, | ||
| c.last_model_config_id, | ||
| c.archived, | ||
| c.last_error, | ||
| c.mode, | ||
| c.mcp_server_ids, | ||
| c.labels, | ||
| c.build_id, | ||
| c.agent_id, | ||
| c.pin_order, | ||
| c.last_read_message_id, | ||
| c.dynamic_tools, | ||
| c.organization_id, | ||
| c.plan_mode, | ||
| c.client_type, | ||
| c.last_turn_summary, | ||
| c.snapshot_version, | ||
| c.history_version, | ||
| c.queue_version, | ||
| c.generation_attempt, | ||
| c.retry_state, | ||
| c.retry_state_version, | ||
| c.runner_id, | ||
| c.requires_action_deadline_at, | ||
| COALESCE(root.user_acl, c.user_acl) AS user_acl, | ||
| COALESCE(root.group_acl, c.group_acl) AS group_acl, | ||
| owner.username AS owner_username, | ||
| owner.name AS owner_name, | ||
| c.context_aggregate_hash, | ||
| c.context_dirty_since, | ||
| c.context_dirty_resources, | ||
| c.context_error | ||
| FROM ((chats c | ||
| LEFT JOIN chats root ON ((root.id = COALESCE(c.root_chat_id, c.parent_chat_id)))) | ||
| JOIN visible_users owner ON ((owner.id = c.owner_id))); |
88 changes: 88 additions & 0 deletions
88
coderd/database/migrations/000542_chat_reasoning_effort.up.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| -- Per-turn reasoning effort. The chats_expanded view must be dropped | ||
| -- and recreated so the new chats column can appear in its column list. | ||
| DROP VIEW IF EXISTS chats_expanded; | ||
|
|
||
| CREATE TYPE chat_reasoning_effort AS ENUM ('none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'); | ||
|
|
||
| ALTER TABLE chats ADD COLUMN last_reasoning_effort chat_reasoning_effort; | ||
| ALTER TABLE chat_messages ADD COLUMN reasoning_effort chat_reasoning_effort; | ||
| ALTER TABLE chat_queued_messages ADD COLUMN reasoning_effort chat_reasoning_effort; | ||
|
|
||
| COMMENT ON COLUMN chats.last_reasoning_effort IS 'Stores the most recent message effort once per-turn selection is wired.'; | ||
| COMMENT ON COLUMN chat_messages.reasoning_effort IS 'Stores the selected effort for the turn triggered by this message.'; | ||
| COMMENT ON COLUMN chat_queued_messages.reasoning_effort IS 'Stores the selected effort until the queued row is promoted.'; | ||
|
|
||
| CREATE VIEW chats_expanded AS | ||
| SELECT c.id, | ||
| c.owner_id, | ||
| c.workspace_id, | ||
| c.title, | ||
| c.status, | ||
| c.worker_id, | ||
| c.started_at, | ||
| c.heartbeat_at, | ||
| c.created_at, | ||
| c.updated_at, | ||
| c.parent_chat_id, | ||
| c.root_chat_id, | ||
| c.last_model_config_id, | ||
| c.last_reasoning_effort, | ||
| c.archived, | ||
| c.last_error, | ||
| c.mode, | ||
| c.mcp_server_ids, | ||
| c.labels, | ||
| c.build_id, | ||
| c.agent_id, | ||
| c.pin_order, | ||
| c.last_read_message_id, | ||
| c.dynamic_tools, | ||
| c.organization_id, | ||
| c.plan_mode, | ||
| c.client_type, | ||
| c.last_turn_summary, | ||
| c.snapshot_version, | ||
| c.history_version, | ||
| c.queue_version, | ||
| c.generation_attempt, | ||
| c.retry_state, | ||
| c.retry_state_version, | ||
| c.runner_id, | ||
| c.requires_action_deadline_at, | ||
| COALESCE(root.user_acl, c.user_acl) AS user_acl, | ||
| COALESCE(root.group_acl, c.group_acl) AS group_acl, | ||
| owner.username AS owner_username, | ||
| owner.name AS owner_name, | ||
| c.context_aggregate_hash, | ||
| c.context_dirty_since, | ||
| c.context_dirty_resources, | ||
| c.context_error | ||
| FROM ((chats c | ||
| LEFT JOIN chats root ON ((root.id = COALESCE(c.root_chat_id, c.parent_chat_id)))) | ||
| JOIN visible_users owner ON ((owner.id = c.owner_id))); | ||
|
|
||
| -- Copy legacy per-provider effort values to top-level | ||
| -- reasoning_effort. Preserve legacy keys so the down migration can | ||
| -- restore the original options shape. | ||
| UPDATE chat_model_configs | ||
| SET options = options || jsonb_build_object( | ||
| 'reasoning_effort', | ||
| jsonb_build_object('default', legacy.effort, 'max', legacy.effort) | ||
| ) | ||
| FROM ( | ||
| SELECT | ||
| id, | ||
| COALESCE( | ||
| NULLIF(lower(trim(options #>> '{provider_options,openai,reasoning_effort}')), ''), | ||
| NULLIF(lower(trim(options #>> '{provider_options,azure,reasoning_effort}')), ''), | ||
| NULLIF(lower(trim(options #>> '{provider_options,anthropic,effort}')), ''), | ||
| NULLIF(lower(trim(options #>> '{provider_options,bedrock,effort}')), ''), | ||
| NULLIF(lower(trim(options #>> '{provider_options,openaicompat,reasoning_effort}')), ''), | ||
| NULLIF(lower(trim(options #>> '{provider_options,openrouter,reasoning,effort}')), ''), | ||
| NULLIF(lower(trim(options #>> '{provider_options,vercel,reasoning,effort}')), '') | ||
|
DanielleMaywood marked this conversation as resolved.
|
||
| ) AS effort | ||
| FROM chat_model_configs | ||
| ) legacy | ||
| WHERE chat_model_configs.id = legacy.id | ||
| AND legacy.effort IS NOT NULL | ||
| AND legacy.effort IN ('none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.