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

Skip to content

Commit df1a910

Browse files
authored
chore: remove AI task support from the provisioner protocol (#28790)
Removes AI task support from the provisioner protocol: the task-related proto fields, terraform scanning for `coder_ai_task` resources, echo provisioner support, the regenerated `.pb.go` and `provisionerGenerated.ts`, and the terraform testdata that exercised them. The provisioner API version change lives in `provisionerd/proto/version.go`. **Stack context:** Coder Tasks removal stack (CODAGT-642): #28743 frontend → #28788 CLI → #28789 API → #28790 provisioner → #29084 notifications and usage → #29085 build reasons → #29086 tables → #28750 permissions. The last four PRs replace the single data-drop migration that used to live in #28750; each carries one concern and a focused migration test. **Why:** the proto fields lost their last consumer in #28789; this deletes the producer side and the wire format. **What to scrutinize:** the proto/version handling, and that `coder_ai_task` resources in existing templates are now ignored rather than errors (template imports simply no longer scan for them). **Validation:** `go build ./...`, `go test ./provisionersdk/... ./provisionerd/...`, `go test ./provisioner/terraform -run TestConvertResources`, provisioner list golden regenerated, site tsc, pre-commit hooks. **Size:** +580/-1,286 over 76 files; most files are mechanical testdata and generated-code updates. > Created by Xum (AI agent) on behalf of @ibetitsmike.
1 parent 9cd38b5 commit df1a910

77 files changed

Lines changed: 585 additions & 1291 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cli/testdata/coder_provisioner_list_--output_json.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"last_seen_at": "====[timestamp]=====",
88
"name": "test-daemon",
99
"version": "v0.0.0-devel",
10-
"api_version": "1.18",
10+
"api_version": "1.19",
1111
"provisioners": [
1212
"echo"
1313
],

docs/ai-coder/agents/tasks-to-chats-migration.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,9 @@ unused when the chat is driven by the Chats API:
436436
}
437437
```
438438

439-
> [!TIP]
440-
> You do not have to remove these resources immediately. Templates can
441-
> serve both Tasks and Chats simultaneously during a transition period.
442-
> The Tasks-specific resources are simply unused when work comes through
443-
> the Chats API.
439+
> [!IMPORTANT]
440+
> Remove the Tasks-specific Terraform when you upgrade.
441+
> Tasks and Chats can no longer run side by side: Coder no longer injects `CODER_TASK_ID` or `CODER_TASK_PROMPT`, so builds of a template that keeps the `coder_task` data source can no longer populate it.
444442
445443
See
446444
[Template Optimization](./platform-controls/template-optimization.md)

provisioner/echo/serve.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,6 @@ func (*echo) Graph(sess *provisionersdk.Session, req *proto.GraphRequest, cancel
245245
sess.ProvisionLog(log.Level, log.Output)
246246
}
247247
if complete := response.GetGraph(); complete != nil {
248-
if len(complete.AiTasks) > 0 {
249-
// These two fields are linked; if there are AI tasks, indicate that.
250-
complete.HasAiTasks = true
251-
}
252248
return complete
253249
}
254250
}
@@ -426,10 +422,8 @@ func TarWithOptions(ctx context.Context, logger slog.Logger, responses *Response
426422
responses.ProvisionPlan = []*proto.Response{{
427423
Type: &proto.Response_Plan{
428424
Plan: &proto.PlanComplete{
429-
Plan: []byte("{}"),
430-
//nolint:gosec // the number of resources will not exceed int32
431-
AiTaskCount: int32(len(g.GetAiTasks())),
432-
DailyCost: dailycost,
425+
Plan: []byte("{}"),
426+
DailyCost: dailycost,
433427
},
434428
},
435429
}}

provisioner/terraform/executor.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ func (e *executor) plan(ctx, killCtx context.Context, env, vars []string, logr l
375375
Plan: planJSON,
376376
DailyCost: state.DailyCost,
377377
ResourceReplacements: resReps,
378-
AiTaskCount: state.AITaskCount,
379378
}
380379

381380
return msg, nil

provisioner/terraform/planresources.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import (
77
)
88

99
type PlanState struct {
10-
DailyCost int32
11-
AITaskCount int32
10+
DailyCost int32
1211
}
1312

1413
func planModules(plan *tfjson.Plan) []*tfjson.StateModule {
@@ -35,19 +34,15 @@ func ConvertPlanState(plan *tfjson.Plan) (*PlanState, error) {
3534
modules := planModules(plan)
3635

3736
var dailyCost int32
38-
var aiTaskCount int32
3937
for _, mod := range modules {
4038
err := forEachResource(mod, func(res *tfjson.StateResource) error {
41-
switch res.Type {
42-
case "coder_metadata":
39+
if res.Type == "coder_metadata" {
4340
var attrs resourceMetadataAttributes
4441
err := mapstructure.Decode(res.AttributeValues, &attrs)
4542
if err != nil {
4643
return xerrors.Errorf("decode metadata attributes: %w", err)
4744
}
4845
dailyCost += attrs.DailyCost
49-
case "coder_ai_task":
50-
aiTaskCount++
5146
}
5247
return nil
5348
})
@@ -57,8 +52,7 @@ func ConvertPlanState(plan *tfjson.Plan) (*PlanState, error) {
5752
}
5853

5954
return &PlanState{
60-
DailyCost: dailyCost,
61-
AITaskCount: aiTaskCount,
55+
DailyCost: dailyCost,
6256
}, nil
6357
}
6458

provisioner/terraform/provision.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,6 @@ func (s *server) Graph(
275275
Parameters: state.Parameters,
276276
ExternalAuthProviders: state.ExternalAuthProviders,
277277
Presets: state.Presets,
278-
HasAiTasks: state.HasAITasks,
279-
AiTasks: state.AITasks,
280278
HasExternalAgents: state.HasExternalAgents,
281279
}
282280
}
@@ -379,8 +377,6 @@ func provisionEnv(
379377
"CODER_WORKSPACE_TEMPLATE_NAME="+metadata.GetTemplateName(),
380378
"CODER_WORKSPACE_TEMPLATE_VERSION="+metadata.GetTemplateVersion(),
381379
"CODER_WORKSPACE_BUILD_ID="+metadata.GetWorkspaceBuildId(),
382-
"CODER_TASK_ID="+metadata.GetTaskId(),
383-
"CODER_TASK_PROMPT="+metadata.GetTaskPrompt(),
384380
awsSDKUserAgentEnv(safeEnvironValue(env, awsSDKUserAgentEnvKey)),
385381
)
386382
if metadata.GetPrebuiltWorkspaceBuildStage().IsPrebuild() {

provisioner/terraform/provision_test.go

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -937,59 +937,6 @@ func TestProvision(t *testing.T) {
937937
}},
938938
},
939939
},
940-
{
941-
Name: "ai-task-multiple-allowed-in-plan",
942-
Files: map[string]string{
943-
"main.tf": `terraform {
944-
required_providers {
945-
coder = {
946-
source = "coder/coder"
947-
version = ">= 2.13.0"
948-
}
949-
}
950-
}
951-
data "coder_task" "me" {}
952-
resource "coder_ai_task" "a" {
953-
sidebar_app {
954-
id = "7128be08-8722-44cb-bbe1-b5a391c4d94b" # fake ID, irrelevant here anyway but needed for validation
955-
}
956-
}
957-
resource "coder_ai_task" "b" {
958-
sidebar_app {
959-
id = "7128be08-8722-44cb-bbe1-b5a391c4d94b" # fake ID, irrelevant here anyway but needed for validation
960-
}
961-
}
962-
`,
963-
},
964-
Request: &proto.PlanRequest{},
965-
Response: &proto.GraphComplete{
966-
Resources: []*proto.Resource{
967-
{
968-
Name: "a",
969-
Type: "coder_ai_task",
970-
},
971-
{
972-
Name: "b",
973-
Type: "coder_ai_task",
974-
},
975-
},
976-
AiTasks: []*proto.AITask{
977-
{
978-
Id: "a",
979-
SidebarApp: &proto.AITaskSidebarApp{
980-
Id: "7128be08-8722-44cb-bbe1-b5a391c4d94b",
981-
},
982-
},
983-
{
984-
Id: "b",
985-
SidebarApp: &proto.AITaskSidebarApp{
986-
Id: "7128be08-8722-44cb-bbe1-b5a391c4d94b",
987-
},
988-
},
989-
},
990-
HasAiTasks: true,
991-
},
992-
},
993940
{
994941
Name: "external-agent",
995942
Files: map[string]string{
@@ -1014,38 +961,6 @@ func TestProvision(t *testing.T) {
1014961
HasExternalAgents: true,
1015962
},
1016963
},
1017-
{
1018-
Name: "ai-task-app-id",
1019-
Files: map[string]string{
1020-
"main.tf": `terraform {
1021-
required_providers {
1022-
coder = {
1023-
source = "coder/coder"
1024-
version = ">= 2.12.0"
1025-
}
1026-
}
1027-
}
1028-
resource "coder_ai_task" "my-task" {
1029-
app_id = "7128be08-8722-44cb-bbe1-b5a391c4d94b" # fake ID, irrelevant here anyway but needed for validation
1030-
}
1031-
`,
1032-
},
1033-
Response: &proto.GraphComplete{
1034-
Resources: []*proto.Resource{
1035-
{
1036-
Name: "my-task",
1037-
Type: "coder_ai_task",
1038-
},
1039-
},
1040-
AiTasks: []*proto.AITask{
1041-
{
1042-
Id: "my-task",
1043-
AppId: "7128be08-8722-44cb-bbe1-b5a391c4d94b",
1044-
},
1045-
},
1046-
HasAiTasks: true,
1047-
},
1048-
},
1049964
{
1050965
Name: "malicious-tar",
1051966
Files: map[string]string{
@@ -1173,7 +1088,6 @@ func TestProvision(t *testing.T) {
11731088
require.Equal(t, string(modulesWant), string(modulesGot))
11741089
}
11751090

1176-
require.Equal(t, graphComplete.HasAiTasks, testCase.Response.HasAiTasks)
11771091
require.Equal(t, graphComplete.HasExternalAgents, testCase.Response.HasExternalAgents)
11781092
}
11791093

provisioner/terraform/resources.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ type State struct {
165165
Parameters []*proto.RichParameter
166166
Presets []*proto.Preset
167167
ExternalAuthProviders []*proto.ExternalAuthProviderResource
168-
AITasks []*proto.AITask
169-
HasAITasks bool
170168
HasExternalAgents bool
171169
}
172170

@@ -209,7 +207,6 @@ func ConvertState(ctx context.Context, modules []*tfjson.StateModule, rawGraph s
209207
// Extra array to preserve the order of rich parameters.
210208
tfResourcesRichParameters := make([]*tfjson.StateResource, 0)
211209
tfResourcesPresets := make([]*tfjson.StateResource, 0)
212-
tfResourcesAITasks := make([]*tfjson.StateResource, 0)
213210
var findTerraformResources func(mod *tfjson.StateModule)
214211
findTerraformResources = func(mod *tfjson.StateModule) {
215212
for _, module := range mod.ChildModules {
@@ -222,9 +219,6 @@ func ConvertState(ctx context.Context, modules []*tfjson.StateModule, rawGraph s
222219
if resource.Type == "coder_workspace_preset" {
223220
tfResourcesPresets = append(tfResourcesPresets, resource)
224221
}
225-
if resource.Type == "coder_ai_task" {
226-
tfResourcesAITasks = append(tfResourcesAITasks, resource)
227-
}
228222

229223
label := convertAddressToLabel(resource.Address)
230224
if tfResourcesByLabel[label] == nil {
@@ -996,29 +990,6 @@ func ConvertState(ctx context.Context, modules []*tfjson.StateModule, rawGraph s
996990
return nil, xerrors.Errorf("a maximum of 1 coder_workspace_preset can be marked as default, but %d are set", defaultPresets)
997991
}
998992

999-
// This will only pick up resources which will actually be created.
1000-
aiTasks := make([]*proto.AITask, 0, len(tfResourcesAITasks))
1001-
for _, resource := range tfResourcesAITasks {
1002-
var task provider.AITask
1003-
err = mapstructure.Decode(resource.AttributeValues, &task)
1004-
if err != nil {
1005-
return nil, xerrors.Errorf("decode coder_ai_task attributes: %w", err)
1006-
}
1007-
1008-
appID := task.AppID
1009-
if appID == "" && len(task.SidebarApp) > 0 {
1010-
appID = task.SidebarApp[0].ID
1011-
}
1012-
1013-
aiTasks = append(aiTasks, &proto.AITask{
1014-
Id: task.ID,
1015-
AppId: appID,
1016-
SidebarApp: &proto.AITaskSidebarApp{
1017-
Id: appID,
1018-
},
1019-
})
1020-
}
1021-
1022993
// A map is used to ensure we don't have duplicates!
1023994
externalAuthProvidersMap := map[string]*proto.ExternalAuthProviderResource{}
1024995
// Process the legacy coder_git_auth type first so that
@@ -1068,8 +1039,6 @@ func ConvertState(ctx context.Context, modules []*tfjson.StateModule, rawGraph s
10681039
Parameters: parameters,
10691040
Presets: presets,
10701041
ExternalAuthProviders: externalAuthProviders,
1071-
HasAITasks: len(aiTasks) > 0,
1072-
AITasks: aiTasks,
10731042
HasExternalAgents: hasExternalAgentResources(graph),
10741043
}, nil
10751044
}

0 commit comments

Comments
 (0)