fix: skip auto-processing for self-assigned tasks (taken via tool call)
When agent takes a task via take_task tool in conversation, the task.assigned event is now skipped (no duplicate in_progress→in_review).
This commit is contained in:
parent
9d897621a7
commit
e58c39dc0c
@ -16,6 +16,8 @@ export class EventRouter {
|
||||
private log = logger.child({ component: 'event-router' });
|
||||
private activeTasks = 0;
|
||||
private trackerTools: ToolDefinition[];
|
||||
/** Tasks taken via tool call (agent already knows about them — skip auto-processing) */
|
||||
private selfAssignedTasks = new Set<string>();
|
||||
constructor(
|
||||
private config: AgentConfig,
|
||||
private client: TrackerClient,
|
||||
@ -24,6 +26,7 @@ export class EventRouter {
|
||||
this.trackerTools = createTrackerTools({
|
||||
trackerClient: client,
|
||||
agentSlug: config.slug,
|
||||
selfAssignedTasks: this.selfAssignedTasks,
|
||||
});
|
||||
this.log.info({ toolCount: this.trackerTools.length }, 'Tracker tools registered');
|
||||
}
|
||||
@ -61,6 +64,13 @@ export class EventRouter {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip if agent took this task itself via tool call (already in conversation context)
|
||||
if (this.selfAssignedTasks.has(task.id)) {
|
||||
this.selfAssignedTasks.delete(task.id);
|
||||
this.log.info('│ TASK %s self-assigned via tool, skipping auto-processing', task.key);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.activeTasks >= this.config.maxConcurrentTasks) {
|
||||
this.log.warn({ taskId: task.id, activeTasks: this.activeTasks }, 'Max concurrent tasks reached, skipping');
|
||||
return;
|
||||
|
||||
@ -100,6 +100,7 @@ export function createTaskTools(ctx: ToolContext): ToolDefinition<any>[] {
|
||||
description: 'Take a task for yourself (atomically assign to this agent). Task must be in backlog or todo status.',
|
||||
parameters: TakeTaskParams,
|
||||
async execute(_id: string, params: any) {
|
||||
ctx.selfAssignedTasks.add(params.task_id);
|
||||
await ctx.trackerClient.takeTask(params.task_id, ctx.agentSlug);
|
||||
return ok(`Task ${params.task_id} taken by ${ctx.agentSlug}`);
|
||||
},
|
||||
|
||||
@ -4,4 +4,6 @@ import type { TrackerClient } from '../tracker/client.js';
|
||||
export interface ToolContext {
|
||||
trackerClient: TrackerClient;
|
||||
agentSlug: string;
|
||||
/** Track tasks taken via tool call — prevents duplicate auto-processing */
|
||||
selfAssignedTasks: Set<string>;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user