Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

agents-schema test: a blank start_thread effort is left out, not refused (#5141)

milind-sonic408012e29a5
diff --git a/server/drivers/agents-schema.test.ts b/server/drivers/agents-schema.test.ts
index 1c4742e63b..1d628c0d40 100644
--- a/server/drivers/agents-schema.test.ts
+++ b/server/drivers/agents-schema.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import { WATCHER_OPTIONS_CARD_BOT_ID } from "../../shared/options-card.ts";
+import { dropBlankArguments } from "./agents-blank-arguments.ts";
import { callTool, type ToolCallContext } from "./agents-call.ts";
import { availableTools, catalogProfileFromEnv, fullInputSchema } from "./agents-catalog.ts";
import type { Json } from "./agents-client.ts";
@@ -116,7 +117,12 @@ describe("the advertised agents tool schemas", () => {
});
describe("every agents call is held to its full schema", () => {
- const cases = LISTED.flatMap((tool) => bounds(fullInputSchema(tool.name)).map((bound) => [`${tool.name} ${bound.path.join(".")} ${bound.keyword}`, tool.name, bound] as const));
+ const all = LISTED.flatMap((tool) => bounds(fullInputSchema(tool.name)).map((bound) => [`${tool.name} ${bound.path.join(".")} ${bound.keyword}`, tool.name, bound] as const));
+ const blankLeftOut = ([, tool, bound]: (typeof all)[number]) => {
+ const args = argumentsBreaking(bound);
+ return JSON.stringify(dropBlankArguments(tool, args)) !== JSON.stringify(args);
+ };
+ const cases = all.filter((one) => !blankLeftOut(one));
it("covers every bound of every listed tool", () => {
expect(cases.length).toBeGreaterThan(80);
@@ -131,6 +137,14 @@ describe("every agents call is held to its full schema", () => {
expect(calls).toEqual([]);
});
+ it("reads a blank model effort as left out, not as a value out of bounds", () => {
+ expect(all.filter(blankLeftOut).map(([label]) => label)).toEqual(["start_thread model_selection.effort minLength"]);
+ const args = { title: "t", message: "m", model_selection: { instanceId: "codex", model: "gpt", effort: "" } };
+ expect(dropBlankArguments("start_thread", args)).toEqual({ title: "t", message: "m", model_selection: { instanceId: "codex", model: "gpt" } });
+ expect(outOfBounds("start_thread", fullInputSchema("start_thread"), dropBlankArguments("start_thread", args))).toBeUndefined();
+ expect(outOfBounds("start_thread", fullInputSchema("start_thread"), args)).toContain("effort");
+ });
+
it("reads a null as a field left out, and names every problem up to four", () => {
const schema = fullInputSchema("coordinate_bots");
expect(outOfBounds("coordinate_bots", schema, { bot_ids: ["a"], message: "hi", title: null, reason: null })).toBeUndefined();