fix(runtime): run pi tools sequentially

This commit is contained in:
ZacharyZhang-NY committed 2026-04-22 14:37:35 -04:00
1 parent 64842a9185
commit feffd72b98
2 files changed
+43

No files matched your search

@@ -87,5 +87,6 @@ export function createPiAgent(input: PiAgentFactoryInput): Agent {
beforeToolCall: hooks.beforeToolCall,
afterToolCall: hooks.afterToolCall,
transformContext: hooks.transformContext,
toolExecution: "sequential",
});
}
+42
View File
@@ -0,0 +1,42 @@
import type { Model } from "@mariozechner/pi-ai";
import { describe, expect, it } from "vitest";
import { createPiAgent } from "../../src/main/worker/runtime/pi-agent-factory";
import type { WorkerRpcClient } from "../../src/main/worker/entry/rpc";
function createModel(): Model<"openai-responses"> {
return {
id: "mock",
name: "mock",
api: "openai-responses",
provider: "openai",
baseUrl: "https://example.invalid",
reasoning: false,
input: ["text"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 8192,
maxTokens: 2048,
};
}
describe("pi agent factory", () => {
it("uses sequential tool execution for coding tools", () => {
const agent = createPiAgent({
runId: "run_1",
taskSessionId: "session_1",
systemPrompt: "You are an engineer.",
model: createModel(),
tools: [] as never,
priorMessages: [],
thinkingLevel: "off",
apiKey: "test-key",
extraHeaders: undefined,
rpc: {
invoke: async () => {
throw new Error("Unexpected RPC call in factory test.");
},
} as unknown as WorkerRpcClient,
});
expect(agent.toolExecution).toBe("sequential");
});
});