Menu
popagent
publicLatest change 7d04b7c84dd52948c0f4bcf4a3bdbdf00a17f9f0 - Use proven fast model for read-only agents by Ólafur Búi Ólafsson
import { beforeAll, describe, expect, test } from "bun:test";
import { MAX_AGENT_INSTRUCTIONS_CHARACTERS, type AgentSettingsInput } from "./api-types";
import { AgentSettingsStore } from "./agent-settings";
const store = new AgentSettingsStore();
beforeAll(() => store.init());
describe("AgentSettingsStore", () => {
test("bootstraps database-backed roles and persists complete role edits", async () => {
const roles = await store.list();
expect(roles.map((settings) => settings.id)).toEqual(
expect.arrayContaining(["popagent", "researcher", "implementer", "reviewer"]),
);
expect(roles.find(({ id }) => id === "popagent")?.tools).toContain("useBrowserSecret");
for (const role of roles) {
expect(role.tools).not.toEqual(expect.arrayContaining([
"storeSecret",
"recallSecret",
"updateSecret",
]));
}
for (const role of roles) {
expect(role.description.length).toBeGreaterThan(0);
expect(role.instructions).toStartWith("# Role:");
expect(role.sourceUrls).toEqual(
expect.arrayContaining([expect.stringContaining("msitarzewski/agency-agents")]),
);
}
expect(roles.find(({ id }) => id === "popagent")?.model).toBeNull();
expect(roles.find(({ id }) => id === "researcher")?.model).toBe("cx/gpt-5.3-codex-spark");
expect(roles.find(({ id }) => id === "implementer")?.model).toBeNull();
expect(roles.find(({ id }) => id === "reviewer")?.model).toBe("cx/gpt-5.3-codex-spark");
const original = await store.get("researcher");
if (!original) throw new Error("researcher settings missing");
const input: AgentSettingsInput = {
workspaceAccess: original.workspaceAccess === "none" ? "read-only" : "none",
browserAccess: original.browserAccess === "none" ? "read-only" : "none",
delegationEnabled: !original.delegationEnabled,
model: original.model,
tools: original.tools.includes("getTime") ? ["webSearch"] : ["getTime"],
name: `Test Researcher ${crypto.randomUUID().slice(0, 8)}`,
description: "Delegated test research",
instructions: `# Role: Test Researcher\n\nTest instructions ${crypto.randomUUID()}`,
};
try {
expect(await store.update("researcher", input)).toMatchObject(input);
expect(await new AgentSettingsStore().get("researcher")).toMatchObject(input);
} finally {
await store.update("researcher", original);
}
});
test("does not update an unknown agent", async () => {
expect(await store.update("missing", {
name: "Missing",
description: "Missing role",
instructions: "Missing instructions",
workspaceAccess: "read-only",
browserAccess: "none",
delegationEnabled: true,
model: null,
tools: ["webSearch"],
})).toBeUndefined();
});
test("rejects runtime instructions beyond the storage contract", async () => {
await expect(store.update("popagent", {
name: "popagent",
description: "Supervisor",
instructions: "x".repeat(MAX_AGENT_INSTRUCTIONS_CHARACTERS + 1),
workspaceAccess: "read-write",
browserAccess: "interactive",
delegationEnabled: false,
model: null,
tools: ["webSearch"],
})).rejects.toThrow(`Agent instructions exceed ${MAX_AGENT_INSTRUCTIONS_CHARACTERS} characters`);
});
test("rejects empty runtime identity fields", async () => {
await expect(store.update("popagent", {
name: " ",
description: "Supervisor",
instructions: "Instructions",
workspaceAccess: "read-write",
browserAccess: "interactive",
delegationEnabled: false,
model: null,
tools: ["webSearch"],
})).rejects.toThrow("Agent name, description, and instructions must not be empty");
});
});