{"record":{"id":"34993d52c3bcbd5a","repo":"can1357/oh-my-pi","slug":"agent-isolated-nested-patch-apply-failed-for-r","errorCode":null,"errorMessage":"agent() isolated nested patch apply failed for ${result.id}: ${mergeSummary.replace(/<\\/?system-notification>/g, \"\").trim()}${recoveryHint}","messagePattern":"agent\\(\\) isolated nested patch apply failed for (.+?): (.+?)(.+?)","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/eval/agent-bridge.ts","lineNumber":187,"sourceCode":"\t\t\tconst failureMessage = buildSubagentFailureMessage(policy.agentName, result)\n\t\t\t\t.replace(/<\\/?system-notification>/g, \"\")\n\t\t\t\t.trim();\n\t\t\tconst recoveryHint = policy.isIsolated ? await buildStructuredSubagentRecoveryHint(result, artifactsDir) : \"\";\n\t\t\tthrow new ToolError(`${failureMessage}${recoveryHint}`);\n\t\t}\n\t\tif (policy.isIsolated && changesApplied === false) {\n\t\t\tconst summary = mergeSummary.replace(/<\\/?system-notification>/g, \"\").trim();\n\t\t\tconst recoveryHint = await buildStructuredSubagentRecoveryHint(result, artifactsDir);\n\t\t\tthrow new ToolError(\n\t\t\t\t`agent() isolated apply failed for ${result.id}${summary ? `: ${summary}` : \"\"}${recoveryHint}`,\n\t\t\t);\n\t\t}\n\n\t\tconst structuredOutput = result.structuredOutput;\n\t\tconst structured = structuredOutput?.source !== undefined && structuredOutput.source !== \"none\";\n\t\tif (structured && mergeSummary.includes(\"<system-notification>\")) {\n\t\t\tconst recoveryHint = await buildStructuredSubagentRecoveryHint(result, artifactsDir);\n\t\t\tthrow new ToolError(\n\t\t\t\t`agent() isolated nested patch apply failed for ${result.id}: ${mergeSummary.replace(/<\\/?system-notification>/g, \"\").trim()}${recoveryHint}`,\n\t\t\t);\n\t\t}\n\n\t\tconst hasData = structured && structuredOutput !== undefined && Object.hasOwn(structuredOutput, \"data\");\n\t\tconst data = structuredOutput?.data;\n\t\tconst text = structured ? result.output : result.output + mergeSummary;\n\t\tconst schemaSource = structuredOutput?.source === \"none\" ? undefined : structuredOutput?.source;\n\t\tconst schemaMode = structured ? structuredOutput?.mode : undefined;\n\t\tconst schemaStatus = structuredOutput?.status === \"unavailable\" ? undefined : structuredOutput?.status;\n\n\t\tconst model = result.resolvedModel ?? policy.modelOverride;\n\t\tconst nestedPatches = result.nestedPatches?.length ? result.nestedPatches : undefined;\n\t\tconst isolationSummary = mergeSummary ? mergeSummary.trim() : undefined;\n\t\treturn {\n\t\t\ttext,\n\t\t\t...(hasData ? { data } : {}),\n\t\t\tdetails: {","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/eval/agent-bridge.ts#L169-L205","documentation":"When an isolated subagent reports structured output but the merge summary contains a <system-notification> tag, the bridge infers a nested patch application failed inside the subagent run and throws with the sanitized summary plus a recovery hint. It flags partial/failed nested edits despite structured success.","triggerScenarios":"agent() isolated call whose result has structuredOutput.source set (non-'none') while mergeSummary embeds <system-notification> — the subagent attempted to apply nested patches back and one failed.","commonSituations":"Nested patch from the subagent conflicts with parent state; subagent's internal apply hit a malformed patch; notification leaked into the merge summary after a silent nested failure.","solutions":["Inspect the sanitized mergeSummary in the message for which nested patch failed","Review subagent artifacts (recovery hint gives the dir) for the failing patch","Re-run the subagent against the current parent state","If nested patches are optional, run with merge disabled and apply manually"],"exampleFix":"// before: nested patch conflicts surface as thrown error\nawait agent({ isolated: true, prompt: 'apply nested edits' })\n// after: catch, inspect artifacts, retry\ntry { await agent({ isolated: true, prompt }) }\ncatch (e) { const hint = /artifacts at (\\S+)/.exec(e.message); /* inspect dir, retry */ }","handlingStrategy":"try-catch","validationCode":"// ensure subagent emits well-formed nested patches\nconst dry = await agent({ isolated: true, merge: false, prompt });\nif (/<system-notification>/.test(dry.mergeSummary ?? '')) fixPrompt();","typeGuard":"null","tryCatchPattern":"try { await agent({ isolated: true, prompt }) } catch (e) { if (/nested patch apply failed/.test(e.message)) { inspectArtifactsAndRetry(e.message); } else throw e }","preventionTips":["Validate nested patch output format in a smoke eval","Keep nested edits small and conflict-free","Run isolated subagents against current parent state","Treat <system-notification> in summaries as a failure signal"],"tags":["subagent","nested-patch","isolation","eval"],"backgroundTag":"patch-apply-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}