mirror of https://github.com/openclaw/openclaw.git
Compaction/Safeguard: skip faux non-text markers
This commit is contained in:
parent
b656de6de7
commit
3a8cf6a863
|
|
@ -546,6 +546,19 @@ describe("compaction-safeguard recent-turn preservation", () => {
|
|||
expect(section).toContain("[non-text content: image]");
|
||||
});
|
||||
|
||||
it("does not add non-text placeholders for text-only content blocks", () => {
|
||||
const section = formatPreservedTurnsSection([
|
||||
{
|
||||
role: "assistant",
|
||||
content: [{ type: "text", text: "plain text reply" }],
|
||||
timestamp: 1,
|
||||
} as unknown as AgentMessage,
|
||||
]);
|
||||
|
||||
expect(section).toContain("- Assistant: plain text reply");
|
||||
expect(section).not.toContain("[non-text content]");
|
||||
});
|
||||
|
||||
it("clamps preserve count into a safe range", () => {
|
||||
expect(resolveRecentTurnsPreserve(undefined)).toBe(3);
|
||||
expect(resolveRecentTurnsPreserve(-1)).toBe(0);
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ function formatNonTextPlaceholder(content: unknown): string | null {
|
|||
typeCounts.set(type, (typeCounts.get(type) ?? 0) + 1);
|
||||
}
|
||||
if (typeCounts.size === 0) {
|
||||
return "[non-text content]";
|
||||
return null;
|
||||
}
|
||||
const parts = [...typeCounts.entries()].map(([type, count]) =>
|
||||
count > 1 ? `${type} x${count}` : type,
|
||||
|
|
|
|||
Loading…
Reference in New Issue