{"record":{"id":"688b0e97366cc3a2","repo":"n8n-io/n8n","slug":"delegated-child-checkpoint-does-not-match-the-sele","errorCode":null,"errorMessage":"Delegated child checkpoint does not match the selected sub-agent","messagePattern":"Delegated child checkpoint does not match the selected sub-agent","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/agents/src/runtime/tools/delegate-sub-agent-tool.ts","lineNumber":774,"sourceCode":"\t);\n}\n\nfunction restoreDelegateRequest(\n\tinput: DelegateSubAgentInput,\n\tctx: ToolContext,\n\tcontinuation: JSONValue,\n\tpolicy: DelegateSubAgentPolicy | undefined,\n\tchildPathIndexes: Map<string, number>,\n): {\n\tcheckpoint: DelegateSubAgentContinuation & { taskPath: SubAgentTaskPath };\n\trequest: DelegateSubAgentRequest;\n} {\n\tconst checkpoint = parseDelegateSubAgentContinuation(continuation);\n\tif (!checkpoint) {\n\t\tthrow new Error('Delegated child checkpoint metadata is missing or invalid');\n\t}\n\tif (checkpoint.subAgentId !== input.subAgentId) {\n\t\tthrow new Error('Delegated child checkpoint does not match the selected sub-agent');\n\t}\n\tconst { taskPath } = checkpoint;\n\tassertSubAgentTaskPath(taskPath);\n\tconst key = getChildPathIndexKey(ctx);\n\tchildPathIndexes.set(key, Math.max(childPathIndexes.get(key) ?? 0, checkpoint.childCount + 1));\n\tconst request = createDelegateSubAgentRequest(\n\t\tinput,\n\t\tctx,\n\t\ttaskPath,\n\t\tcheckpoint.childCount,\n\t\tpolicy,\n\t);\n\treturn { checkpoint: { ...checkpoint, taskPath }, request };\n}\n\nfunction getChildCheckpointTarget(checkpoint: DelegateSubAgentContinuation) {\n\treturn {\n\t\tchildRunId: checkpoint.runId,","sourceCodeStart":756,"sourceCodeEnd":792,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/agents/src/runtime/tools/delegate-sub-agent-tool.ts#L756-L792","documentation":"Thrown by restoreDelegateRequest when the checkpoint's subAgentId does not match the subAgentId in the current resume input. This guard prevents resuming a delegated child under a different sub-agent than the one that originally started — which would execute the wrong agent's logic with stale context.","triggerScenarios":"The availableSubAgents list or selection logic changed between suspend and resume, causing the resume input to reference a different subAgentId than the one recorded in the continuation checkpoint. Also triggered by manual tampering with the resume payload or a bug in sub-agent selection logic.","commonSituations":"Editing the agent configuration (adding/removing/reordering sub-agents) between when a delegation suspended and when the user resumes. Dynamic sub-agent registration that is non-deterministic across restarts. Passing a hand-crafted resume payload with the wrong subAgentId.","solutions":["Ensure the sub-agent configuration is stable between suspend and resume (same availableSubAgents list and identifiers).","If the sub-agent set legitimately changed, start a new delegation rather than resuming the stale one.","Verify that sub-agent IDs are deterministic and not regenerated on each build."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function continuationMatchesInput(continuation: DelegateSubAgentContinuation, input: DelegateSubAgentInput): boolean {\n  return continuation.subAgentId === input.subAgentId;\n}\nif (!continuationMatchesInput(storedContinuation, resumeInput)) {\n  // sub-agent set changed; do not resume\n}","typeGuard":null,"tryCatchPattern":"try {\n  await agent.resume(resumeData);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('does not match')) {\n    // re-select the correct sub-agent or start fresh\n  } else throw e;\n}","preventionTips":["Keep the sub-agent list stable between suspend and resume.","Use deterministic, stable sub-agent IDs that do not change across restarts.","Avoid dynamically adding or removing sub-agents while delegations are suspended."],"tags":["checkpoint","resume","delegate-tool","sub-agent-id"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}