Skip to content

Commit 75b38f1

Browse files
fix(coderd): ignore sub agents when converting a task to workspace (coder#19624)
Addresses comment raised on previous PR coder#19619 (comment) We know we can skip sub agents when searching for which agent is related to the task, as this is not an explicitly supported feature at the moment. When we come to properly setting up a Task -> Agent relationship this limitation will be dropped.
1 parent 26e8a35 commit 75b38f1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

coderd/aitasks.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,19 @@ func (api *API) tasksFromWorkspaces(ctx context.Context, apiWorkspaces []codersd
217217
// This just picks up the first agent it discovers.
218218
// This approach _might_ break when a task has multiple agents,
219219
// depending on which agent was found first.
220+
//
221+
// We explicitly do not have support for running tasks
222+
// inside of a sub agent at the moment, so we can be sure
223+
// that any sub agents are not the agent we're looking for.
220224
var taskAgentID uuid.NullUUID
221225
var taskAgentLifecycle *codersdk.WorkspaceAgentLifecycle
222226
var taskAgentHealth *codersdk.WorkspaceAgentHealth
223227
for _, resource := range ws.LatestBuild.Resources {
224228
for _, agent := range resource.Agents {
229+
if agent.ParentID.Valid {
230+
continue
231+
}
232+
225233
taskAgentID = uuid.NullUUID{Valid: true, UUID: agent.ID}
226234
taskAgentLifecycle = &agent.LifecycleState
227235
taskAgentHealth = &agent.Health

0 commit comments

Comments
 (0)