Carry forward the arbiter verdict too, not just the owner final
When a paired task ends on an arbiter ESCALATE (asking the user to choose), the user's next reply was carried into the fresh task with the owner's earlier final as context — not the arbiter message they were actually responding to. Generalize the carry-forward to the latest user-facing final (owner final OR arbiter verdict, whichever the task ended on), so the user can choose based on the last arbiter message without the new turn re-reading the whole prior conversation. The carried-forward guidance marker is now matched by a shared prefix so it triggers for both. Adds tests for the arbiter-escalation carry and the prefix guidance. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -246,4 +246,66 @@ describe('paired execution carry-forward attachments', () => {
|
||||
expect.objectContaining({ createdAt: '2026-03-28T00:01:00.000Z' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('carries the arbiter verdict forward when the previous task ended on an arbiter escalation', () => {
|
||||
vi.clearAllMocks();
|
||||
const previousTask = buildTask({
|
||||
id: 'task-escalated',
|
||||
status: 'completed',
|
||||
completion_reason: 'arbiter_escalated',
|
||||
});
|
||||
vi.mocked(db.getLatestOpenPairedTaskForChat).mockReturnValue(undefined);
|
||||
vi.mocked(db.getLatestPairedTaskForChat).mockReturnValue(previousTask);
|
||||
// The arbiter's ESCALATE is the last thing the user saw — they are now
|
||||
// replying to it, so it (not the earlier owner turn) must carry forward.
|
||||
vi.mocked(db.getPairedTurnOutputs).mockReturnValue([
|
||||
{
|
||||
id: 1,
|
||||
task_id: previousTask.id,
|
||||
turn_number: 1,
|
||||
role: 'owner',
|
||||
output_text: 'STEP_DONE\n방향 A로 진행했습니다.',
|
||||
created_at: '2026-03-28T00:01:00.000Z',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
task_id: previousTask.id,
|
||||
turn_number: 2,
|
||||
role: 'reviewer',
|
||||
output_text: 'REVISE\n방향 B가 맞습니다.',
|
||||
created_at: '2026-03-28T00:02:00.000Z',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
task_id: previousTask.id,
|
||||
turn_number: 3,
|
||||
role: 'arbiter',
|
||||
output_text:
|
||||
'ESCALATE\n두 방향(A/B) 중 사용자가 선택해야 합니다. 1) A 유지 2) B 전환',
|
||||
created_at: '2026-03-28T00:03:00.000Z',
|
||||
},
|
||||
]);
|
||||
|
||||
resolveOwnerTaskForHumanMessage({
|
||||
group,
|
||||
chatJid: 'dc:test',
|
||||
roomRoleContext: ownerContext,
|
||||
});
|
||||
|
||||
expect(db.insertPairedTurnOutput).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
0,
|
||||
'owner',
|
||||
expect.stringContaining('latest arbiter verdict'),
|
||||
expect.objectContaining({ createdAt: '2026-03-28T00:03:00.000Z' }),
|
||||
);
|
||||
// And it must carry the arbiter's escalation text, not the earlier owner turn.
|
||||
expect(db.insertPairedTurnOutput).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
0,
|
||||
'owner',
|
||||
expect.stringContaining('두 방향(A/B) 중 사용자가 선택'),
|
||||
expect.anything(),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user