feat(sf): persist continueWithDefault escalations as memories too
When an agent escalates with continueWithDefault=true, it has already proceeded with the recommendation — the artifact JSON captures the audit trail but no other surface carries the rationale forward. Downstream tasks running after this one would query memories and find nothing about the choice. resolveEscalation already writes a memory on the continueWithDefault= false path (after operator resolves). This is the symmetric write for the continueWithDefault=true path: same category="architecture", same "[escalation:T##]" prefix, with the rationale prefixed "auto-applied default: ..." so a journal scan can tell apart continueWithDefault entries from operator-resolved ones. Now a slice's full decision history (operator-resolved + auto-accepted + default-applied escalations) lives uniformly in the memory store and flows into the cosine ranking for downstream prompts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fec6c293bf
commit
7a5b125405
1 changed files with 32 additions and 0 deletions
|
|
@ -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;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue