Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions coderd/database/db2sdk/db2sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,10 @@ func Chat(c database.Chat, diffStatus *database.ChatDiffStatus, files []database
if c.LastTurnSummary.Valid {
chat.LastTurnSummary = &c.LastTurnSummary.String
}
if c.LastReasoningEffort.Valid {
lastReasoningEffort := c.LastReasoningEffort.String
chat.LastReasoningEffort = &lastReasoningEffort
}
if c.PlanMode.Valid {
chat.PlanMode = codersdk.ChatPlanMode(c.PlanMode.ChatPlanMode)
}
Expand Down
49 changes: 25 additions & 24 deletions coderd/database/db2sdk/db2sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,30 +696,31 @@ func TestChat_AllFieldsPopulated(t *testing.T) {
require.NoError(t, err)

input := database.Chat{
ID: uuid.New(),
OwnerID: uuid.New(),
OwnerUsername: "owner-username",
OwnerName: "Owner Name",
OrganizationID: uuid.New(),
WorkspaceID: uuid.NullUUID{UUID: uuid.New(), Valid: true},
BuildID: uuid.NullUUID{UUID: uuid.New(), Valid: true},
AgentID: uuid.NullUUID{UUID: uuid.New(), Valid: true},
ParentChatID: uuid.NullUUID{UUID: uuid.New(), Valid: true},
RootChatID: uuid.NullUUID{UUID: uuid.New(), Valid: true},
LastModelConfigID: uuid.New(),
Title: "all-fields-test",
Status: database.ChatStatusRunning,
ClientType: database.ChatClientTypeUi,
LastError: pqtype.NullRawMessage{RawMessage: lastErrorRaw, Valid: true},
LastTurnSummary: sql.NullString{String: "turn completed", Valid: true},
CreatedAt: now,
UpdatedAt: now,
Archived: true,
UserACL: database.ChatACL{uuid.NewString(): database.ChatACLEntry{}},
PinOrder: 1,
PlanMode: database.NullChatPlanMode{ChatPlanMode: database.ChatPlanModePlan, Valid: true},
MCPServerIDs: []uuid.UUID{uuid.New()},
Labels: database.StringMap{"env": "prod"},
ID: uuid.New(),
OwnerID: uuid.New(),
OwnerUsername: "owner-username",
OwnerName: "Owner Name",
OrganizationID: uuid.New(),
WorkspaceID: uuid.NullUUID{UUID: uuid.New(), Valid: true},
BuildID: uuid.NullUUID{UUID: uuid.New(), Valid: true},
AgentID: uuid.NullUUID{UUID: uuid.New(), Valid: true},
ParentChatID: uuid.NullUUID{UUID: uuid.New(), Valid: true},
RootChatID: uuid.NullUUID{UUID: uuid.New(), Valid: true},
LastModelConfigID: uuid.New(),
LastReasoningEffort: sql.NullString{String: "high", Valid: true},
Title: "all-fields-test",
Status: database.ChatStatusRunning,
ClientType: database.ChatClientTypeUi,
LastError: pqtype.NullRawMessage{RawMessage: lastErrorRaw, Valid: true},
LastTurnSummary: sql.NullString{String: "turn completed", Valid: true},
CreatedAt: now,
UpdatedAt: now,
Archived: true,
UserACL: database.ChatACL{uuid.NewString(): database.ChatACLEntry{}},
PinOrder: 1,
PlanMode: database.NullChatPlanMode{ChatPlanMode: database.ChatPlanModePlan, Valid: true},
MCPServerIDs: []uuid.UUID{uuid.New()},
Labels: database.StringMap{"env": "prod"},
DynamicTools: pqtype.NullRawMessage{
RawMessage: json.RawMessage(`[{"name":"tool1","description":"test tool","inputSchema":{"type":"object"}}]`),
Valid: true,
Expand Down
1 change: 1 addition & 0 deletions coderd/database/dbgen/dbgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func ChatMessage(t testing.TB, db database.Store, seed database.ChatMessage) dat
CreatedBy: []uuid.UUID{seed.CreatedBy.UUID},
APIKeyID: []string{apiKeyID},
ModelConfigID: []uuid.UUID{seed.ModelConfigID.UUID},
ReasoningEffort: []string{seed.ReasoningEffort.String},
Role: []database.ChatMessageRole{role},
Content: []string{content},
ContentVersion: []int16{takeFirst(seed.ContentVersion, chatprompt.CurrentContentVersion)},
Expand Down
14 changes: 12 additions & 2 deletions coderd/database/dump.sql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

136 changes: 136 additions & 0 deletions coderd/database/migrations/000537_chat_reasoning_effort.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
DROP VIEW IF EXISTS chats_expanded;

-- Move the reasoning effort default back to the provider-appropriate
-- legacy path. Rows whose provider cannot be determined just lose the
-- reasoning_effort key in the cleanup below.
UPDATE chat_model_configs cmc
SET options = (cmc.options - 'reasoning_effort') || jsonb_build_object(
'provider_options',
COALESCE(cmc.options -> 'provider_options', '{}'::jsonb) || jsonb_build_object(
'openai',
COALESCE(cmc.options #> '{provider_options,openai}', '{}'::jsonb) ||
jsonb_build_object('reasoning_effort', cmc.options #> '{reasoning_effort,default}')
)
)
FROM ai_providers ap
WHERE ap.id = cmc.ai_provider_id
AND ap.type IN ('openai', 'azure')
AND cmc.options #>> '{reasoning_effort,default}' IS NOT NULL;

UPDATE chat_model_configs cmc
SET options = (cmc.options - 'reasoning_effort') || jsonb_build_object(
'provider_options',
COALESCE(cmc.options -> 'provider_options', '{}'::jsonb) || jsonb_build_object(
'anthropic',
COALESCE(cmc.options #> '{provider_options,anthropic}', '{}'::jsonb) ||
jsonb_build_object('effort', cmc.options #> '{reasoning_effort,default}')
)
)
FROM ai_providers ap
WHERE ap.id = cmc.ai_provider_id
AND ap.type IN ('anthropic', 'bedrock')
AND cmc.options #>> '{reasoning_effort,default}' IS NOT NULL;

UPDATE chat_model_configs cmc
SET options = (cmc.options - 'reasoning_effort') || jsonb_build_object(
'provider_options',
COALESCE(cmc.options -> 'provider_options', '{}'::jsonb) || jsonb_build_object(
'openaicompat',
COALESCE(cmc.options #> '{provider_options,openaicompat}', '{}'::jsonb) ||
jsonb_build_object('reasoning_effort', cmc.options #> '{reasoning_effort,default}')
)
)
FROM ai_providers ap
WHERE ap.id = cmc.ai_provider_id
AND ap.type = 'openai-compat'
AND cmc.options #>> '{reasoning_effort,default}' IS NOT NULL;

UPDATE chat_model_configs cmc
SET options = (cmc.options - 'reasoning_effort') || jsonb_build_object(
'provider_options',
COALESCE(cmc.options -> 'provider_options', '{}'::jsonb) || jsonb_build_object(
'openrouter',
COALESCE(cmc.options #> '{provider_options,openrouter}', '{}'::jsonb) || jsonb_build_object(
'reasoning',
COALESCE(cmc.options #> '{provider_options,openrouter,reasoning}', '{}'::jsonb) ||
jsonb_build_object('effort', cmc.options #> '{reasoning_effort,default}')
)
)
)
FROM ai_providers ap
WHERE ap.id = cmc.ai_provider_id
AND ap.type = 'openrouter'
AND cmc.options #>> '{reasoning_effort,default}' IS NOT NULL;

UPDATE chat_model_configs cmc
SET options = (cmc.options - 'reasoning_effort') || jsonb_build_object(
'provider_options',
COALESCE(cmc.options -> 'provider_options', '{}'::jsonb) || jsonb_build_object(
'vercel',
COALESCE(cmc.options #> '{provider_options,vercel}', '{}'::jsonb) || jsonb_build_object(
'reasoning',
COALESCE(cmc.options #> '{provider_options,vercel,reasoning}', '{}'::jsonb) ||
jsonb_build_object('effort', cmc.options #> '{reasoning_effort,default}')
)
)
)
FROM ai_providers ap
WHERE ap.id = cmc.ai_provider_id
AND ap.type = 'vercel'
AND cmc.options #>> '{reasoning_effort,default}' IS NOT NULL;

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;

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)));
Loading
Loading