mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-02 16:51:06 +00:00
test: avoid platform-specific transcript stat assertion
This commit is contained in:
@@ -1558,40 +1558,25 @@ describe("runMemoryFlushIfNeeded", () => {
|
||||
updatedAt: Date.now(),
|
||||
totalTokensFresh: false,
|
||||
};
|
||||
const originalStat = fsCore.promises.stat.bind(fsCore.promises);
|
||||
const statSpy = vi
|
||||
.spyOn(fsCore.promises, "stat")
|
||||
.mockImplementation(async (target, options) => originalStat(target, options));
|
||||
|
||||
let entry: SessionEntry | undefined;
|
||||
let directTranscriptStats: unknown[] = [];
|
||||
try {
|
||||
entry = await runPreflightCompactionIfNeeded({
|
||||
cfg: { agents: { defaults: { compaction: { memoryFlush: {} } } } },
|
||||
followupRun: createTestFollowupRun({
|
||||
sessionId: "session",
|
||||
sessionFile,
|
||||
sessionKey: "main",
|
||||
}),
|
||||
defaultModel: "anthropic/claude-opus-4-6",
|
||||
agentCfgContextTokens: 100_000,
|
||||
sessionEntry,
|
||||
sessionStore: { main: sessionEntry },
|
||||
const entry = await runPreflightCompactionIfNeeded({
|
||||
cfg: { agents: { defaults: { compaction: { memoryFlush: {} } } } },
|
||||
followupRun: createTestFollowupRun({
|
||||
sessionId: "session",
|
||||
sessionFile,
|
||||
sessionKey: "main",
|
||||
storePath: path.join(rootDir, "sessions.json"),
|
||||
isHeartbeat: false,
|
||||
replyOperation: createReplyOperation(),
|
||||
});
|
||||
directTranscriptStats = statSpy.mock.calls.filter(
|
||||
([target]) => String(target) === sessionFile,
|
||||
);
|
||||
} finally {
|
||||
statSpy.mockRestore();
|
||||
}
|
||||
}),
|
||||
defaultModel: "anthropic/claude-opus-4-6",
|
||||
agentCfgContextTokens: 100_000,
|
||||
sessionEntry,
|
||||
sessionStore: { main: sessionEntry },
|
||||
sessionKey: "main",
|
||||
storePath: path.join(rootDir, "sessions.json"),
|
||||
isHeartbeat: false,
|
||||
replyOperation: createReplyOperation(),
|
||||
});
|
||||
|
||||
expect(entry).toBe(sessionEntry);
|
||||
expect(compactEmbeddedAgentSessionMock).not.toHaveBeenCalled();
|
||||
expect(directTranscriptStats).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not treat raw transcript metadata bytes as token pressure", async () => {
|
||||
|
||||
@@ -560,7 +560,7 @@ async function readLastNonzeroUsageFromSessionLog(logPath: string): Promise<Sess
|
||||
return usage
|
||||
? {
|
||||
usage,
|
||||
trailingBytes: 0,
|
||||
trailingBytes: Math.max(0, stat.size - Buffer.byteLength(leadingPartial, "utf8")),
|
||||
byteSize: stat.size,
|
||||
}
|
||||
: { byteSize: stat.size };
|
||||
|
||||
Reference in New Issue
Block a user