{"record":{"id":"35a46f28ecc6ea15","repo":"n8n-io/n8n","slug":"no-cancellation-handler-is-available-for-reques","errorCode":null,"errorMessage":"No cancellation handler is available for \"${request.subAgentId}\".","messagePattern":"No cancellation handler is available for \"(.+?)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/agents/src/sdk/agent.ts","lineNumber":1201,"sourceCode":"\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (hostResumeRunner !== undefined) {\n\t\t\t\t\t\t\t\t\treturn await hostResumeRunner(request, helpersFromHandler);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn configuredSubAgentNotFound(request);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcancelSubAgent: async (\n\t\t\t\t\t\t\t\trequest: DelegateSubAgentCancelRequest,\n\t\t\t\t\t\t\t\thelpersFromHandler: DelegateSubAgentRunnerHelpers,\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tif (request.subAgentId === INLINE_SUB_AGENT_ID) {\n\t\t\t\t\t\t\t\t\tawait options.runState.cancel(request.childRunId);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (hostCancelRunner !== undefined) {\n\t\t\t\t\t\t\t\t\tawait hostCancelRunner(request, helpersFromHandler);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`No cancellation handler is available for \"${request.subAgentId}\".`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t});\n\n\t\t\tif (tool.approval?.required === true) {\n\t\t\t\treturn wrapToolForApproval(completedTool, { requireApproval: true });\n\t\t\t}\n\t\t\treturn completedTool;\n\t\t});\n\t}\n\n\tprivate createInlineSubAgentRunner(options: {\n\t\tdeferredTools: BuiltTool[];\n\t\tmodelConfig: ModelConfig;\n\t\trunState: RunStateManager;","sourceCodeStart":1183,"sourceCodeEnd":1219,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/agents/src/sdk/agent.ts#L1183-L1219","documentation":"Thrown from the inline sub-agent wiring inside Agent when the delegate-subagent tool's cancelSubAgent handler receives a cancel request it cannot route. Routing tries the inline sub-agent first (INLINE_SUB_AGENT_ID), then delegates to the host-supplied hostCancelRunner; if neither applies, there is no way to cancel that sub-agent id. The error identifies the unroutable subAgentId verbatim.","triggerScenarios":"A host constructs a delegate sub-agent tool via createDelegateSubAgentTool (or supplies delegateOptions) WITHOUT setting cancelSubAgent, then the runtime issues a DelegateSubAgentCancelRequest whose subAgentId is something other than 'inline'. Because the cancel handler is only registered when childCanSuspend is true, this surfaces during a suspend/resume lifecycle of a host-managed sub-agent.","commonSituations":"Custom host integrations that wire resumeSubAgent but forget cancelSubAgent; upgrading @n8n/agents and relying on prior behavior where cancellation was a no-op; passing a non-inline subAgentId from a checkpoint-resume path that the host runner does not recognize.","solutions":["Supply a cancelSubAgent handler in the delegate sub-agent options alongside resumeSubAgent so host-managed sub-agents can be cancelled.","Ensure every subAgentId the runtime can emit is either 'inline' or covered by your host runner.","If you do not need suspend/resume, do not set resumeSubAgent so childCanSuspend stays false and the cancel handler is never registered."],"exampleFix":"// before\ncreateDelegateSubAgentTool({\n  runSubAgent: hostRun,\n  resumeSubAgent: hostResume,\n  // cancelSubAgent missing\n});\n// after\ncreateDelegateSubAgentTool({\n  runSubAgent: hostRun,\n  resumeSubAgent: hostResume,\n  cancelSubAgent: async (req, helpers) => { await hostCancel(req, helpers); },\n});","handlingStrategy":"validation","validationCode":"import { INLINE_SUB_AGENT_ID } from '@n8n/agents';\n\nfunction assertCancelRoutable(subAgentId: string, hostCancelRunner?: Function) {\n  if (subAgentId === INLINE_SUB_AGENT_ID) return;\n  if (typeof hostCancelRunner !== 'function') {\n    throw new Error(`No host cancelSubAgent for non-inline subAgentId \"${subAgentId}\"`);\n  }\n}","typeGuard":"function isInlineSubAgentId(id: string): boolean {\n  return id === 'inline';\n}","tryCatchPattern":"try {\n  await delegate.cancel(request);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('No cancellation handler')) {\n    // log and degrade: mark the run as un-cancellable, surface to user\n  } else throw e;\n}","preventionTips":["Always supply cancelSubAgent whenever you supply resumeSubAgent in delegate sub-agent options.","Treat any non-inline subAgentId as requiring a host runner — validate before wiring."],"tags":["sub-agent","delegation","cancellation","runtime"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}