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:
Luke
2026-04-14 15:38:10 +10:00
committed by GitHub
parent 852484965f
commit 0abe64a4ff
13 changed files with 249 additions and 42 deletions

View File

@@ -93,7 +93,7 @@ describe("qqbot local media path remapping", () => {
it("allows structured payload files inside the QQ Bot media directory", () => {
const { mediaFile } = createQqbotMediaFile("allowed.png");
expect(resolveQQBotPayloadLocalFilePath(mediaFile)).toBe(mediaFile);
expect(resolveQQBotPayloadLocalFilePath(mediaFile)).toBe(fs.realpathSync(mediaFile));
});
it("blocks structured payload files inside the QQ Bot data directory", () => {
@@ -127,6 +127,6 @@ describe("qqbot local media path remapping", () => {
"legacy.png",
);
expect(resolveQQBotPayloadLocalFilePath(missingWorkspacePath)).toBe(mediaFile);
expect(resolveQQBotPayloadLocalFilePath(missingWorkspacePath)).toBe(fs.realpathSync(mediaFile));
});
});

View File

@@ -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}` });
}