feat: scope paired owner/reviewer sessions to one paired task
Each paired room used to resume one owner (and one reviewer) session for weeks, so every call re-read a huge unrelated history (median ~260k input tokens). A stored session is now resumed only while it belongs to the running paired task; the first turn of a new task starts fresh and the new session is bound to that task (router_state paired_session_task:<folder>, survives restarts). Later turns of the same task (revisions, follow-up human messages while the task is open) keep resuming it. Arbiter was already fresh per call; single rooms are unchanged. The previous task's final answer still reaches the new session through the carried-forward turn-0 output, so PAIRED_CARRY_FORWARD_LATEST_OWNER_FINAL now defaults to true. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import { getPairedTaskById } from './db.js';
|
||||
import { completePairedTaskWithReason } from './paired-task-status.js';
|
||||
import { prepareMessageAgentExecutionTarget } from './message-agent-executor-target.js';
|
||||
import { shouldRetryFreshSessionOnAgentFailure } from './session-recovery.js';
|
||||
import { bindPairedSessionToTask } from './paired-session-binding.js';
|
||||
import type { AgentType, PairedRoomRole, RegisteredGroup } from './types.js';
|
||||
import {
|
||||
clearCompactRefreshIfUnchanged,
|
||||
@@ -186,6 +187,7 @@ export async function runAgentForGroup(
|
||||
runtimePairedTurnIdentity,
|
||||
log,
|
||||
clearRoleSdkSessions,
|
||||
sessionTaskId,
|
||||
} = preparedExecution;
|
||||
let currentSessionId = preparedExecution.currentSessionId;
|
||||
|
||||
@@ -281,6 +283,9 @@ export async function runAgentForGroup(
|
||||
fallbackWorkspaceDir: group.workDir ?? null,
|
||||
onPersistSession: (sessionId) => {
|
||||
deps.persistSession(sessionFolder, sessionId);
|
||||
if (sessionTaskId) {
|
||||
bindPairedSessionToTask(sessionFolder, sessionTaskId);
|
||||
}
|
||||
currentSessionId = sessionId;
|
||||
},
|
||||
registerProcess: (proc, processName, ipcDir) =>
|
||||
|
||||
Reference in New Issue
Block a user