fix: route paired room turns by task status instead of SERVICE_ID
In unified mode, SERVICE_SESSION_SCOPE doesn't match the lease's owner/reviewer service IDs. Determine the effective role from the paired task status: review_ready/in_review → reviewer, otherwise → owner. This restores the owner↔reviewer ping-pong in unified single-process mode.
This commit is contained in:
@@ -11,7 +11,11 @@ import {
|
|||||||
writeTasksSnapshot,
|
writeTasksSnapshot,
|
||||||
} from './agent-runner.js';
|
} from './agent-runner.js';
|
||||||
import { listAvailableGroups } from './available-groups.js';
|
import { listAvailableGroups } from './available-groups.js';
|
||||||
import { createServiceHandoff, getAllTasks } from './db.js';
|
import {
|
||||||
|
createServiceHandoff,
|
||||||
|
getAllTasks,
|
||||||
|
getLatestOpenPairedTaskForChat,
|
||||||
|
} from './db.js';
|
||||||
import { GroupQueue } from './group-queue.js';
|
import { GroupQueue } from './group-queue.js';
|
||||||
import { logger } from './logger.js';
|
import { logger } from './logger.js';
|
||||||
import { buildRoomMemoryBriefing } from './memento-client.js';
|
import { buildRoomMemoryBriefing } from './memento-client.js';
|
||||||
@@ -127,11 +131,22 @@ export async function runAgentForGroup(
|
|||||||
|
|
||||||
const canRotateToken = isClaudeCodeAgent && getTokenCount() > 1;
|
const canRotateToken = isClaudeCodeAgent && getTokenCount() > 1;
|
||||||
const currentLease = getEffectiveChannelLease(chatJid);
|
const currentLease = getEffectiveChannelLease(chatJid);
|
||||||
const reviewerMode =
|
|
||||||
currentLease.reviewer_service_id === SERVICE_SESSION_SCOPE;
|
// In unified mode, determine role from the lease directly.
|
||||||
|
// Default to owner; the auto-review trigger in completePairedExecutionContext
|
||||||
|
// will switch to reviewer when the task is in review_ready state.
|
||||||
|
const pairedTask = currentLease.reviewer_service_id
|
||||||
|
? getLatestOpenPairedTaskForChat(chatJid)
|
||||||
|
: null;
|
||||||
|
const effectiveServiceId =
|
||||||
|
pairedTask &&
|
||||||
|
(pairedTask.status === 'review_ready' || pairedTask.status === 'in_review')
|
||||||
|
? currentLease.reviewer_service_id!
|
||||||
|
: currentLease.owner_service_id;
|
||||||
|
const reviewerMode = effectiveServiceId === currentLease.reviewer_service_id;
|
||||||
const roomRoleContext = buildRoomRoleContext(
|
const roomRoleContext = buildRoomRoleContext(
|
||||||
currentLease,
|
currentLease,
|
||||||
SERVICE_SESSION_SCOPE,
|
effectiveServiceId,
|
||||||
);
|
);
|
||||||
const pairedExecutionContext = preparePairedExecutionContext({
|
const pairedExecutionContext = preparePairedExecutionContext({
|
||||||
group,
|
group,
|
||||||
|
|||||||
Reference in New Issue
Block a user