fix: stabilize session tools and tests

This commit is contained in:
Peter Steinberger
2026-01-12 18:17:17 +00:00
parent 3ffb9a3b5e
commit 77b20377cc
4 changed files with 77 additions and 67 deletions

View File

@@ -44,11 +44,13 @@ export function createClawdbotTools(options?: {
/** Mutable ref to track if a reply was sent (for "first" mode). */ /** Mutable ref to track if a reply was sent (for "first" mode). */
hasRepliedRef?: { value: boolean }; hasRepliedRef?: { value: boolean };
}): AnyAgentTool[] { }): AnyAgentTool[] {
const imageTool = createImageTool({ const imageTool = options?.agentDir?.trim()
? createImageTool({
config: options?.config, config: options?.config,
agentDir: options?.agentDir, agentDir: options.agentDir,
sandboxRoot: options?.sandboxRoot, sandboxRoot: options?.sandboxRoot,
}); })
: null;
const memorySearchTool = createMemorySearchTool({ const memorySearchTool = createMemorySearchTool({
config: options?.config, config: options?.config,
agentSessionKey: options?.agentSessionKey, agentSessionKey: options?.agentSessionKey,

View File

@@ -703,7 +703,10 @@ describe("runEmbeddedPiAgent", () => {
).resolves.toBeTruthy(); ).resolves.toBeTruthy();
}); });
it("persists the first user message before assistant output", async () => { it(
"persists the first user message before assistant output",
{ timeout: 15_000 },
async () => {
const agentDir = await fs.mkdtemp( const agentDir = await fs.mkdtemp(
path.join(os.tmpdir(), "clawdbot-agent-"), path.join(os.tmpdir(), "clawdbot-agent-"),
); );
@@ -741,7 +744,8 @@ describe("runEmbeddedPiAgent", () => {
if (firstAssistantIndex !== -1) { if (firstAssistantIndex !== -1) {
expect(firstUserIndex).toBeLessThan(firstAssistantIndex); expect(firstUserIndex).toBeLessThan(firstAssistantIndex);
} }
}, 15_000); },
);
it("persists the user message when prompt fails before assistant output", async () => { it("persists the user message when prompt fails before assistant output", async () => {
const agentDir = await fs.mkdtemp( const agentDir = await fs.mkdtemp(

View File

@@ -14,7 +14,10 @@ vi.mock("../commands/models.js", async () => {
}); });
describe("models cli", () => { describe("models cli", () => {
it("registers github-copilot login command", async () => { it(
"registers github-copilot login command",
{ timeout: 15_000 },
async () => {
const { Command } = await import("commander"); const { Command } = await import("commander");
const { registerModelsCli } = await import("./models-cli.js"); const { registerModelsCli } = await import("./models-cli.js");
@@ -44,5 +47,6 @@ describe("models cli", () => {
expect.objectContaining({ yes: true }), expect.objectContaining({ yes: true }),
expect.any(Object), expect.any(Object),
); );
}, 15_000); },
);
}); });

View File

@@ -325,7 +325,7 @@ vi.mock("./doctor-state-migrations.js", () => ({
describe("doctor", () => { describe("doctor", () => {
it( it(
"migrates routing.allowFrom to whatsapp.allowFrom", "migrates routing.allowFrom to whatsapp.allowFrom",
{ timeout: 15_000 }, { timeout: 30_000 },
async () => { async () => {
readConfigFileSnapshot.mockResolvedValue({ readConfigFileSnapshot.mockResolvedValue({
path: "/tmp/clawdbot.json", path: "/tmp/clawdbot.json",