diff --git a/src/resources/extensions/sf/escalation.ts b/src/resources/extensions/sf/escalation.ts index 63ddd03fc..9e198343e 100644 --- a/src/resources/extensions/sf/escalation.ts +++ b/src/resources/extensions/sf/escalation.ts @@ -142,6 +142,38 @@ export function writeEscalationArtifact( }), ); + // continueWithDefault=true: the agent already proceeded with its + // recommendation. The artifact is the audit trail, but the choice + + // rationale should ALSO land in the memory store so future tasks see + // it via getRelevantMemoriesRanked — otherwise the rationale lives + // only in the JSON artifact and never reaches downstream prompts. + // resolveEscalation handles this for the continueWithDefault=false + // path; we do the symmetric write here. Best-effort. + if (artifact.continueWithDefault) { + try { + const recommendedOption = artifact.options.find( + (o) => o.id === artifact.recommendation, + ); + const memoryContent = formatEscalationMemoryContent( + artifact, + recommendedOption, + `auto-applied default: ${artifact.recommendationRationale}`, + ); + createMemory({ + category: "architecture", + content: memoryContent, + confidence: 0.85, + source_unit_type: "execute-task", + source_unit_id: artifact.taskId, + }); + } catch (memoryErr) { + logWarning( + "tool", + `escalation: continueWithDefault memory write failed: ${(memoryErr as Error).message}`, + ); + } + } + return path; }