fix: harden sub-agent model overrides

This commit is contained in:
Peter Steinberger
2026-01-07 04:48:20 +00:00
parent 12d57da53a
commit 514fcfe77e
6 changed files with 113 additions and 11 deletions

View File

@@ -0,0 +1,28 @@
import { describe, expect, it } from "vitest";
import type { AgentTool } from "@mariozechner/pi-agent-core";
import { toToolDefinitions } from "./pi-tool-definition-adapter.js";
describe("pi tool definition adapter", () => {
it("wraps tool errors into a tool result", async () => {
const tool = {
name: "boom",
label: "Boom",
description: "throws",
parameters: {},
execute: async () => {
throw new Error("nope");
},
} satisfies AgentTool<unknown, unknown>;
const defs = toToolDefinitions([tool]);
const result = await defs[0].execute("call1", {}, undefined, undefined);
expect(result.details).toMatchObject({
status: "error",
tool: "boom",
});
expect(JSON.stringify(result.details)).toContain("nope");
});
});