Skip to content

fix: backport fix for managed agent tracking (#21696)#21729

Merged
david-fraley merged 1 commit intodean/release/2.28/ai-usagefrom
cj/r228/fix-aitask-usage-tracking
Jan 29, 2026
Merged

fix: backport fix for managed agent tracking (#21696)#21729
david-fraley merged 1 commit intodean/release/2.28/ai-usagefrom
cj/r228/fix-aitask-usage-tracking

Conversation

@johnstcn
Copy link
Member

@johnstcn johnstcn commented Jan 28, 2026

@johnstcn johnstcn self-assigned this Jan 28, 2026
@johnstcn johnstcn changed the title fix(coderd/provisionerdserver): backport fix for managed agent tracki… fix(coderd/provisionerdserver): backport fix for managed agent tracking (#21696) Jan 28, 2026
@johnstcn johnstcn requested review from Emyrk and mafredri January 28, 2026 13:14
@johnstcn johnstcn marked this pull request as ready for review January 28, 2026 13:14
@johnstcn johnstcn marked this pull request as draft January 28, 2026 16:54
@johnstcn johnstcn changed the base branch from release/2.28 to dean/release/2.28/ai-usage January 28, 2026 16:54
@johnstcn johnstcn force-pushed the cj/r228/fix-aitask-usage-tracking branch from b2674a8 to 58bfed7 Compare January 28, 2026 17:42

// Create one AI workspace, which should succeed.
workspace := coderdtest.CreateWorkspace(t, cli, aiTemplate.ID)
// Create one AI workspace, which should succeed.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Create one AI workspace, which should succeed.

@johnstcn johnstcn marked this pull request as ready for review January 28, 2026 17:52
Comment on lines 2934 to +2935
expectHasAiTask: false,
expectUsageEvent: false,
expectUsageEvent: true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review: to keep the scope of this change small, I'm not changing the semantics of has_ai_task but just fixing the usage events.

Comment on lines +726 to +737
// Create a second AI task, which should fail due to breaching the limit.
_, err = codersdk.NewExperimentalClient(cli).CreateTask(ctx, owner.UserID.String(), codersdk.CreateTaskRequest{
Name: "test-task-2",
TemplateVersionID: aiTemplate.ActiveVersionID,
})
require.ErrorContains(t, err, "You have breached the managed agent limit in your license")

// Create a third non-AI workspace, which should succeed.
// Create a third workspace using the same template, which should succeed.
workspace = coderdtest.CreateWorkspace(t, cli, aiTemplate.ID)
coderdtest.AwaitWorkspaceBuildJobCompleted(t, cli, workspace.LatestBuild.ID)

// Create a fourth non-AI workspace, which should also succeed.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review: this updated test is doing most of the heavy lifting here.

@johnstcn johnstcn changed the title fix(coderd/provisionerdserver): backport fix for managed agent tracking (#21696) fix: backport fix for managed agent tracking (#21696) Jan 28, 2026
@david-fraley david-fraley merged commit 507d05a into dean/release/2.28/ai-usage Jan 29, 2026
40 checks passed
@david-fraley david-fraley deleted the cj/r228/fix-aitask-usage-tracking branch January 29, 2026 15:33
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants