mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 17:50:45 +00:00
Agents: clarify local model context preflight (#66236)
Merged via squash.
Prepared head SHA: 11bfaf15f6
Co-authored-by: ImLukeF <92253590+ImLukeF@users.noreply.github.com>
Co-authored-by: ImLukeF <92253590+ImLukeF@users.noreply.github.com>
Reviewed-by: @ImLukeF
This commit is contained in:
@@ -2,7 +2,7 @@ import syncFs from "node:fs";
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
clearTopicNameCache,
|
||||
getTopicEntry,
|
||||
@@ -14,10 +14,15 @@ import {
|
||||
|
||||
describe("topic-name-cache", () => {
|
||||
beforeEach(() => {
|
||||
vi.useRealTimers();
|
||||
clearTopicNameCache();
|
||||
resetTopicNameCacheForTest();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("stores and retrieves a topic name", () => {
|
||||
updateTopicName(-100123, 42, { name: "Deployments" });
|
||||
expect(getTopicName(-100123, 42)).toBe("Deployments");
|
||||
@@ -63,9 +68,11 @@ describe("topic-name-cache", () => {
|
||||
expect(topicNameCacheSize()).toBe(0);
|
||||
});
|
||||
|
||||
it("updates timestamps on write", () => {
|
||||
it("updates timestamps on write", async () => {
|
||||
vi.useFakeTimers();
|
||||
updateTopicName(-100123, 42, { name: "A" });
|
||||
const t1 = getTopicEntry(-100123, 42)?.updatedAt ?? 0;
|
||||
await vi.advanceTimersByTimeAsync(10);
|
||||
updateTopicName(-100123, 42, { name: "B" });
|
||||
const t2 = getTopicEntry(-100123, 42)?.updatedAt ?? 0;
|
||||
expect(t2).toBeGreaterThan(t1);
|
||||
@@ -85,8 +92,10 @@ describe("topic-name-cache", () => {
|
||||
expect(getTopicName(-100000, 2048)).toBe("Topic 2048");
|
||||
});
|
||||
|
||||
it("refreshes recency on read so active topics survive eviction", () => {
|
||||
it("refreshes recency on read so active topics survive eviction", async () => {
|
||||
vi.useFakeTimers();
|
||||
updateTopicName(-100000, 1, { name: "Active" });
|
||||
await vi.advanceTimersByTimeAsync(10);
|
||||
for (let i = 2; i <= 2048; i++) {
|
||||
updateTopicName(-100000, i, { name: `Topic ${i}` });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user