fix: prevent ESCALATE → new task loop (only create tasks on human messages)
This commit is contained in:
@@ -174,6 +174,7 @@ describe('paired execution context', () => {
|
||||
chatJid: 'dc:test',
|
||||
runId: 'run-1',
|
||||
roomRoleContext: ownerContext,
|
||||
hasHumanMessage: true,
|
||||
});
|
||||
|
||||
expect(db.upsertPairedProject).toHaveBeenCalled();
|
||||
|
||||
@@ -163,6 +163,7 @@ function ensureActiveTask(
|
||||
group: RegisteredGroup,
|
||||
chatJid: string,
|
||||
roomRoleContext: RoomRoleContext,
|
||||
hasHumanMessage?: boolean,
|
||||
): PairedTask | null {
|
||||
const canonicalWorkDir = ensurePairedProject(group, chatJid);
|
||||
if (!canonicalWorkDir) {
|
||||
@@ -174,6 +175,12 @@ function ensureActiveTask(
|
||||
return existing;
|
||||
}
|
||||
|
||||
// Don't create a new task for bot-only messages — prevents
|
||||
// ESCALATE → completed → bot message triggers new task → loop.
|
||||
if (!hasHumanMessage) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const now = new Date().toISOString();
|
||||
const task: PairedTask = {
|
||||
id: crypto.randomUUID(),
|
||||
@@ -239,7 +246,7 @@ export function preparePairedExecutionContext(args: {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const task = ensureActiveTask(group, chatJid, roomRoleContext);
|
||||
const task = ensureActiveTask(group, chatJid, roomRoleContext, args.hasHumanMessage);
|
||||
if (!task) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user