fix(planning): attach agent tag to chained children for queue pickup
Worker queue picker requires the 'agent' tag — without it children created through QueueSubtasksSequentiallyAsync sat in 'Queued' forever. Attach the tag automatically when wiring up the chain.
This commit is contained in:
@@ -19,6 +19,7 @@ public sealed class PlanningChainCoordinator
|
|||||||
?? throw new InvalidOperationException($"Task {parentTaskId} not found.");
|
?? throw new InvalidOperationException($"Task {parentTaskId} not found.");
|
||||||
|
|
||||||
var children = await ctx.Tasks
|
var children = await ctx.Tasks
|
||||||
|
.Include(t => t.Tags)
|
||||||
.Where(t => t.ParentTaskId == parentTaskId)
|
.Where(t => t.ParentTaskId == parentTaskId)
|
||||||
.OrderBy(t => t.SortOrder).ThenBy(t => t.CreatedAt)
|
.OrderBy(t => t.SortOrder).ThenBy(t => t.CreatedAt)
|
||||||
.ToListAsync(ct);
|
.ToListAsync(ct);
|
||||||
@@ -31,8 +32,14 @@ public sealed class PlanningChainCoordinator
|
|||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
$"Child {bad.Id} is in status {bad.Status}; expected Manual or Planned.");
|
$"Child {bad.Id} is in status {bad.Status}; expected Manual or Planned.");
|
||||||
|
|
||||||
|
// Worker queue picker requires the "agent" tag — attach it so children are pickable.
|
||||||
|
var agentTag = await ctx.Tags.FirstOrDefaultAsync(t => t.Name == "agent", ct);
|
||||||
for (int i = 0; i < children.Count; i++)
|
for (int i = 0; i < children.Count; i++)
|
||||||
|
{
|
||||||
children[i].Status = i == 0 ? TaskStatus.Queued : TaskStatus.Waiting;
|
children[i].Status = i == 0 ? TaskStatus.Queued : TaskStatus.Waiting;
|
||||||
|
if (agentTag is not null && !children[i].Tags.Any(t => t.Id == agentTag.Id))
|
||||||
|
children[i].Tags.Add(agentTag);
|
||||||
|
}
|
||||||
|
|
||||||
await ctx.SaveChangesAsync(ct);
|
await ctx.SaveChangesAsync(ct);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user