mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 13:20:22 +00:00
Compaction/Safeguard: align off-policy identifier behavior
This commit is contained in:
committed by
Josh Lehman
parent
980eb46a83
commit
0b1df34806
@@ -671,8 +671,9 @@ describe("compaction-safeguard recent-turn preservation", () => {
|
||||
identifierPolicy: "off",
|
||||
});
|
||||
expect(instructions).toContain("## Exact identifiers");
|
||||
expect(instructions).toContain("N/A (identifier policy off)");
|
||||
expect(instructions).toContain("do not enforce literal-preservation rules");
|
||||
expect(instructions).not.toContain("preserve literal values exactly as seen");
|
||||
expect(instructions).not.toContain("N/A (identifier policy off)");
|
||||
});
|
||||
|
||||
it("threads custom identifier policy text into structured instructions", () => {
|
||||
@@ -754,12 +755,13 @@ describe("compaction-safeguard recent-turn preservation", () => {
|
||||
expect(summary).toContain("\n## Open TODOs\n");
|
||||
});
|
||||
|
||||
it("uses policy-off marker in fallback exact identifiers section", () => {
|
||||
it("does not force policy-off marker in fallback exact identifiers section", () => {
|
||||
const summary = buildStructuredFallbackSummary(undefined, {
|
||||
identifierPolicy: "off",
|
||||
});
|
||||
expect(summary).toContain("## Exact identifiers");
|
||||
expect(summary).toContain("N/A (identifier policy off).");
|
||||
expect(summary).toContain("None captured.");
|
||||
expect(summary).not.toContain("N/A (identifier policy off).");
|
||||
});
|
||||
|
||||
it("uses structured instructions when summarizing dropped history chunks", async () => {
|
||||
|
||||
@@ -47,7 +47,7 @@ const REQUIRED_SUMMARY_SECTIONS = [
|
||||
const STRICT_EXACT_IDENTIFIERS_INSTRUCTION =
|
||||
"For ## Exact identifiers, preserve literal values exactly as seen (IDs, URLs, file paths, ports, hashes, dates, times).";
|
||||
const POLICY_OFF_EXACT_IDENTIFIERS_INSTRUCTION =
|
||||
"For ## Exact identifiers, do not include literal identifiers. Write: N/A (identifier policy off).";
|
||||
"For ## Exact identifiers, include identifiers only when needed for continuity; do not enforce literal-preservation rules.";
|
||||
|
||||
type ToolFailure = {
|
||||
toolCallId: string;
|
||||
@@ -484,16 +484,13 @@ function hasRequiredSummarySections(summary: string): boolean {
|
||||
|
||||
function buildStructuredFallbackSummary(
|
||||
previousSummary: string | undefined,
|
||||
summarizationInstructions?: CompactionSummarizationInstructions,
|
||||
_summarizationInstructions?: CompactionSummarizationInstructions,
|
||||
): string {
|
||||
const trimmedPreviousSummary = previousSummary?.trim() ?? "";
|
||||
if (trimmedPreviousSummary && hasRequiredSummarySections(trimmedPreviousSummary)) {
|
||||
return trimmedPreviousSummary;
|
||||
}
|
||||
const exactIdentifiersSummary =
|
||||
summarizationInstructions?.identifierPolicy === "off"
|
||||
? "N/A (identifier policy off)."
|
||||
: "None captured.";
|
||||
const exactIdentifiersSummary = "None captured.";
|
||||
return [
|
||||
"## Decisions",
|
||||
trimmedPreviousSummary || "No prior history.",
|
||||
|
||||
Reference in New Issue
Block a user