Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix: preserve complete native model catalogs and Custom selection (#888)
Gustavo Ye82a76614285a
diff --git a/src/daemon/agent-driver/src/adapters/antigravity/catalog.test.ts b/src/daemon/agent-driver/src/adapters/antigravity/catalog.test.tsindex 8884ebd43..4cddc23e1 100644--- a/src/daemon/agent-driver/src/adapters/antigravity/catalog.test.ts+++ b/src/daemon/agent-driver/src/adapters/antigravity/catalog.test.ts@@ -1,7 +1,15 @@+import { RUNTIME_MODEL_CATALOG_MAX } from "../../internal/modelCatalog.js";import { describe, expect, it } from "vitest";import { antigravityModelForEffort, antigravityReasoningCatalog, parseAntigravityCatalog } from "./catalog.js";describe("Antigravity native model variants", () => {+ it.each([1024, 1025])("keeps the complete catalog or rejects overflow (%s models)", (count) => {+ const models = Array.from({ length: count }, (_, index) => `model-${index}`);+ const catalog = parseAntigravityCatalog({ models: { availableModels: models.map((modelId) => ({ modelId })) } });+ if (count > RUNTIME_MODEL_CATALOG_MAX) expect(catalog).toBeUndefined();+ else expect(catalog?.models.map((model) => model.id)).toEqual(models);+ });+it("preserves returned choices and maps effort only to offered siblings", () => {const models = ["gemini-3.8-flash-high", "gemini-3.8-flash-low", "gemini-3.1-pro-low", "other-high"];const catalog = parseAntigravityCatalog({ models: { currentModelId: models[0], availableModels: models.map((modelId) => ({ modelId, name: modelId })) } })!;@@ -20,7 +28,7 @@ describe("Antigravity native model variants", () => {id: "native-model", category: "model", type: "select", currentValue: "actual",options: [{ group: "g", options: [{ value: "actual", name: "Actual" }, { value: "actual" }, { value: "invalid model" }] }],}] })).toEqual({ configId: "native-model", currentModelId: "actual", models: [{ id: "actual", displayName: "Actual" }] });- expect(parseAntigravityCatalog({ models: { availableModels: Array.from({ length: 513 }, (_, i) => ({ modelId: `model-${i}` })) } })).toBeUndefined();+ expect(parseAntigravityCatalog({ models: { availableModels: Array.from({ length: RUNTIME_MODEL_CATALOG_MAX + 1 }, (_, i) => ({ modelId: `model-${i}` })) } })).toBeUndefined();expect(parseAntigravityCatalog(null)).toBeUndefined();});});diff --git a/src/daemon/agent-driver/src/adapters/codex/index.test.ts b/src/daemon/agent-driver/src/adapters/codex/index.test.tsindex b386deefe..95c862c96 100644--- a/src/daemon/agent-driver/src/adapters/codex/index.test.ts+++ b/src/daemon/agent-driver/src/adapters/codex/index.test.ts@@ -4,6 +4,7 @@ import * as fs from "fs";import * as os from "os";import * as path from "path";import { CodexDriver } from "./index.js";+import { RUNTIME_MODEL_CATALOG_MAX } from "../../internal/modelCatalog.js";import type { AdapterLaunchContext } from "../../internal/adapter.js";import { fakeLaunchContext } from "../../testing/adapter-fixture.js";@@ -258,24 +259,50 @@ describe("CodexDriver reasoning catalog probe", () => {});});- it("returns no catalog rather than a truncated list when pagination exceeds 512 models", async () => {- const models = Array.from({ length: 512 }, (_, index) => ({+ it.each([false, true])("handles the exact catalog bound across distinct pages (hasNext=%s)", async (hasNext) => {+ const models = Array.from({ length: RUNTIME_MODEL_CATALOG_MAX }, (_, index) => ({id: `gpt-model-${index}`,supportedReasoningEfforts: [],}));- const proc = probingProcess((request) => request.method === "initialize"- ? { jsonrpc: "2.0", id: request.id, result: {} }- : { jsonrpc: "2.0", id: request.id, result: { data: models, nextCursor: "more" } });+ const cursors: unknown[] = [];+ const proc = probingProcess((request) => {+ if (request.method === "initialize") return { jsonrpc: "2.0", id: request.id, result: {} };+ cursors.push(request.params.cursor);+ const page = request.params.cursor ? Number(request.params.cursor) : 0;+ const end = Math.min((page + 1) * 100, models.length);+ return { jsonrpc: "2.0", id: request.id, result: {+ data: models.slice(page * 100, end),+ nextCursor: end < models.length || hasNext ? String(page + 1) : null,+ } };+ });runtimeMocks.spawnAgentProcess.mockReturnValueOnce(proc as never);- await expect(new CodexDriver().probe()).resolves.toMatchObject({- status: "healthy",- reasoning: undefined,+ const result = await new CodexDriver().probe();+ expect(result.status).toBe("healthy");+ if (hasNext) expect(result.reasoning).toBeUndefined();+ else expect(result.reasoning?.models.map((model) => model.id)).toEqual(models.map((model) => model.id));+ expect(cursors).toEqual([undefined, ...Array.from({ length: 10 }, (_, index) => String(index + 1))]);+ });++ it("returns no catalog for 1025 unique models across distinct pages", async () => {+ const models = Array.from({ length: RUNTIME_MODEL_CATALOG_MAX + 1 }, (_, index) => ({+ id: `gpt-model-${index}`,+ supportedReasoningEfforts: [],+ }));+ const proc = probingProcess((request) => {+ if (request.method === "initialize") return { jsonrpc: "2.0", id: request.id, result: {} };+ const page = request.params.cursor ? Number(request.params.cursor) : 0;+ const end = Math.min((page + 1) * 100, models.length);+ return { jsonrpc: "2.0", id: request.id, result: {+ data: models.slice(page * 100, end), nextCursor: end < models.length ? String(page + 1) : null,+ } };});+ runtimeMocks.spawnAgentProcess.mockReturnValueOnce(proc as never);+ await expect(new CodexDriver().probe()).resolves.toMatchObject({ reasoning: undefined });});- it("returns no catalog when a producer ignores the page limit and sends 513 unique models", async () => {- const models = Array.from({ length: 513 }, (_, index) => ({+ it("returns no catalog when a producer ignores the page limit and sends 1025 unique models", async () => {+ const models = Array.from({ length: RUNTIME_MODEL_CATALOG_MAX + 1 }, (_, index) => ({id: `gpt-model-${index}`,supportedReasoningEfforts: [],}));@@ -283,7 +310,6 @@ describe("CodexDriver reasoning catalog probe", () => {? { jsonrpc: "2.0", id: request.id, result: {} }: { jsonrpc: "2.0", id: request.id, result: { data: models, nextCursor: null } });runtimeMocks.spawnAgentProcess.mockReturnValueOnce(proc as never);-await expect(new CodexDriver().probe()).resolves.toMatchObject({ reasoning: undefined });});diff --git a/src/daemon/agent-driver/src/adapters/cursor/catalog-probe.test.ts b/src/daemon/agent-driver/src/adapters/cursor/catalog-probe.test.tsindex 9defa71d4..925c80bfe 100644--- a/src/daemon/agent-driver/src/adapters/cursor/catalog-probe.test.ts+++ b/src/daemon/agent-driver/src/adapters/cursor/catalog-probe.test.ts@@ -1,3 +1,4 @@+import { RUNTIME_MODEL_CATALOG_MAX } from "../../internal/modelCatalog.js";import { EventEmitter } from "node:events";import { PassThrough } from "node:stream";import { describe, expect, it, vi } from "vitest";@@ -44,6 +45,13 @@ function respond(process: FakeProcess, request: Record<string, unknown>, result:}describe("Cursor ACP model catalog", () => {+ it.each([1024, 1025])("keeps the complete catalog or rejects overflow (%s models)", (count) => {+ const models = Array.from({ length: count }, (_, index) => `model-${index}`);+ const catalog = parseCursorAcpModelCatalog({ configOptions: [{ id: "model", options: models.map((id) => ({ value: id })) }] });+ if (count > RUNTIME_MODEL_CATALOG_MAX) expect(catalog).toBeUndefined();+ else expect(catalog?.models.map((model) => model.id)).toEqual(models);+ });+it("normalizes nested exact values, preserves duplicate labels, and omits ACP Auto", () => {expect(parseCursorAcpModelCatalog({sessionId: "probe",@@ -98,7 +106,7 @@ describe("Cursor ACP model catalog", () => {expect(parseCursorAcpModelCatalog({configOptions: [{id: "model",- options: Array.from({ length: 513 }, (_, index) => ({ value: `model-${index}` })),+ options: Array.from({ length: RUNTIME_MODEL_CATALOG_MAX + 1 }, (_, index) => ({ value: `model-${index}` })),}],})).toBeUndefined();});diff --git a/src/daemon/agent-driver/src/adapters/grok/index.test.ts b/src/daemon/agent-driver/src/adapters/grok/index.test.tsindex 97b1ea827..37245bade 100644--- a/src/daemon/agent-driver/src/adapters/grok/index.test.ts+++ b/src/daemon/agent-driver/src/adapters/grok/index.test.ts@@ -1,3 +1,4 @@+import { RUNTIME_MODEL_CATALOG_MAX } from "../../internal/modelCatalog.js";import { EventEmitter } from "node:events";import { mkdtempSync, rmSync } from "node:fs";import { tmpdir } from "node:os";@@ -68,6 +69,13 @@ const modelState = {};describe("Grok ACP model catalog", () => {+ it.each([1024, 1025])("keeps the complete catalog or rejects overflow (%s models)", (count) => {+ const models = Array.from({ length: count }, (_, index) => `model-${index}`);+ const catalog = parseGrokModelCatalog({ availableModels: models.map((modelId) => ({ modelId })) });+ if (count > RUNTIME_MODEL_CATALOG_MAX) expect(catalog).toBeUndefined();+ else expect(catalog?.models.map((model) => model.id)).toEqual(models);+ });+it("preserves provider ids and dynamic reasoning values", () => {expect(parseGrokModelCatalog(modelState)).toEqual({updateMode: "live_next_turn",diff --git a/src/daemon/agent-driver/src/internal/modelCatalog.test.ts b/src/daemon/agent-driver/src/internal/modelCatalog.test.tsindex 419f0d246..604fc40f5 100644--- a/src/daemon/agent-driver/src/internal/modelCatalog.test.ts+++ b/src/daemon/agent-driver/src/internal/modelCatalog.test.ts@@ -35,6 +35,17 @@ describe("runtime startup model catalog parsers", () => {expect(parsePiModelCatalog([{ nope: true }])).toBeUndefined();});+ it("preserves a 598-model OpenCode catalog without losing its first or last model", () => {+ const models = Array.from({ length: 598 }, (_, index) => `provider/model-${index}`);+ expect(ids(parseOpenCodeModelCatalog([...models, models[0]!].join("\n")))).toEqual(models);+ });++ it("accepts the complete catalog at the bound for both producers", () => {+ const models = Array.from({ length: RUNTIME_MODEL_CATALOG_MAX }, (_, index) => `provider/model-${index}`);+ expect(ids(parseOpenCodeModelCatalog(models.join("\n")))).toEqual(models);+ expect(ids(parsePiModelCatalog(models.map((id) => ({ provider: "provider", id: id.slice(9) }))))).toEqual(models);+ });+it("returns no catalog instead of truncating when unique IDs overflow the bound", () => {const opencode = Array.from({ length: RUNTIME_MODEL_CATALOG_MAX + 1 },diff --git a/src/daemon/agent-driver/src/internal/modelCatalog.ts b/src/daemon/agent-driver/src/internal/modelCatalog.tsindex f93cfce4c..2c05f0418 100644--- a/src/daemon/agent-driver/src/internal/modelCatalog.ts+++ b/src/daemon/agent-driver/src/internal/modelCatalog.ts@@ -1,6 +1,6 @@import type { RuntimeReasoningCatalog } from "../contract.js";-export const RUNTIME_MODEL_CATALOG_MAX = 512;+export const RUNTIME_MODEL_CATALOG_MAX = 1024;const RUNTIME_MODEL_ID_MAX = 100;export function normalizeRuntimeModelId(value: unknown): string | undefined {diff --git a/src/shared/src/schemas.test.ts b/src/shared/src/schemas.test.tsindex 3f7046b60..562c6e204 100644--- a/src/shared/src/schemas.test.ts+++ b/src/shared/src/schemas.test.ts@@ -12,8 +12,34 @@ import {BotAuditEventSchema,BotAuditEventKindSchema,CommunityAgentNapRequestSchema,+ CommunityMachineRuntimeSchema,+ RuntimeReasoningCatalogSchema,+ COMMUNITY_REASONING_MODELS_MAX,} from "./schemas"+describe("large runtime model catalogs", () => {+ const catalog = (count: number) => ({+ updateMode: "unsupported" as const,+ models: Array.from({ length: count }, (_, index) => ({+ id: `provider/model-${index}`,+ supportedReasoningEfforts: [],+ })),+ })++ it("retains all 598 models through the machine runtime wire schema", () => {+ const reasoning = catalog(598)+ const runtime = CommunityMachineRuntimeSchema.parse({ id: "opencode", reasoning })+ expect(runtime.reasoning).toEqual(reasoning)+ })++ it("accepts the full bound and rejects overflow without returning a partial catalog", () => {+ expect(RuntimeReasoningCatalogSchema.parse(catalog(COMMUNITY_REASONING_MODELS_MAX)))+ .toEqual(catalog(COMMUNITY_REASONING_MODELS_MAX))+ expect(RuntimeReasoningCatalogSchema.safeParse(catalog(COMMUNITY_REASONING_MODELS_MAX + 1)).success)+ .toBe(false)+ })+})+const usageSnapshot = (index: number) => ({botId: "bot_1",day: `2026-08-${String(index + 1).padStart(2, "0")}`,diff --git a/src/shared/src/schemas.ts b/src/shared/src/schemas.tsindex 33fa4c89d..eed16a669 100644--- a/src/shared/src/schemas.ts+++ b/src/shared/src/schemas.ts@@ -839,7 +839,7 @@ const REASONING_EFFORT_RE = /^[A-Za-z0-9._-]+$/;export const COMMUNITY_REASONING_EFFORT_MAX = 32;export const COMMUNITY_REASONING_DESCRIPTION_MAX = 256;export const COMMUNITY_REASONING_OPTIONS_MAX = 16;-export const COMMUNITY_REASONING_MODELS_MAX = 512;+export const COMMUNITY_REASONING_MODELS_MAX = 1024;export const ReasoningEffortSchema = z.string()diff --git a/src/web/src/components/community/bots/model-field.dom.test.ts b/src/web/src/components/community/bots/model-field.dom.test.tsindex 68982ff60..780aad8a2 100644--- a/src/web/src/components/community/bots/model-field.dom.test.ts+++ b/src/web/src/components/community/bots/model-field.dom.test.ts@@ -1,5 +1,6 @@import { describe, it, expect, vi } from "vitest"import React from "react"+import { useAtom, useCreateAtom } from "@tanstack/react-store"import { act, fireEvent, render as rtlRender } from "@/test/react-dom-harness"// Mock the Select shell to a passthrough that records the current value and exposes an onValueChange@@ -201,6 +202,35 @@ describe("ModelField", () => {expect(onChange).toHaveBeenLastCalledWith(null)})+ it("preserves Custom through controlled value echoes and re-seeds external changes", () => {+ const first = runtime("opencode", ["provider/tail"])+ const second = runtime("opencode", ["provider/other"])+ const values: Array<string | null> = []+ function Controlled({ selectedRuntime }: { selectedRuntime: typeof first }) {+ const [value, setValue] = useAtom(useCreateAtom<string | null>("provider/tail"))+ return React.createElement(React.Fragment, {},+ React.createElement(ModelField, { runtime: selectedRuntime, value, onChange: (next) => { values.push(next); setValue(next) } }),+ React.createElement("button", { onClick: () => setValue("external/model") }, "External model"),+ )+ }+ const renderer = rtlRender(React.createElement(Controlled, { selectedRuntime: first }))+ act(() => selectCalls.at(-1)!.onValueChange("__custom__"))+ expect(renderer.getByTestId("bot-model-custom-input")).toHaveValue("")+ expect(values.at(-1)).toBeNull()+ fireEvent.change(renderer.getByTestId("bot-model-custom-input"), { target: { value: "custom/model" } })+ expect(values.at(-1)).toBe("custom/model")+ fireEvent.change(renderer.getByTestId("bot-model-custom-input"), { target: { value: "" } })+ expect(renderer.getByTestId("bot-model-custom-input")).toHaveValue("")+ expect(values.at(-1)).toBeNull()+ act(() => renderer.rerender(React.createElement(Controlled, { selectedRuntime: second })))+ expect(renderer.queryAllByTestId("bot-model-custom-input")).toHaveLength(0)+ fireEvent.click(renderer.getByText("External model"))+ expect(renderer.getByTestId("bot-model-custom-input")).toHaveValue("external/model")+ act(() => selectCalls.at(-1)!.onValueChange("__default__"))+ expect(renderer.queryAllByTestId("bot-model-custom-input")).toHaveLength(0)+ expect(values.at(-1)).toBeNull()+ })+it("filters a 204-item catalog by case-insensitive substring while keeping Default and Custom", () => {const models = Array.from({ length: 204 }, (_, index) => `Cursor-MODEL-${index}`)const renderer = render({ runtime: runtime("cursor", models), value: null })@@ -219,11 +249,18 @@ describe("ModelField", () => {])})- it("shows an explicit no-match state for a 479-item catalog and keeps Custom usable", () => {- const models = Array.from({ length: 479 }, (_, index) => `provider/model-${index}`)- const renderer = render({ runtime: runtime("opencode", models), value: null })+ it("shows all 598 OpenCode models, selects the catalog tail, and keeps Custom usable after no match", () => {+ const models = Array.from({ length: 598 }, (_, index) => `provider/model-${index}`)+ const onChange = vi.fn()+ const renderer = render({ runtime: runtime("opencode", models), value: null, onChange })+ expect(itemValues(renderer)).toEqual(["__default__", "__custom__", ...models])const filter = renderer.getByTestId("bot-model-filter-input")+ fireEvent.change(filter, { target: { value: "model-597" } })+ expect(itemValues(renderer)).toEqual(["__default__", "__custom__", models[597]])+ act(() => selectCalls.at(-1)!.onValueChange(models[597]))+ expect(onChange).toHaveBeenLastCalledWith(models[597])+fireEvent.change(filter, { target: { value: "not-in-catalog" } })expect(itemValues(renderer)).toEqual(["__default__", "__custom__"])diff --git a/src/web/src/components/community/bots/model-field.tsx b/src/web/src/components/community/bots/model-field.tsxindex 9f70ba485..cfc6198d2 100644--- a/src/web/src/components/community/bots/model-field.tsx+++ b/src/web/src/components/community/bots/model-field.tsx@@ -54,15 +54,19 @@ export function ModelField({const [selectValue, setSelectValue] = useAtom(useCreateAtom(seed.selectValue))const [customName, setCustomName] = useAtom(useCreateAtom(seed.customName))const [filterQuery, setFilterQuery] = useAtom(useCreateAtom(""))+ const localChange = useCreateAtom<{ runtime: typeof runtime; value: string | null } | null>(null)// Re-seed whenever the selected machine/runtime snapshot or stored value// changes. This is required even when the stored string is unchanged: a// value can be a reported option on machine A and Custom… on machine B.useEffect(() => {+ const change = localChange.get()+ localChange.set(null)+ if (change && change.runtime === runtime && change.value === value) returnsetSelectValue(seed.selectValue)setCustomName(seed.customName)setFilterQuery("")- }, [seed, setCustomName, setFilterQuery, setSelectValue])+ }, [seed, runtime, value, localChange, setCustomName, setFilterQuery, setSelectValue])const isCustom = selectValue === MODEL_SELECT_CUSTOMconst defaultLabel = runtime ? `Default (${runtime.id}'s own default)` : "Default"@@ -103,7 +107,9 @@ export function ModelField({setSelectValue(nextValue)// Custom… keeps the text field revealed even when empty (emits null// until something is typed); any other value maps through the helper.- onChange(modelNameFromSelect(nextValue, customName))+ const nextModel = modelNameFromSelect(nextValue, customName)+ localChange.set({ runtime, value: nextModel })+ onChange(nextModel)}}onOpenChange={(open) => {if (!open) setFilterQuery("")@@ -192,7 +198,9 @@ export function ModelField({placeholder="e.g. provider/model-id"onChange={(e) => {setCustomName(e.target.value)- onChange(modelNameFromSelect(MODEL_SELECT_CUSTOM, e.target.value))+ const nextModel = modelNameFromSelect(MODEL_SELECT_CUSTOM, e.target.value)+ localChange.set({ runtime, value: nextModel })+ onChange(nextModel)}}className="h-11 font-mono sm:h-8"/>