Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix: drop null team-setup fields and blank model choices on propose_model and start_thread
AdityaUmale2523fdcf3550
diff --git a/server/drivers/agents-blank-arguments.ts b/server/drivers/agents-blank-arguments.tsindex b60ebbe5de..7e0670e694 100644--- a/server/drivers/agents-blank-arguments.ts+++ b/server/drivers/agents-blank-arguments.ts@@ -32,7 +32,8 @@ function withoutBlankModelChoice(selection: unknown): unknown {}/** Same for team setup: a create also carries a blank botId and an update a blank key, which the receiver refuses as- * unrecognized keys. A non-blank one is kept, so a real mistake is still named. */+ * unrecognized keys, and optional fields arrive as null. A non-blank one is kept, so a real mistake is still named; an+ * empty string field (a cleared description) is kept too. */function withoutBlankTeamSetupFields(input: Json): Json {if (!Array.isArray(input.operations)) return input;return {@@ -40,18 +41,24 @@ function withoutBlankTeamSetupFields(input: Json): Json {operations: input.operations.map((operation) => {if (!jsonRecord(operation)) return operation;const out = withoutBlank(operation, operation.action === "create" ? ["botId"] : operation.action === "update" ? ["key"] : []);- if (jsonRecord(out.fields) && out.fields.modelSelection !== undefined) {- out.fields = { ...out.fields, modelSelection: withoutBlankModelChoice(out.fields.modelSelection) };+ if (jsonRecord(out.fields)) {+ const fields = withoutBlank(out.fields, Object.keys(out.fields), (value) => value === null);+ if (fields.modelSelection !== undefined) fields.modelSelection = withoutBlankModelChoice(fields.modelSelection);+ out.fields = fields;}return out;}),};}+/** Tools whose model choice (effort / variant) strict engines fill with blanks, and the argument that holds it. */+const MODEL_CHOICE_ARGUMENT: Readonly<Record<string, string>> = { create_bot: "modelSelection", propose_model: "model_selection", start_thread: "model_selection" };+export function dropBlankArguments(name: string, input: Json): Json {if (!jsonRecord(input)) return input;if (name === "propose_team_setup") return withoutBlankTeamSetupFields(input);- if (name === "create_bot" && input.modelSelection !== undefined) return { ...input, modelSelection: withoutBlankModelChoice(input.modelSelection) };+ const selectionKey = Object.hasOwn(MODEL_CHOICE_ARGUMENT, name) ? MODEL_CHOICE_ARGUMENT[name] : undefined;+ if (selectionKey && input[selectionKey] !== undefined) return { ...input, [selectionKey]: withoutBlankModelChoice(input[selectionKey]) };const keys = Object.hasOwn(BLANK_MEANS_LEFT_OUT, name) ? BLANK_MEANS_LEFT_OUT[name] : undefined;return keys ? withoutBlank(input, keys, blankText) : input;}diff --git a/server/drivers/agents-call.test.ts b/server/drivers/agents-call.test.tsindex 15ca8bad36..8f575656a8 100644--- a/server/drivers/agents-call.test.ts+++ b/server/drivers/agents-call.test.ts@@ -136,6 +136,37 @@ describe("team creation with every optional field filled in", () => {recording(calls, { id: "b1", name: "Scout" }));expect(calls[0].body.modelSelection).toEqual({ instanceId: "codex", model: "gpt-5" });});++ it("propose_team_setup drops null optional fields but keeps an empty description", async () => {+ const calls: Array<{ path: string; body: any }> = [];+ await callTool("propose_team_setup", {+ reason: "Shop team",+ operations: [+ { action: "create", key: "buyer", fields: { name: "Buyer", description: null, cwd: null, chiefOfStaff: null } },+ { action: "update", botId: "b-1", fields: { description: "" } },+ ],+ }, recording(calls, { state: "applied" }));+ expect(calls[0].body.plan.operations).toEqual([+ { action: "create", key: "buyer", fields: { name: "Buyer" } },+ { action: "update", botId: "b-1", fields: { description: "" } },+ ]);+ });++ it("propose_model drops blank effort and variant from the model choice", async () => {+ const calls: Array<{ path: string; body: any }> = [];+ const result = await callTool("propose_model", { model_selection: { instanceId: "codex", model: "gpt-5", effort: "", variant: null }, reason: "Faster." },+ recording(calls, { state: "applied" }));+ expect(result.isError).toBeFalsy();+ expect(calls[0].body.modelSelection).toEqual({ instanceId: "codex", model: "gpt-5" });+ });++ it("start_thread drops a blank effort from the model choice", async () => {+ const calls: Array<{ path: string; body: any }> = [];+ const result = await callTool("start_thread", { title: "Review", message: "Review it.", model_selection: { instanceId: "codex", model: "gpt-5", effort: " " } },+ recording(calls, { self: true, state: "queued", threadId: "t-1", title: "Review" }));+ expect(result.isError).toBeFalsy();+ expect(calls[0].body.modelSelection).toEqual({ instanceId: "codex", model: "gpt-5" });+ });});describe("mcp_server", () => {