From e1df942430f3d4a2b2f23ce988bb893772f74f77 Mon Sep 17 00:00:00 2001 From: Bryant Derosier Date: Tue, 27 Oct 2026 19:16:37 -0400 Subject: [PATCH 1/6] feat(contracts): a second allowlist for custom members' reasoning levels (reasoning levels) Co-Authored-By: Claude Sonnet 5.5 --- packages/contracts/src/j5.ts | 1 + packages/contracts/src/j5/crewMemberModels.ts | 2 +- .../src/j5/crewMemberReasoning.test.ts | 161 ++++++++++++++++++ .../contracts/src/j5/crewMemberReasoning.ts | 140 +++++++++++++++ packages/contracts/src/settings.ts | 6 + packages/shared/src/projectSettings.test.ts | 25 +++ 6 files changed, 334 insertions(+), 1 deletion(-) create mode 100644 packages/contracts/src/j5/crewMemberReasoning.test.ts create mode 100644 packages/contracts/src/j5/crewMemberReasoning.ts diff --git a/packages/contracts/src/j5.ts b/packages/contracts/src/j5.ts index 8ce683e93a29f..9a5f5f1c4cef7 100644 --- a/packages/contracts/src/j5.ts +++ b/packages/contracts/src/j5.ts @@ -8,6 +8,7 @@ export * from "./j5/peerPoll.ts"; export * from "./j5/playbook.ts"; export * from "./j5/access.ts"; export * from "./j5/crewMemberModels.ts"; +export * from "./j5/crewMemberReasoning.ts"; export * from "./j5/levels.ts"; export * from "./j5/people.ts"; export * from "./j5/sharedConversation.ts"; diff --git a/packages/contracts/src/j5/crewMemberModels.ts b/packages/contracts/src/j5/crewMemberModels.ts index 12317b1c2ad6e..52457352a5c87 100644 --- a/packages/contracts/src/j5/crewMemberModels.ts +++ b/packages/contracts/src/j5/crewMemberModels.ts @@ -20,7 +20,7 @@ export type CrewMemberModel = typeof CrewMemberModel.Type; export const CrewMemberModels = Schema.NullOr(Schema.Array(CrewMemberModel)); export type CrewMemberModels = typeof CrewMemberModels.Type; -const CREW_MEMBER_MODELS_SETTING_LABEL = "Models for custom members in Agent Setup"; +export const CREW_MEMBER_MODELS_SETTING_LABEL = "Models for custom members in Agent Setup"; type ModelKey = Pick; diff --git a/packages/contracts/src/j5/crewMemberReasoning.test.ts b/packages/contracts/src/j5/crewMemberReasoning.test.ts new file mode 100644 index 0000000000000..d3b8f5ba5dc70 --- /dev/null +++ b/packages/contracts/src/j5/crewMemberReasoning.test.ts @@ -0,0 +1,161 @@ +import { describe, expect, it } from "vite-plus/test"; + +import type { ProviderOptionDescriptor } from "../model.ts"; +import { ProviderInstanceId } from "../providerInstance.ts"; +import type { ServerProvider } from "../server.ts"; +import { + crewMemberLevelCounts, + crewMemberProviderLevels, + crewMemberReasoningRefusal, + crewMemberSelectionLevel, + eligibleCrewMemberLevels, + eligibleCrewMemberLevelsForModel, + isCrewMemberLevelChecked, +} from "./crewMemberReasoning.ts"; + +const effort = ( + ids: ReadonlyArray, + input: { readonly id?: string; readonly defaultId?: string } = {}, +): ProviderOptionDescriptor => ({ + id: input.id ?? "reasoningEffort", + label: "Reasoning", + type: "select", + options: ids.map((id) => ({ + id, + label: id.toUpperCase(), + ...(id === input.defaultId ? { isDefault: true } : {}), + })), +}); + +const thinking: ProviderOptionDescriptor = { id: "thinking", label: "Thinking", type: "boolean" }; + +const model = (slug: string, descriptors?: ReadonlyArray) => ({ + slug, + name: slug.toUpperCase(), + capabilities: descriptors === undefined ? null : { optionDescriptors: [...descriptors] }, +}); + +const provider = ( + instanceId: string, + models: ReadonlyArray>, + overrides: Partial = {}, +) => + ({ + instanceId: ProviderInstanceId.make(instanceId), + driver: "codex", + enabled: true, + installed: true, + status: "ready", + availability: "available", + models, + ...overrides, + }) as unknown as ServerProvider; + +const codex = ProviderInstanceId.make("codex"); +const claude = ProviderInstanceId.make("claude"); +const checked = (...levels: ReadonlyArray) => + levels.map((level) => ({ instanceId: codex, level })); + +describe("crew member reasoning levels", () => { + const providers = [ + provider("codex", [ + model("a", [effort(["low", "high"], { defaultId: "high" })]), + model("b", [effort(["medium", "high", "xhigh"])]), + model("plain"), + ]), + provider("claude", [model("x", [thinking, effort(["low", "max"], { id: "effort" })])]), + ]; + + it("derives a provider's levels as the union of its models' choices, in order of first appearance", () => { + expect(crewMemberProviderLevels(providers[0]!).map(({ level }) => level)).toEqual([ + "low", + "high", + "medium", + "xhigh", + ]); + expect(crewMemberProviderLevels(providers[0]!)[0]).toEqual({ level: "low", label: "LOW" }); + }); + + it("ignores boolean thinking options and options that are not reasoning", () => { + const onlyBoolean = provider("grok", [model("g", [thinking, effort(["a"], { id: "mode" })])]); + expect(crewMemberProviderLevels(onlyBoolean)).toEqual([]); + expect(crewMemberProviderLevels(providers[1]!).map(({ level }) => level)).toEqual([ + "low", + "max", + ]); + }); + + it("makes every level eligible until a list is saved", () => { + expect(isCrewMemberLevelChecked(null, { instanceId: codex, level: "anything" })).toBe(true); + expect(eligibleCrewMemberLevels(null, providers)).toHaveLength(6); + expect(crewMemberLevelCounts(null, providers)).toEqual({ checked: 6, total: 6 }); + }); + + it("makes only the checked levels eligible, per provider instance, so a new level starts unchecked", () => { + const list = checked("low", "high"); + expect(isCrewMemberLevelChecked(list, { instanceId: codex, level: "xhigh" })).toBe(false); + // The same id on another instance is another level. + expect(isCrewMemberLevelChecked(list, { instanceId: claude, level: "low" })).toBe(false); + expect(crewMemberLevelCounts(list, providers)).toEqual({ checked: 2, total: 6 }); + }); + + it("keeps stale entries out of the count and the eligible list", () => { + const list = checked("low", "retired"); + expect(crewMemberLevelCounts(list, providers)).toEqual({ checked: 1, total: 6 }); + expect(eligibleCrewMemberLevels(list, providers).map(({ level }) => level)).toEqual(["low"]); + }); + + it("treats a saved empty list as nothing eligible", () => { + expect(eligibleCrewMemberLevels([], providers)).toEqual([]); + expect(crewMemberLevelCounts([], providers)).toEqual({ checked: 0, total: 6 }); + }); + + it("offers only levels of providers that are set up", () => { + const all = [ + ...providers, + provider("cursor", [model("z", [effort(["q"])])], { status: "error" }), + ]; + expect(crewMemberLevelCounts(null, all)).toEqual({ checked: 6, total: 6 }); + }); + + it("lists the eligible levels of one model in its own order", () => { + expect( + eligibleCrewMemberLevelsForModel(checked("xhigh", "high"), providers[0]!, "b").map( + ({ level }) => level, + ), + ).toEqual(["high", "xhigh"]); + expect(eligibleCrewMemberLevelsForModel(null, providers[0]!, "plain")).toEqual([]); + }); + + it("reads a selection's level from its explicit value, else the model's default", () => { + const a = providers[0]!.models[0]!; + expect(crewMemberSelectionLevel(a, [{ id: "reasoningEffort", value: "low" }])).toBe("low"); + expect(crewMemberSelectionLevel(a, undefined)).toBe("high"); + expect(crewMemberSelectionLevel(a, [{ id: "other", value: "low" }])).toBe("high"); + // No explicit value and no default: nothing to check. + expect(crewMemberSelectionLevel(providers[0]!.models[1]!, [])).toBeNull(); + // A model with no reasoning option has no level. + expect(crewMemberSelectionLevel(providers[0]!.models[2]!, [])).toBeNull(); + }); + + it("names the level, the model, the project, the setting and the levels to use instead", () => { + const message = crewMemberReasoningRefusal({ + selection: { instanceId: "codex", model: "b", level: "xhigh" }, + projectTitle: "Billing Migration", + eligible: eligibleCrewMemberLevelsForModel(checked("medium"), providers[0]!, "b"), + }); + expect(message).toContain("Reasoning level xhigh of b on codex"); + expect(message).toContain('"Billing Migration"'); + expect(message).toContain("Models for custom members in Agent Setup"); + expect(message).toContain("Eligible levels for b: medium."); + }); + + it("says when none of the model's levels is eligible", () => { + const message = crewMemberReasoningRefusal({ + selection: { instanceId: "codex", model: "b", level: "xhigh" }, + projectTitle: "P", + eligible: [], + }); + expect(message).toContain("No reasoning level of b is eligible"); + }); +}); diff --git a/packages/contracts/src/j5/crewMemberReasoning.ts b/packages/contracts/src/j5/crewMemberReasoning.ts new file mode 100644 index 0000000000000..43b90cfa44b78 --- /dev/null +++ b/packages/contracts/src/j5/crewMemberReasoning.ts @@ -0,0 +1,140 @@ +import * as Schema from "effect/Schema"; + +import { TrimmedNonEmptyString } from "../baseSchemas.ts"; +import type { ProviderOptionSelection } from "../model.ts"; +import { ProviderInstanceId } from "../providerInstance.ts"; +import type { ServerProvider, ServerProviderModel } from "../server.ts"; +import { agentPersonaReasoningDescriptor } from "./agentPersona.ts"; +import { CREW_MEMBER_MODELS_SETTING_LABEL, isCrewMemberProviderSetUp } from "./crewMemberModels.ts"; + +/** One checked reasoning level: the choice id of a model's reasoning option, per provider instance. */ +export const CrewMemberReasoningLevel = Schema.Struct({ + instanceId: ProviderInstanceId, + level: TrimmedNonEmptyString, +}); +export type CrewMemberReasoningLevel = typeof CrewMemberReasoningLevel.Type; + +/** + * The reasoning levels custom Crew members and plain delegated or spawned agents may run at, with + * the same semantics as `CrewMemberModels`: `null` means no list was ever saved and every level is + * eligible, a saved list holds only the checked pairs, and an empty saved list makes none eligible. + */ +export const CrewMemberReasoning = Schema.NullOr(Schema.Array(CrewMemberReasoningLevel)); +export type CrewMemberReasoning = typeof CrewMemberReasoning.Type; + +type LevelKey = Pick; + +export interface CrewMemberLevel { + readonly level: string; + readonly label: string; +} + +export interface CrewMemberLevelChoice extends CrewMemberLevel { + readonly instanceId: ServerProvider["instanceId"]; +} + +const modelLevels = ( + model: Pick | undefined, +): ReadonlyArray => + agentPersonaReasoningDescriptor(model)?.options.map((choice) => ({ + level: choice.id, + label: choice.label, + })) ?? []; + +/** + * A provider's levels: the choices of every model's reasoning option, each once, in order of first + * appearance. Boolean options such as a thinking switch are not levels. + */ +export const crewMemberProviderLevels = ( + provider: Pick, +): ReadonlyArray => { + const seen = new Map(); + for (const model of provider.models) + for (const level of modelLevels(model)) + if (!seen.has(level.level)) seen.set(level.level, level); + return [...seen.values()]; +}; + +export const isCrewMemberLevelChecked = ( + list: CrewMemberReasoning | undefined, + key: LevelKey, +): boolean => + list === null || + list === undefined || + list.some((entry) => entry.instanceId === key.instanceId && entry.level === key.level); + +/** The set-up providers' levels the list makes eligible, in provider order. Stale entries match nothing. */ +export const eligibleCrewMemberLevels = ( + list: CrewMemberReasoning | undefined, + providers: ReadonlyArray, +): ReadonlyArray => + providers.filter(isCrewMemberProviderSetUp).flatMap((provider) => + crewMemberProviderLevels(provider) + .filter((level) => + isCrewMemberLevelChecked(list, { instanceId: provider.instanceId, level: level.level }), + ) + .map((level) => ({ instanceId: provider.instanceId, ...level })), + ); + +/** "3 of 4": checked levels that are in the catalog, over the catalog. */ +export const crewMemberLevelCounts = ( + list: CrewMemberReasoning | undefined, + providers: ReadonlyArray, +): { readonly checked: number; readonly total: number } => ({ + checked: eligibleCrewMemberLevels(list, providers).length, + total: providers + .filter(isCrewMemberProviderSetUp) + .reduce((count, provider) => count + crewMemberProviderLevels(provider).length, 0), +}); + +/** The levels one model offers that the list makes eligible, in the model's own order. */ +export const eligibleCrewMemberLevelsForModel = ( + list: CrewMemberReasoning | undefined, + provider: Pick, + modelSlug: string, +): ReadonlyArray => + modelLevels(provider.models.find((model) => model.slug === modelSlug)).filter((level) => + isCrewMemberLevelChecked(list, { instanceId: provider.instanceId, level: level.level }), + ); + +/** + * The level a selection runs at: its explicit reasoning value, or else the model's default for + * that option. Null when the model has no reasoning option or the selection names no level and the + * option has no default, so there is nothing to check. + */ +export const crewMemberSelectionLevel = ( + model: Pick | undefined, + options: ReadonlyArray | undefined, +): string | null => { + const descriptor = agentPersonaReasoningDescriptor(model); + if (descriptor === undefined) return null; + const explicit = options?.find((option) => option.id === descriptor.id)?.value; + if (typeof explicit === "string") return explicit; + return ( + descriptor.currentValue ?? descriptor.options.find((choice) => choice.isDefault)?.id ?? null + ); +}; + +const MAX_LISTED_LEVELS = 30; + +/** + * What a refused level tells the agent or the person: the level, the model and provider, the + * project, the setting that decided it, and the levels that model can run at instead. + */ +export const crewMemberReasoningRefusal = (input: { + readonly selection: { + readonly instanceId: string; + readonly model: string; + readonly level: string; + }; + readonly projectTitle: string; + readonly eligible: ReadonlyArray; +}): string => { + const listed = input.eligible.slice(0, MAX_LISTED_LEVELS).map((choice) => choice.level); + const more = input.eligible.length - listed.length; + const alternatives = + input.eligible.length === 0 + ? `No reasoning level of ${input.selection.model} is eligible: none is checked.` + : `Eligible levels for ${input.selection.model}: ${listed.join(", ")}${more > 0 ? `, and ${more} more` : ""}.`; + return `Reasoning level ${input.selection.level} of ${input.selection.model} on ${input.selection.instanceId} is not eligible for custom members in project "${input.projectTitle}". The project's list is the setting ${CREW_MEMBER_MODELS_SETTING_LABEL}. ${alternatives}`; +}; diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts index 84345e49ea81d..a475bd8c8c1b3 100644 --- a/packages/contracts/src/settings.ts +++ b/packages/contracts/src/settings.ts @@ -28,6 +28,7 @@ import { ProviderOptionSelections, } from "./model.ts"; import { CrewMemberModels } from "./j5/crewMemberModels.ts"; +import { CrewMemberReasoning } from "./j5/crewMemberReasoning.ts"; import { ModelSelection } from "./modelSelection.ts"; import { ProjectScript, type ProjectMutation } from "./project.ts"; import { DEFAULT_RUNTIME_MODE, RuntimeMode } from "./providerPolicy.ts"; @@ -894,6 +895,7 @@ export const PROJECT_SCOPED_SERVER_SETTING_KEYS = [ "worktreeSubmodules", "crewAutoApprove", "crewMemberModels", + "crewMemberReasoning", "defaultAutoPull", "defaultProjectScripts", "enableAgentBrowserAccess", @@ -939,6 +941,7 @@ export const ProjectSettingsOverrides = Schema.Struct({ worktreeSubmodules: ForwardCompatibleOptional(WorktreeSubmodules), crewAutoApprove: Schema.optionalKey(Schema.Boolean), crewMemberModels: Schema.optionalKey(CrewMemberModels), + crewMemberReasoning: Schema.optionalKey(CrewMemberReasoning), defaultAutoPull: Schema.optionalKey(Schema.Boolean), defaultProjectScripts: Schema.optionalKey(Schema.Array(ProjectScript)), enableAgentBrowserAccess: Schema.optionalKey(Schema.Boolean), @@ -984,6 +987,7 @@ const NULLABLE_PROJECT_SETTINGS_OVERRIDES: ReadonlySet { expect(resolveProjectSettings(settings, null).settings.crewMemberModels).toEqual([entry("a")]); }); + it("replaces the reasoning levels for custom members whole, and lets a project hold null or its own list", () => { + const entry = (level: string) => ({ instanceId: ProviderInstanceId.make("codex"), level }); + expect(DEFAULT_SERVER_SETTINGS.crewMemberReasoning).toBeNull(); + const three = applyServerSettingsPatch(DEFAULT_SERVER_SETTINGS, { + crewMemberReasoning: [entry("low"), entry("medium"), entry("high")], + }); + const one = applyServerSettingsPatch(three, { crewMemberReasoning: [entry("low")] }); + expect(one.crewMemberReasoning).toEqual([entry("low")]); + const settings = applyServerSettingsPatch(one, { + projectSettingsOverrides: { + [projectId]: { crewMemberReasoning: null }, + [otherProjectId]: { crewMemberReasoning: [entry("xhigh")] }, + }, + }); + const everything = resolveProjectSettings(settings, projectId); + expect(everything.settings.crewMemberReasoning).toBeNull(); + expect(everything.sources.crewMemberReasoning).toBe("project"); + expect(resolveProjectSettings(settings, otherProjectId).settings.crewMemberReasoning).toEqual([ + entry("xhigh"), + ]); + expect(resolveProjectSettings(settings, null).settings.crewMemberReasoning).toEqual([ + entry("low"), + ]); + }); + it("keeps the environment text generation model when the override's provider is disabled", () => { const disabledSelection = createModelSelection(ProviderInstanceId.make("claudeAgent"), "opus"); const settings = applyServerSettingsPatch(DEFAULT_SERVER_SETTINGS, { From 4829c0c6f40e41b194c66ef344d23a3ee4a7d2a8 Mon Sep 17 00:00:00 2001 From: Bryant Derosier Date: Tue, 27 Oct 2026 19:24:48 -0400 Subject: [PATCH 2/6] feat(j5): hold custom members to the project's reasoning levels (reasoning levels) Co-Authored-By: Claude Sonnet 5.5 --- .../src/j5/a2a/CrewLaunchService.test.ts | 228 ++++++++++++++++-- apps/server/src/j5/a2a/CrewLaunchService.ts | 26 +- apps/server/src/j5/a2a/SpawnAgentService.ts | 7 +- apps/server/src/j5/a2a/mcp/handlers.ts | 2 +- apps/server/src/j5/a2a/mcp/tools.ts | 6 +- apps/server/src/j5/a2a/spawnWorkspace.test.ts | 79 +++++- apps/server/src/j5/agents/agentDelegation.ts | 12 +- .../agents/agentSubagent.integration.test.ts | 108 +++++++-- apps/server/src/j5/agents/crewMemberModels.ts | 82 +++++-- docs/j5/product/a2a/agent-tools.md | 12 +- 10 files changed, 490 insertions(+), 72 deletions(-) diff --git a/apps/server/src/j5/a2a/CrewLaunchService.test.ts b/apps/server/src/j5/a2a/CrewLaunchService.test.ts index 51af50e544084..cd8af9279c51e 100644 --- a/apps/server/src/j5/a2a/CrewLaunchService.test.ts +++ b/apps/server/src/j5/a2a/CrewLaunchService.test.ts @@ -85,7 +85,14 @@ const createdAt = DateTime.makeUnsafe("2026-09-09T16:00:00.000Z"); const provider = ( instanceId: string, driver: string, - models: ReadonlyArray<{ slug: string; options: ReadonlyArray }>, + models: ReadonlyArray<{ + slug: string; + options: ReadonlyArray; + /** The option the model runs at when a selection names none. */ + defaultOption?: string; + /** A model that advertises no reasoning option at all. */ + noReasoning?: true; + }>, ): ServerProvider => ({ instanceId: ProviderInstanceId.make(instanceId), driver: ProviderDriverKind.make(driver), @@ -103,14 +110,20 @@ const provider = ( name: model.slug, isCustom: false, capabilities: { - optionDescriptors: [ - { - id: driver === "codex" ? "reasoningEffort" : "effort", - label: "Reasoning", - type: "select", - options: model.options.map((id) => ({ id, label: id })), - }, - ], + optionDescriptors: model.noReasoning + ? [] + : [ + { + id: driver === "codex" ? "reasoningEffort" : "effort", + label: "Reasoning", + type: "select", + options: model.options.map((id) => ({ + id, + label: id, + ...(id === model.defaultOption ? { isDefault: true } : {}), + })), + }, + ], }, })), }); @@ -2445,15 +2458,16 @@ it.effect("a persona keeps its own model off the list, until its model is overri model: own!.modelSelection.model, }; // Editing a field on the roster card freezes the persona's model into the seat; it is the - // same model, so the seat still keeps it, with or without the options the card carried. + // same model and level, so the seat still keeps it. const [frozen] = yield* launcher.resolveSeats(captain, [ { ...persona, modelSelection: own!.modelSelection, runtimeMode: "approval-required" }, ]); assert.equal(frozen!.modelSelection.model, personaModel.model); - const [bare] = yield* launcher.resolveSeats(captain, [ - { ...persona, modelSelection: personaModel }, - ]); - assert.equal(bare!.modelSelection.model, personaModel.model); + // Naming no reasoning value is not keeping the persona's: it runs at the model's default. + const bare = yield* launcher + .resolveSeats(captain, [{ ...persona, modelSelection: personaModel }]) + .pipe(Effect.flip); + assert.equal(bare._tag, "CrewLaunchModelNotEligibleError"); // A different model on the card makes it a custom choice, held to the list. const other = ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"].find( (model) => model !== personaModel.model, @@ -2507,3 +2521,189 @@ it.effect( }).pipe(Effect.provide(layer)); }).pipe(Effect.scoped), ); + +const codexLevel = (level: string) => ({ instanceId: ProviderInstanceId.make("codex"), level }); +const solAt = (value: string) => ({ ...sol, options: [{ id: "reasoningEffort", value }] }); +const terraAt = (value: string) => ({ ...terra, options: [{ id: "reasoningEffort", value }] }); +// The Captain runs on gpt-5.6-sol with no explicit level, so it runs at the model's default. +const reasoningProviders = [ + provider("codex", "codex", [ + { slug: "gpt-5.6-sol", options: ["low", "medium", "high"], defaultOption: "medium" }, + { slug: "gpt-5.6-terra", options: ["high", "xhigh"] }, + { slug: "gpt-5.6-luna", options: [], noReasoning: true }, + ]), +]; + +it.effect( + "a saved level list holds a custom seat to its checked levels and names what to use", + () => + Effect.gen(function* () { + const { layer, captain, commands } = yield* eligibilityFixture({ + providers: reasoningProviders, + settings: { crewMemberReasoning: [codexLevel("low"), codexLevel("high")] }, + }); + yield* Effect.gen(function* () { + const launcher = yield* CrewLaunchService; + const checked = yield* launcher.resolveSeats(captain, [ + customSeat("low", solAt("low")), + customSeat("high", solAt("high")), + ]); + assert.lengthOf(checked, 2); + const refused = yield* launcher + .resolveSeats(captain, [customSeat("medium", solAt("medium"))]) + .pipe(Effect.flip); + assert.equal(refused._tag, "CrewLaunchModelNotEligibleError"); + for (const part of [ + "Reasoning level medium of gpt-5.6-sol on codex", + "Billing Migration", + "Models for custom members in Agent Setup", + "Eligible levels for gpt-5.6-sol: low, high.", + ]) + assert.include(refused.message, part); + // Another model's levels are listed for that model, not this one's. + const terraRefused = yield* launcher + .resolveSeats(captain, [customSeat("terra", terraAt("xhigh"))]) + .pipe(Effect.flip); + assert.include(terraRefused.message, "Eligible levels for gpt-5.6-terra: high."); + // Approving the roster goes through the same check, and nothing is created. + const launched = yield* launcher + .launch({ + providerSessionId: "session", + requestKey: "launch-ineligible-level", + captain, + displayName: "Crew", + seats: [customSeat("medium", solAt("medium"))], + brief: "Work.", + }) + .pipe(Effect.flip); + assert.equal(launched._tag, "CrewLaunchModelNotEligibleError"); + assert.lengthOf(yield* Ref.get(commands), 0); + }).pipe(Effect.provide(layer)); + }).pipe(Effect.scoped), +); + +it.effect( + "a custom seat with no explicit level runs at the model's default, which is checked", + () => + Effect.gen(function* () { + // The Captain's own selection names no level, so a seat that inherits it runs at medium. + const refusing = yield* eligibilityFixture({ + providers: reasoningProviders, + settings: { crewMemberReasoning: [codexLevel("high")] }, + }); + yield* Effect.gen(function* () { + const launcher = yield* CrewLaunchService; + const refused = yield* launcher + .resolveSeats(refusing.captain, [customSeat("inherits")]) + .pipe(Effect.flip); + assert.include(refused.message, "Reasoning level medium of gpt-5.6-sol"); + }).pipe(Effect.provide(refusing.layer)); + const allowing = yield* eligibilityFixture({ + providers: reasoningProviders, + settings: { crewMemberReasoning: [codexLevel("medium")] }, + }); + yield* Effect.gen(function* () { + const launcher = yield* CrewLaunchService; + yield* launcher.resolveSeats(allowing.captain, [customSeat("inherits")]); + }).pipe(Effect.provide(allowing.layer)); + }).pipe(Effect.scoped), +); + +it.effect( + "a saved empty level list makes no level eligible, but a model with none is not held", + () => + Effect.gen(function* () { + const { layer, captain } = yield* eligibilityFixture({ + providers: reasoningProviders, + settings: { crewMemberReasoning: [] }, + }); + yield* Effect.gen(function* () { + const launcher = yield* CrewLaunchService; + const refused = yield* launcher + .resolveSeats(captain, [customSeat("inherits")]) + .pipe(Effect.flip); + assert.include(refused.message, "No reasoning level of gpt-5.6-sol is eligible"); + yield* launcher.resolveSeats(captain, [ + customSeat("plain", { instanceId: sol.instanceId, model: "gpt-5.6-luna" }), + ]); + }).pipe(Effect.provide(layer)); + }).pipe(Effect.scoped), +); + +it.effect( + "the model list is checked before the level, and a level new to the catalog starts unchecked", + () => + Effect.gen(function* () { + const { layer, captain } = yield* eligibilityFixture({ + providers: reasoningProviders, + // Saved when terra offered only xhigh; high arrived later. + settings: { + crewMemberModels: [terra], + crewMemberReasoning: [codexLevel("xhigh")], + }, + }); + yield* Effect.gen(function* () { + const launcher = yield* CrewLaunchService; + const modelFirst = yield* launcher + .resolveSeats(captain, [customSeat("sol", solAt("high"))]) + .pipe(Effect.flip); + assert.include(modelFirst.message, "Model gpt-5.6-sol on codex"); + yield* launcher.resolveSeats(captain, [customSeat("known", terraAt("xhigh"))]); + const fresh = yield* launcher + .resolveSeats(captain, [customSeat("fresh", terraAt("high"))]) + .pipe(Effect.flip); + assert.include(fresh.message, "Reasoning level high of gpt-5.6-terra"); + }).pipe(Effect.provide(layer)); + }).pipe(Effect.scoped), +); + +it.effect("a persona keeps its own level off the list, until its level is changed", () => + Effect.gen(function* () { + const levels = ["low", "medium", "high", "xhigh"]; + const { layer, captain } = yield* eligibilityFixture({ + providers: [ + provider( + "codex", + "codex", + ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"].map((slug) => ({ + slug, + options: levels, + })), + ), + ], + settings: { crewMemberReasoning: [] }, + }); + yield* Effect.gen(function* () { + const launcher = yield* CrewLaunchService; + const persona = { + workspace: { type: "shared" as const }, + name: "builder", + agentId: "builder", + reason: "Builds", + }; + const [own] = yield* launcher.resolveSeats(captain, [persona]); + // The card freezes the persona's whole selection into the seat; unchanged, it is not held. + yield* launcher.resolveSeats(captain, [ + { ...persona, modelSelection: own!.modelSelection, runtimeMode: "approval-required" }, + ]); + const personaLevel = own!.modelSelection.options?.find( + (option) => option.id === "reasoningEffort", + )?.value; + const otherLevel = levels.find((level) => level !== personaLevel)!; + const refused = yield* launcher + .resolveSeats(captain, [ + { + ...persona, + modelSelection: { + instanceId: own!.modelSelection.instanceId, + model: own!.modelSelection.model, + options: [{ id: "reasoningEffort", value: otherLevel }], + }, + }, + ]) + .pipe(Effect.flip); + assert.equal(refused._tag, "CrewLaunchModelNotEligibleError"); + assert.include(refused.message, `Reasoning level ${otherLevel}`); + }).pipe(Effect.provide(layer)); + }).pipe(Effect.scoped), +); diff --git a/apps/server/src/j5/a2a/CrewLaunchService.ts b/apps/server/src/j5/a2a/CrewLaunchService.ts index 524433aa5f07d..c29381c8b2b2e 100644 --- a/apps/server/src/j5/a2a/CrewLaunchService.ts +++ b/apps/server/src/j5/a2a/CrewLaunchService.ts @@ -1,4 +1,4 @@ -import { CrewSeatWorkspace } from "@t3tools/contracts/j5"; +import { CrewSeatWorkspace, crewMemberSelectionLevel } from "@t3tools/contracts/j5"; import { describeCrewSeatRuntime, materializeCrewModelSelection, @@ -185,7 +185,7 @@ export class CrewLaunchSeatUnavailableError extends Data.TaggedError( } } -/** A custom seat's model is not on the project's "Models for custom members" list. */ +/** A custom seat's model or reasoning level is not on the project's "Models for custom members" lists. */ export class CrewLaunchModelNotEligibleError extends Data.TaggedError( "CrewLaunchModelNotEligibleError", )<{ readonly seatName: string; readonly detail: string }> { @@ -316,8 +316,17 @@ export const layer = Layer.effect( ), ); const resolved: Array = []; - // `custom` seats run on whatever the project's list of models for custom members allows. A - // persona seat that keeps its persona's own model is not custom and skips the list. + // The reasoning level a selection runs at on its model, explicit or the model's default. + const levelOf = (selection: ModelSelection) => + crewMemberSelectionLevel( + providers + .find((candidate) => candidate.instanceId === selection.instanceId) + ?.models.find((model) => model.slug === selection.model), + selection.options, + ); + // `custom` seats run on whatever the project's lists of models and reasoning levels for + // custom members allow. A persona seat that keeps its persona's own model and level is not + // custom and skips the lists. const resolveSelection = Effect.fn("j5.a2a.crewLaunch.resolveSelection")(function* ( seat: CrewLaunchSeat, selection: ModelSelection, @@ -430,15 +439,18 @@ export const layer = Layer.effect( const definition = catalog.definitions.find(({ id }) => id === agentId); // Editing any field on the roster card freezes the model it showed into the seat, and // that is the fallback route when the primary's provider was signed out at proposal - // time. A seat counts as keeping the persona's model by matching either route, never by - // its absence. + // time. A seat counts as keeping the persona's model and level by matching either route, + // never by its absence. const frozen = seat.modelSelection; const frozenDriver = providers.find( (candidate) => candidate.instanceId === frozen.instanceId, )?.driver; const keepsPersonaModel = definition?.modelRoute.some( - (target) => target.driver === frozenDriver && target.model === frozen.model, + (target) => + target.driver === frozenDriver && + target.model === frozen.model && + target.reasoningEffort === levelOf(frozen), ) ?? false; const { modelSelection, provider } = yield* resolveSelection( seat, diff --git a/apps/server/src/j5/a2a/SpawnAgentService.ts b/apps/server/src/j5/a2a/SpawnAgentService.ts index a8231d5753079..5faca15bc8ad5 100644 --- a/apps/server/src/j5/a2a/SpawnAgentService.ts +++ b/apps/server/src/j5/a2a/SpawnAgentService.ts @@ -479,8 +479,9 @@ const spawn = Effect.fn("j5.a2a.spawnAgent")(function* ( }), ), ); - // A persona runs on its own model. A plain agent runs on one the project's list allows, and a - // retry finishes the agent its first attempt created, so only a first attempt is held to it. + // A persona runs on its own model. A plain agent runs on a model and level the project's + // lists allow, and a retry finishes the agent its first attempt created, so only a first + // attempt is held to them. if (persona === undefined && firstAttempt) yield* (yield* CrewMemberModels) .assertEligible({ projectId: target, selection: modelSelection }) @@ -488,7 +489,7 @@ const spawn = Effect.fn("j5.a2a.spawnAgent")(function* ( Effect.mapError((error) => stateError( error.message, - "Retry j5_spawn_agent with one of the eligible models, or name a persona.", + "Retry j5_spawn_agent with one of the eligible models or levels, or name a persona.", ), ), ); diff --git a/apps/server/src/j5/a2a/mcp/handlers.ts b/apps/server/src/j5/a2a/mcp/handlers.ts index dea1435fd841f..8ae3cc61a4a6d 100644 --- a/apps/server/src/j5/a2a/mcp/handlers.ts +++ b/apps/server/src/j5/a2a/mcp/handlers.ts @@ -228,7 +228,7 @@ const crewProposalNextStep = (error: CrewProposalError) => : error._tag === "CrewLaunchSeatUnavailableError" ? "Choose a different persona from j5_list_personas or ask the user to fix that persona, then retry." : error._tag === "CrewLaunchModelNotEligibleError" - ? "Give that custom member one of the eligible models above, or leave its model unset to use yours if yours is eligible, then retry." + ? "Give that custom member one of the eligible models or levels above, or leave its model unset to use yours if yours is eligible, then retry." : error._tag === "CrewLaunchCapError" ? "The crew is full. Work with the seats it has, or propose a new crew for the extra work." : error._tag === "CrewLaunchSeatConflictError" diff --git a/apps/server/src/j5/a2a/mcp/tools.ts b/apps/server/src/j5/a2a/mcp/tools.ts index 574455044e6ed..7c1b098a2543d 100644 --- a/apps/server/src/j5/a2a/mcp/tools.ts +++ b/apps/server/src/j5/a2a/mcp/tools.ts @@ -575,16 +575,16 @@ export const J5ArchiveCrewFailure = Schema.Struct({ export type J5ArchiveCrewFailure = typeof J5ArchiveCrewFailure.Type; export const J5_SPAWN_AGENT_DESCRIPTION = - "Spawn a Peer Agent: a full-citizen teammate with its own top-level thread, starting on your brief as its first turn. It joins your project unless you name another with project_id or set scratch for none, and records you as its immutable spawner; in your own project it is placed under you. It is addressable the moment this returns. In your brief, tell the new agent what it should do first and whether it should reply to you. Choose provider, model, and reasoning for the work in the brief — see orchestrator_capabilities for what's available. To run a persona from j5_list_personas, set `persona` to its id: the spawn gets that persona's instructions and runtime policy, and provider, model, and reasoning must be one of that persona's declared routes. Without a persona it runs in your permission and interaction modes, or in narrower ones you set with runtime_mode and interaction_mode. Without a persona its model must be one the project's Models for custom members list allows; an ineligible one is refused with the eligible models. Attach files to the brief with attachments. Choose its workspace every time (see the workspace field). A new worktree is prepared after this returns, and the agent begins once it is bound, possibly while the project's setup script is still running; if preparing it fails, the agent's thread shows why, and it is not retried. Reuse client_request_id to retry the same spawn safely; reusing it with any change to the request is refused, so use a fresh one for new work."; + "Spawn a Peer Agent: a full-citizen teammate with its own top-level thread, starting on your brief as its first turn. It joins your project unless you name another with project_id or set scratch for none, and records you as its immutable spawner; in your own project it is placed under you. It is addressable the moment this returns. In your brief, tell the new agent what it should do first and whether it should reply to you. Choose provider, model, and reasoning for the work in the brief — see orchestrator_capabilities for what's available. To run a persona from j5_list_personas, set `persona` to its id: the spawn gets that persona's instructions and runtime policy, and provider, model, and reasoning must be one of that persona's declared routes. Without a persona it runs in your permission and interaction modes, or in narrower ones you set with runtime_mode and interaction_mode. Without a persona its model and reasoning level must be ones the project's Models for custom members lists allow; an ineligible one is refused with the eligible ones. Attach files to the brief with attachments. Choose its workspace every time (see the workspace field). A new worktree is prepared after this returns, and the agent begins once it is bound, possibly while the project's setup script is still running; if preparing it fails, the agent's thread shows why, and it is not retried. Reuse client_request_id to retry the same spawn safely; reusing it with any change to the request is refused, so use a fresh one for new work."; export const J5_LIST_AGENTS_DESCRIPTION = "List the personas in this environment: id, purpose, runtime policy, whether each can start now, and the provider, model, and reasoning it would run on. Read this before choosing a persona for j5_spawn_agent or a crew roster so the choice fits the task and the user's budget. Read-only."; export const J5_PROPOSE_CREW_DESCRIPTION = - "Propose the crew you need for the brief you were given. Use it when the user asks for a crew or the work splits into distinct responsibilities that should run at once. Mix saved personas and custom seats in the same roster: call j5_list_personas when choosing a saved persona, or leave persona unset for a custom seat with its own instructions (required) and the brief. Custom seats inherit your harness, model, and reasoning by default and run with full-access unless you set runtime_mode; to choose different ones, set model_selection (instanceId, model, options) and/or runtime_mode using orchestrator_capabilities. A custom seat's model, yours included, must be one the project's Models for custom members list allows; an ineligible one is refused with the eligible models. Saved personas are proposed with their own configuration; only the human may override their runtime before approval. To have the crew follow a playbook, set playbook to a name from j5_playbook_list and give seats the step ids they own (steps, from j5_playbook_read); a step has one owner, steps no seat owns are yours as Captain, and the result reports unowned steps and any step whose persona differs from its seat's. For a crew built from a playbook, staff one seat per distinct persona its steps name, each owning that persona's steps, and propose a custom seat, noted in its reason, where a named persona isn't available. Every seat names its workspace, with the same three choices as j5_spawn_agent. Name the crew for what it is for and give each seat a short lowercase-hyphen name like code-reviewer. By default the user reviews and edits the roster in this thread, then approves or declines. If Auto-approve new Crews is on for your project, the proposed roster is created immediately with no approval card. The result says whether it is open or approved; the launch report arrives here once creation finishes or fails. Approval creates seats without starting turns. Send each member its first assignment when it has work; reuse finished members for follow-up work in the same thread. Each seat keeps its configured access and tool approvals, which may exceed yours. You become the crew's Captain and may command several crews at once; later requests, stops, and archives name the crew they mean. Use j5_send_message for member-to-member, member-to-Captain, and Captain-to-Captain coordination, including findings and direct results; artifacts do not gate these conversations. Reuse client_request_id to retry safely; a changed request is refused, so use a fresh one for new work. This tool works under every sandbox and approval policy, including approval policy never; never refuse the brief because approvals are disabled."; + "Propose the crew you need for the brief you were given. Use it when the user asks for a crew or the work splits into distinct responsibilities that should run at once. Mix saved personas and custom seats in the same roster: call j5_list_personas when choosing a saved persona, or leave persona unset for a custom seat with its own instructions (required) and the brief. Custom seats inherit your harness, model, and reasoning by default and run with full-access unless you set runtime_mode; to choose different ones, set model_selection (instanceId, model, options) and/or runtime_mode using orchestrator_capabilities. A custom seat's model and reasoning level, yours included, must be ones the project's Models for custom members lists allow; an ineligible one is refused with the eligible ones. Saved personas are proposed with their own configuration; only the human may override their runtime before approval. To have the crew follow a playbook, set playbook to a name from j5_playbook_list and give seats the step ids they own (steps, from j5_playbook_read); a step has one owner, steps no seat owns are yours as Captain, and the result reports unowned steps and any step whose persona differs from its seat's. For a crew built from a playbook, staff one seat per distinct persona its steps name, each owning that persona's steps, and propose a custom seat, noted in its reason, where a named persona isn't available. Every seat names its workspace, with the same three choices as j5_spawn_agent. Name the crew for what it is for and give each seat a short lowercase-hyphen name like code-reviewer. By default the user reviews and edits the roster in this thread, then approves or declines. If Auto-approve new Crews is on for your project, the proposed roster is created immediately with no approval card. The result says whether it is open or approved; the launch report arrives here once creation finishes or fails. Approval creates seats without starting turns. Send each member its first assignment when it has work; reuse finished members for follow-up work in the same thread. Each seat keeps its configured access and tool approvals, which may exceed yours. You become the crew's Captain and may command several crews at once; later requests, stops, and archives name the crew they mean. Use j5_send_message for member-to-member, member-to-Captain, and Captain-to-Captain coordination, including findings and direct results; artifacts do not gate these conversations. Reuse client_request_id to retry safely; a changed request is refused, so use a fresh one for new work. This tool works under every sandbox and approval policy, including approval policy never; never refuse the brief because approvals are disabled."; export const J5_REQUEST_CREW_MEMBER_DESCRIPTION = - "Add one seat directly to a running crew you command when the work needs expertise the roster lacks. No human approval is needed, regardless of Auto-approve new Crews. Give a seat name, a persona id from j5_list_personas or required instructions for a custom seat, a reason identifying the missing expertise, and its workspace (the same choices as j5_propose_crew). Custom seats inherit your model selection and run with full-access unless you set model_selection or runtime_mode; a custom seat's model must be one the project's Models for custom members list allows, and saved personas use their own configuration. Optionally give a brief; otherwise the seat gets the Crew's brief. On a playbook Crew, steps may claim only unowned step ids from j5_playbook_read. The result returns the updated roster or refuses the seat with its name and reason; creation is reported separately here. The new member waits for its first assignment; send it with j5_send_message when the work is ready. Each member's configured access still controls tool approvals. Captain-only: a member sends the concern to its Captain with j5_send_message. Reuse client_request_id to retry safely; a changed request is refused, so use a fresh one for new work. Works under every approval policy, including approval policy never."; + "Add one seat directly to a running crew you command when the work needs expertise the roster lacks. No human approval is needed, regardless of Auto-approve new Crews. Give a seat name, a persona id from j5_list_personas or required instructions for a custom seat, a reason identifying the missing expertise, and its workspace (the same choices as j5_propose_crew). Custom seats inherit your model selection and run with full-access unless you set model_selection or runtime_mode; a custom seat's model and reasoning level must be ones the project's Models for custom members lists allow, and saved personas use their own configuration. Optionally give a brief; otherwise the seat gets the Crew's brief. On a playbook Crew, steps may claim only unowned step ids from j5_playbook_read. The result returns the updated roster or refuses the seat with its name and reason; creation is reported separately here. The new member waits for its first assignment; send it with j5_send_message when the work is ready. Each member's configured access still controls tool approvals. Captain-only: a member sends the concern to its Captain with j5_send_message. Reuse client_request_id to retry safely; a changed request is refused, so use a fresh one for new work. Works under every approval policy, including approval policy never."; export const J5_STOP_AGENT_DESCRIPTION = "Stop one Peer Agent the way a user Stop does: its running turn is interrupted now, turns already queued behind it, messages you sent it included, are held until a person resumes its queue or the next message reaches it (that message resumes the queue and runs after them, in order), its pull request watches end, and the tasks it delegated stop too. The agent remains, stays readable, and can be messaged again later — stopping halts work, it retires nothing. It reaches any agent on this server, in any project. Reuse client_request_id to retry safely."; diff --git a/apps/server/src/j5/a2a/spawnWorkspace.test.ts b/apps/server/src/j5/a2a/spawnWorkspace.test.ts index 87d725f71926f..2320ea5ba9d8e 100644 --- a/apps/server/src/j5/a2a/spawnWorkspace.test.ts +++ b/apps/server/src/j5/a2a/spawnWorkspace.test.ts @@ -376,7 +376,10 @@ const spawnHarness = (input: { id: "reasoningEffort", label: "Reasoning", type: "select" as const, - options: [{ id: "high", label: "High" }], + options: [ + { id: "low", label: "Low" }, + { id: "high", label: "High" }, + ], }, ], }, @@ -660,6 +663,80 @@ it.effect( }), ); +const codexWithLevels = { + ...codexSolAndTerra, + models: ["gpt-5.6-sol", "gpt-5.6-terra"].map((slug) => ({ + slug, + name: slug, + capabilities: { + optionDescriptors: [ + { + id: "reasoningEffort", + label: "Reasoning", + type: "select", + options: [ + { id: "low", label: "Low" }, + { id: "high", label: "High" }, + ], + }, + ], + }, + })), +} as unknown as ServerProvider; +const lowOnly = { + crewMemberReasoning: [{ instanceId: ProviderInstanceId.make("codex"), level: "low" }], +}; + +it.effect("a plain spawn runs at a reasoning level its project's list allows", () => + Effect.gen(function* () { + const { layer, call, commands } = yield* spawnHarness({ + checkout: { isRepo: true, refName: "j5/main" }, + memberModels: crewMemberModelsLayer({ + providers: [codexWithLevels], + settings: lowOnly, + projectTitle: "Billing Migration", + }), + }); + yield* Effect.gen(function* () { + const refused = yield* call({ ...spawnArgs, client_request_id: "off-list-level" }); + assert.isTrue(refused.isFailure); + for (const part of [ + "Reasoning level high of gpt-5.6-sol on codex", + "Billing Migration", + "Models for custom members in Agent Setup", + "Eligible levels for gpt-5.6-sol: low.", + ]) + assert.include(message(refused), part); + assert.lengthOf(yield* Ref.get(commands), 0, "a refused spawn creates nothing"); + const allowed = yield* call({ + ...spawnArgs, + reasoning: "low", + client_request_id: "on-list-level", + }); + assert.isFalse(allowed.isFailure); + }).pipe(Effect.provide(layer)); + }), +); + +it.effect( + "a retry of a spawn that already created its agent is not held to a level list saved since", + () => + Effect.gen(function* () { + const { layer, call } = yield* spawnHarness({ + checkout: { isRepo: true, refName: "j5/main" }, + existingChildRuntimeMode: "full-access", + memberModels: crewMemberModelsLayer({ + providers: [codexWithLevels], + settings: lowOnly, + }), + }); + yield* Effect.gen(function* () { + const replayed = yield* call({ ...spawnArgs, client_request_id: "already-created" }); + assert.isFalse(replayed.isFailure); + }).pipe(Effect.provide(layer)); + }), +); + it.effect("spawns an agent with no project into a folder of its own", () => Effect.gen(function* () { const { layer, call, commands } = yield* spawnHarness({ diff --git a/apps/server/src/j5/agents/agentDelegation.ts b/apps/server/src/j5/agents/agentDelegation.ts index 613446a6a34ea..ad63dfe13ea59 100644 --- a/apps/server/src/j5/agents/agentDelegation.ts +++ b/apps/server/src/j5/agents/agentDelegation.ts @@ -38,7 +38,7 @@ export type J5DelegateTaskInput = typeof J5DelegateTaskInput.Type; * fallback. */ export const J5_DELEGATE_TASK_DESCRIPTION = - "Run one task as a J5-owned child of THIS thread with only the supplied task prompt; parent conversation history is not copied. Pass persona=ID when the user writes @persona:ID or asks for a persona by name: the server pins that persona's instructions, provider, model, reasoning, and runtime policy, so omit target and runtimeMode. Give the persona a self-contained task, and if that call fails, report the error instead of substituting a plain child. Without persona, this is a plain J5-tracked child for cross-provider work or for work the user wants tracked as a J5 task; for an ordinary subagent request, use your provider's native subagent mechanism instead. The childThreadId is backing storage, not an ordinary top-level thread. Set isolation to worktree for a separate checkout based on the parent local commit, with project setup completed before the child starts. Uncommitted edits are not copied; omitted isolation shares the parent checkout. Provider, model, model options (see orchestrator_capabilities), runtime mode, and interaction mode inherit unless target overrides them. Without persona the child's model, an inherited one included, must be one the project's Models for custom members list allows; a refusal lists the eligible models to retry with in target. A requested runtimeMode must be one the target provider lists in orchestrator_capabilities runtimeModes; an inherited one steps down to the broadest mode it offers. Leave runtimeMode unset unless the user asks for a supervised child: approval-required and auto-accept-edits usually make the child wait for a person at each action that needs approval. Prefer mode='async' for long work; mode='wait' blocks until completion, a blocking question, or timeout. If hasPendingQuestion, pass threadId=childThreadId to t3_pending_request_list, t3_pending_request_read (with requestId) and t3_pending_request_respond, or ask the user; the task's completion still wakes this thread. timeoutMs on mode=wait is only the parent's wait budget and does not cancel the child. waitTimedOut on that wait call means the timeout fired; keep that taskId and read status on later task_status. An async child's completion wakes this thread through a notification, steered into active turns where supported or queued otherwise, so end the turn instead of polling or spawning watchers; use task_status only when the result is needed mid-turn."; + "Run one task as a J5-owned child of THIS thread with only the supplied task prompt; parent conversation history is not copied. Pass persona=ID when the user writes @persona:ID or asks for a persona by name: the server pins that persona's instructions, provider, model, reasoning, and runtime policy, so omit target and runtimeMode. Give the persona a self-contained task, and if that call fails, report the error instead of substituting a plain child. Without persona, this is a plain J5-tracked child for cross-provider work or for work the user wants tracked as a J5 task; for an ordinary subagent request, use your provider's native subagent mechanism instead. The childThreadId is backing storage, not an ordinary top-level thread. Set isolation to worktree for a separate checkout based on the parent local commit, with project setup completed before the child starts. Uncommitted edits are not copied; omitted isolation shares the parent checkout. Provider, model, model options (see orchestrator_capabilities), runtime mode, and interaction mode inherit unless target overrides them. Without persona the child's model and reasoning level, inherited ones included, must be ones the project's Models for custom members lists allow; a refusal lists the eligible ones to retry with in target. A requested runtimeMode must be one the target provider lists in orchestrator_capabilities runtimeModes; an inherited one steps down to the broadest mode it offers. Leave runtimeMode unset unless the user asks for a supervised child: approval-required and auto-accept-edits usually make the child wait for a person at each action that needs approval. Prefer mode='async' for long work; mode='wait' blocks until completion, a blocking question, or timeout. If hasPendingQuestion, pass threadId=childThreadId to t3_pending_request_list, t3_pending_request_read (with requestId) and t3_pending_request_respond, or ask the user; the task's completion still wakes this thread. timeoutMs on mode=wait is only the parent's wait budget and does not cancel the child. waitTimedOut on that wait call means the timeout fired; keep that taskId and read status on later task_status. An async child's completion wakes this thread through a notification, steered into active turns where supported or queued otherwise, so end the turn instead of polling or spawning watchers; use task_status only when the result is needed mid-turn."; /** J5's delegate_task: the upstream tool with the persona extension, registered in place of it. */ export const J5DelegateTaskTool = Tool.make("delegate_task", { @@ -52,7 +52,7 @@ export const J5DelegateTaskTool = Tool.make("delegate_task", { OrchestratorMcpService, ThreadManagementService, ProviderRegistry.ProviderRegistry, - // A plain child's model is held to the project's list of models for custom members. + // A plain child's model and reasoning level are held to the project's lists for custom members. CrewMemberModels, ], }) @@ -67,7 +67,8 @@ export const delegateTask = Effect.fn("j5.delegateTask")(function* (input: J5Del const service = yield* OrchestratorMcpService; const memberModels = yield* CrewMemberModels; // A persona runs on its own model; a plain child, even one that inherits its parent's model, - // runs on one the project's list allows. Upstream calls this with the model it resolved. + // runs on a model and level the project's lists allow. Upstream calls this with the model it + // resolved. return yield* service.delegateTask(scope, { ...delegate, authorizeTarget: ({ projectId, modelSelection }) => @@ -76,7 +77,10 @@ export const delegateTask = Effect.fn("j5.delegateTask")(function* (input: J5Del (error) => new OrchestratorMcpFailure({ code: "model_unavailable", - message: `${error.message} Retry with target set to one of them as providerInstanceId and model.`, + message: + error._tag === "CrewMemberModelNotEligibleError" + ? `${error.message} Retry with target set to one of them as providerInstanceId and model.` + : `${error.message} Retry with target options setting the model's reasoning option to one of them.`, }), ), ), diff --git a/apps/server/src/j5/agents/agentSubagent.integration.test.ts b/apps/server/src/j5/agents/agentSubagent.integration.test.ts index f2edc98c3895f..b2be3912584ee 100644 --- a/apps/server/src/j5/agents/agentSubagent.integration.test.ts +++ b/apps/server/src/j5/agents/agentSubagent.integration.test.ts @@ -49,6 +49,7 @@ const modelSelection = { model: BUILT_IN_AGENT_PERSONAS.scout.modelRoute[0].model, }; const otherModel = "gpt-5.6-other"; +const plainModel = "gpt-5.6-plain"; const provider: ServerProvider = { instanceId: modelSelection.instanceId, driver: ProviderDriverKind.make("codex"), @@ -61,21 +62,28 @@ const provider: ServerProvider = { availability: "available", slashCommands: [], skills: [], - models: [modelSelection.model, otherModel].map((slug) => ({ - slug, - name: "Model", - isCustom: false, - capabilities: { - optionDescriptors: [ - { - id: "reasoningEffort", - label: "Reasoning", - type: "select" as const, - options: [{ id: "high", label: "High" }], - }, - ], - }, - })), + models: [ + ...[modelSelection.model, otherModel].map((slug) => ({ + slug, + name: "Model", + isCustom: false, + capabilities: { + optionDescriptors: [ + { + id: "reasoningEffort", + label: "Reasoning", + type: "select" as const, + options: [ + { id: "high", label: "High", isDefault: true }, + { id: "low", label: "Low" }, + ], + }, + ], + }, + })), + // A model that advertises no reasoning option has no level to hold. + { slug: plainModel, name: "Plain", isCustom: false, capabilities: null }, + ], }; const adapter = { instanceId: modelSelection.instanceId, @@ -329,3 +337,73 @@ it.effect("holds a plain delegated child to the list, inherited model included", assert.include(none.message, "nothing is checked"); }).pipe(Effect.provide(listedLayer)), ); + +it.effect("holds a plain delegated child to the level list, an inherited level included", () => + Effect.gen(function* () { + const { orchestrator, scope } = yield* runningParent; + const settings = yield* ServerSettings.ServerSettingsService; + const asParent = Effect.provideService(McpInvocationContext, scope); + const plain = ( + clientRequestId: string, + target?: { readonly model: string; readonly level?: string }, + ) => + delegateTask({ + task: "Plain child work.", + clientRequestId, + ...(target === undefined + ? {} + : { + target: { + providerInstanceId: modelSelection.instanceId, + model: target.model, + ...(target.level === undefined + ? {} + : { options: [{ id: "reasoningEffort", value: target.level }] }), + }, + }), + }).pipe(asParent); + const level = { instanceId: modelSelection.instanceId, level: "low" }; + + // The parent runs on its model's default level, high, which this list leaves out. + yield* settings.updateSettings({ crewMemberReasoning: [level] }); + const refused = yield* plain("inherits").pipe(Effect.flip); + assert.equal(refused.code, "model_unavailable"); + for (const part of [ + `Reasoning level high of ${modelSelection.model}`, + "Billing Migration", + "Models for custom members in Agent Setup", + `Eligible levels for ${modelSelection.model}: low.`, + "Retry with target options", + ]) + assert.include(refused.message, part); + + // A persona runs on its own level, a model with no reasoning option has nothing to hold, and + // an explicit checked level works. + const persona = yield* delegateTask({ + task: "Return a short evidence brief.", + persona: "scout", + clientRequestId: "persona", + }).pipe(asParent); + assert.equal( + (yield* orchestrator.getThreadProjection(persona.childThreadId)).thread.modelSelection.model, + modelSelection.model, + ); + yield* plain("plain-model", { model: plainModel }); + const explicit = yield* plain("explicit", { model: otherModel, level: "low" }); + assert.equal( + (yield* orchestrator.getThreadProjection(explicit.childThreadId)).thread.modelSelection.model, + otherModel, + ); + const unchecked = yield* plain("unchecked", { model: otherModel, level: "high" }).pipe( + Effect.flip, + ); + assert.include(unchecked.message, `Reasoning level high of ${otherModel}`); + + // A list saved afterwards does not refuse the retry of a delegation already accepted. + yield* settings.updateSettings({ crewMemberReasoning: [] }); + const replayed = yield* plain("explicit", { model: otherModel, level: "low" }); + assert.equal(replayed.childThreadId, explicit.childThreadId); + const none = yield* plain("fresh", { model: otherModel, level: "low" }).pipe(Effect.flip); + assert.include(none.message, "No reasoning level"); + }).pipe(Effect.provide(listedLayer)), +); diff --git a/apps/server/src/j5/agents/crewMemberModels.ts b/apps/server/src/j5/agents/crewMemberModels.ts index 0d5d3ec1c0068..02faf8994f8f2 100644 --- a/apps/server/src/j5/agents/crewMemberModels.ts +++ b/apps/server/src/j5/agents/crewMemberModels.ts @@ -1,7 +1,11 @@ import type { ModelSelection, ProjectId } from "@t3tools/contracts"; import { crewMemberModelRefusal, + crewMemberReasoningRefusal, + crewMemberSelectionLevel, + eligibleCrewMemberLevelsForModel, eligibleCrewMemberModels, + isCrewMemberLevelChecked, isCrewMemberModelChecked, } from "@t3tools/contracts/j5"; import { resolveProjectSettings } from "@t3tools/shared/projectSettings"; @@ -37,18 +41,42 @@ export class CrewMemberModelNotEligibleError extends Schema.TaggedError()( + "CrewMemberReasoningNotEligibleError", + { + projectId: Schema.String, + projectTitle: Schema.String, + instanceId: Schema.String, + model: Schema.String, + level: Schema.String, + eligible: Schema.Array(Schema.Struct({ level: Schema.String, label: Schema.String })), + }, +) { + override get message(): string { + return crewMemberReasoningRefusal({ + selection: this, + projectTitle: this.projectTitle, + eligible: this.eligible, + }); + } +} + /** - * The one place that decides whether a resolved model may run a custom worker in a project: a - * Crew's custom member, a plain `j5_spawn_agent`, or a plain `delegate_task`. Persona seats that - * keep their persona's model never reach it. + * The one place that decides whether a resolved model and reasoning level may run a custom worker + * in a project: a Crew's custom member, a plain `j5_spawn_agent`, or a plain `delegate_task`. + * Persona seats that keep their persona's selection never reach it. */ export class CrewMemberModels extends Context.Service< CrewMemberModels, { readonly assertEligible: (input: { readonly projectId: ProjectId; - readonly selection: Pick; - }) => Effect.Effect; + readonly selection: Pick; + }) => Effect.Effect< + void, + CrewMemberModelNotEligibleError | CrewMemberReasoningNotEligibleError + >; } >()("t3/j5/agents/crewMemberModels") {} @@ -58,26 +86,48 @@ export const layer = Layer.effect( const settings = yield* ServerSettings.ServerSettingsService; const registry = yield* ProviderRegistry; const projects = yield* ProjectService; + const projectTitleOf = (projectId: ProjectId) => + projects.getById(projectId).pipe( + Effect.map(Option.map((project) => project.title)), + Effect.map(Option.getOrElse(() => projectId as string)), + Effect.orElseSucceed(() => projectId as string), + ); const assertEligible: CrewMemberModels["Service"]["assertEligible"] = Effect.fn( "j5.crewMemberModels.assertEligible", )(function* ({ projectId, selection }) { - const list = yield* settings.getSettings.pipe( - Effect.map((all) => resolveProjectSettings(all, projectId).settings.crewMemberModels), + const resolved = yield* settings.getSettings.pipe( + Effect.map((all) => resolveProjectSettings(all, projectId).settings), Effect.orDie, ); - if (isCrewMemberModelChecked(list, selection)) return; - const eligible = eligibleCrewMemberModels(list, yield* registry.getProviders); - const projectTitle = yield* projects.getById(projectId).pipe( - Effect.map(Option.map((project) => project.title)), - Effect.map(Option.getOrElse(() => projectId as string)), - Effect.orElseSucceed(() => projectId as string), + const list = resolved.crewMemberModels; + if (!isCrewMemberModelChecked(list, selection)) { + return yield* new CrewMemberModelNotEligibleError({ + projectId, + projectTitle: yield* projectTitleOf(projectId), + instanceId: selection.instanceId, + model: selection.model, + eligible: eligibleCrewMemberModels(list, yield* registry.getProviders), + }); + } + // With no saved list every level is eligible, so the catalog is not read at all. + const levels = resolved.crewMemberReasoning; + if (levels === null) return; + const provider = (yield* registry.getProviders).find( + (candidate) => candidate.instanceId === selection.instanceId, + ); + const level = crewMemberSelectionLevel( + provider?.models.find((model) => model.slug === selection.model), + selection.options, ); - return yield* new CrewMemberModelNotEligibleError({ + if (provider === undefined || level === null) return; + if (isCrewMemberLevelChecked(levels, { instanceId: provider.instanceId, level })) return; + return yield* new CrewMemberReasoningNotEligibleError({ projectId, - projectTitle, + projectTitle: yield* projectTitleOf(projectId), instanceId: selection.instanceId, model: selection.model, - eligible, + level, + eligible: eligibleCrewMemberLevelsForModel(levels, provider, selection.model), }); }); return CrewMemberModels.of({ assertEligible }); diff --git a/docs/j5/product/a2a/agent-tools.md b/docs/j5/product/a2a/agent-tools.md index f0291a180cccc..a072289697941 100644 --- a/docs/j5/product/a2a/agent-tools.md +++ b/docs/j5/product/a2a/agent-tools.md @@ -83,8 +83,7 @@ for the work in the brief — see orchestrator_capabilities for what's available from j5_list_personas, set `persona` to its id: the spawn gets that persona's instructions and runtime policy, and provider, model, and reasoning must be one of that persona's declared routes. Without a persona it runs in your permission and interaction modes, or in narrower ones you set with -runtime_mode and interaction_mode. Without a persona its model must be one the project's Models for -custom members list allows; an ineligible one is refused with the eligible models. Attach files to +runtime_mode and interaction_mode. Without a persona its model and reasoning level must be ones the project's Models for custom members lists allow; an ineligible one is refused with the eligible ones. Attach files to the brief with attachments. Choose its workspace every time (see the workspace field). A new worktree is prepared after this returns, and the agent begins once it is bound, possibly while the project's setup script is still running; if preparing it fails, the agent's thread shows why, and it is not retried. Reuse client_request_id to retry the @@ -202,9 +201,7 @@ custom seats in the same roster: call j5_list_personas when choosing a saved per persona unset for a custom seat with its own instructions (required) and the brief. Custom seats inherit your harness, model, and reasoning by default and run with full-access unless you set runtime_mode; to choose different ones, set model_selection (instanceId, model, options) and/or -runtime_mode using orchestrator_capabilities. A custom seat's model, yours included, must be one -the project's Models for custom members list allows; an ineligible one is refused with the eligible -models. Saved personas are proposed with their own configuration; only the human may override their runtime before approval. To have the crew follow +runtime_mode using orchestrator_capabilities. A custom seat's model and reasoning level, yours included, must be ones the project's Models for custom members lists allow; an ineligible one is refused with the eligible ones. Saved personas are proposed with their own configuration; only the human may override their runtime before approval. To have the crew follow a playbook, set playbook to a name from j5_playbook_list and give seats the step ids they own (steps, from j5_playbook_read); a step has one owner, steps no seat owns are yours as Captain, and the result reports unowned steps and any step whose persona differs from its seat's. For a crew @@ -258,7 +255,7 @@ caller, persona-backed where a seat names one, records the Crew snapshot with ea a `` launch report into the caller's thread immediately after creation: the roster, what the user changed against the proposal, and per seat `start=waiting|started|failed|pending`, with a `seat_failed` line carrying the run's error (`not_started` when the seat's thread exists but registration failed) and a `seat_not_created` line for an approved seat whose thread was never created, which is left off the roster. A proposal resolves once: a seat that fails does not stop the others or reopen the gate. Declines post the decline at once. Every seat names its workspace, with the same three choices as `j5_spawn_agent`, so there is no Captain-aware default (Jackson, 2026-10-03). Each seat's workspace resolves at preview against the Captain's repository, and the approval token binds it, as it binds the Captain's branch and worktree. Every preview also carries the Captain's current branch, the directory its branch picker searches, and its worktrees, for the roster card's editor; the branches themselves are searched live, so no list is capped. A seat the person adds starts in the Captain's checkout. A seat recorded before workspaces were required stays readable but is refused at preview and approval until one is chosen. New and added seats wait for their first assignment. A direct chat message, participant message, or playbook handoff activates the seat with its approved instructions and shared brief, the current roster with responsibilities and participant ids, and the assignment with its envelope and reply obligation intact. A new-worktree seat prepares its workspace before running that assignment; failed preparation is reported as a seat failure. New Crews require human approval by default. **Settings → Agent Setup → Crews → Auto-approve new Crews** skips that gate, off by default and overridable per project. The server reads the Captain's project setting only for a new request; changing it leaves existing Crews and open proposals alone. Automatic approval launches the proposed configuration through the same provider, workspace, capacity, and persona checks. Tool approvals still follow each seat's access. The persisted proposal and launch report distinguish automatic approval from a human decision. -**Models for custom members** is a project setting holding the checked provider models; until one is saved every model is eligible. A custom seat, including one that inherits the Captain's model, must run on an eligible model, checked at preview, at approval, and for an automatic launch, so a roster naming another is refused whole before anything spawns, with an error naming the seat, the model, the project and the setting and listing the eligible models. A saved persona seat that keeps the persona's model skips the check; one whose model the person changed on the card is checked like a custom seat. An accepted proposal is not checked again. +**Models for custom members** is a pair of project settings holding the checked provider models and the checked reasoning levels; until a list is saved everything it covers is eligible. A custom seat, including one that inherits the Captain's selection, must run on an eligible model at an eligible level (its explicit one, or the model's default), checked at preview, at approval, and for an automatic launch, so a roster naming another is refused whole before anything spawns, with an error naming the seat, the model or level, the project and the setting and listing the eligible ones. A model with no reasoning option has no level to check. A saved persona seat that keeps the persona's model and level skips the check; one where the person changed either on the card is checked like a custom seat. An accepted proposal is not checked again. ### `j5_request_crew_member` @@ -267,8 +264,7 @@ lacks. No human approval is needed, regardless of Auto-approve new Crews. Give a persona id from j5_list_personas or required instructions for a custom seat, a reason identifying the missing expertise, and its workspace (the same choices as j5_propose_crew). Custom seats inherit your model selection and run with full-access unless you set model_selection or -runtime_mode; a custom seat's model must be one the project's Models for custom members list -allows, and saved personas use their own configuration. Optionally give a brief; otherwise the +runtime_mode; a custom seat's model and reasoning level must be ones the project's Models for custom members lists allow, and saved personas use their own configuration. Optionally give a brief; otherwise the seat gets the Crew's brief. On a playbook Crew, steps may claim only unowned step ids from j5_playbook_read. The result returns the updated roster or refuses the seat with its name and reason; creation is reported separately here. The new member waits for its first assignment; send From ffa8fb4f6134d07cd62301ee448e28f47564213e Mon Sep 17 00:00:00 2001 From: Bryant Derosier Date: Tue, 27 Oct 2026 19:29:11 -0400 Subject: [PATCH 3/6] feat(web): choose reasoning levels for custom members in Agent Setup and the roster card (reasoning levels) Co-Authored-By: Claude Sonnet 5.5 --- .../src/j5/crew/CrewMemberModelsSettings.tsx | 164 +++++++++++++----- .../web/src/j5/crew/CrewProposalCard.test.tsx | 63 ++++++- apps/web/src/j5/crew/CrewProposalCard.tsx | 7 +- .../src/j5/crew/CrewProposalMemberDialog.tsx | 8 +- apps/web/src/j5/crew/CrewSeatEditor.tsx | 41 +++-- .../j5/crew/crewMemberModels.logic.test.ts | 152 ++++++++++++++++ .../web/src/j5/crew/crewMemberModels.logic.ts | 145 +++++++++++++++- apps/web/src/j5/crew/useCrewMemberModels.ts | 29 +++- 8 files changed, 544 insertions(+), 65 deletions(-) diff --git a/apps/web/src/j5/crew/CrewMemberModelsSettings.tsx b/apps/web/src/j5/crew/CrewMemberModelsSettings.tsx index 3564aeae8e267..ab1ad2b5efb5f 100644 --- a/apps/web/src/j5/crew/CrewMemberModelsSettings.tsx +++ b/apps/web/src/j5/crew/CrewMemberModelsSettings.tsx @@ -1,15 +1,20 @@ import { useAtomValue } from "@effect/atom-react"; import type { EnvironmentId, ServerProvider } from "@t3tools/contracts"; import { + crewMemberLevelCounts, crewMemberModelCounts, + crewMemberProviderLevels, + isCrewMemberLevelChecked, isCrewMemberModelChecked, isCrewMemberProviderSetUp, type CrewMemberModel, type CrewMemberModels, + type CrewMemberReasoning, + type CrewMemberReasoningLevel, } from "@t3tools/contracts/j5"; import { Link } from "@tanstack/react-router"; import { AlertTriangleIcon, ChevronDownIcon, ChevronRightIcon } from "lucide-react"; -import { useMemo, useState } from "react"; +import { useMemo, useState, type ReactNode } from "react"; import { ProviderInstanceIcon } from "../../components/chat/ProviderInstanceIcon"; import { SettingResetButton, SettingsRow } from "../../components/settings/settingsLayout"; @@ -26,16 +31,20 @@ import { serverEnvironment } from "../../state/server"; import { useEnvironmentQuery } from "../../state/query"; import { agentPersonaEnvironment } from "../agents/agentPersonaAtoms"; import { + crewMemberLevelsSummary, crewMemberModelLabel, crewMemberModelsSummary, + crewMemberProviderSummary, personasOffCrewMemberModels, + setCrewMemberLevelChecked, setCrewMemberModelChecked, setCrewMemberProviderChecked, + setCrewMemberProviderLevelsChecked, } from "./crewMemberModels.logic"; const NO_ENVIRONMENT = "" as EnvironmentId; -/** One model: solid when allowed. Every chip fills its grid cell, so they all match in size. */ +/** One model or level: solid when allowed. Every chip fills its grid cell, so they all match in size. */ function ModelChip(props: { readonly name: string; readonly checked: boolean; @@ -57,17 +66,40 @@ function ModelChip(props: { ); } +interface CrewMemberListsPatch { + readonly crewMemberModels?: ReadonlyArray; + readonly crewMemberReasoning?: ReadonlyArray; +} + +function ChipGroup(props: { readonly label: string; readonly children: ReactNode }) { + return ( +
+

+ {props.label} +

+
    + {props.children} +
+
+ ); +} + function ProviderModels(props: { readonly provider: ServerProvider; readonly providers: ReadonlyArray; readonly entry: ReturnType[number]; readonly list: CrewMemberModels; + readonly reasoning: CrewMemberReasoning; readonly open: boolean; readonly onOpenChange: (open: boolean) => void; - readonly onChange: (next: ReadonlyArray) => void; + readonly onChange: (patch: CrewMemberListsPatch) => void; }) { - const { provider, entry, list } = props; - const { checked, total } = crewMemberModelCounts(list, [provider]); + const { provider, entry, list, reasoning } = props; + const levels = crewMemberProviderLevels(provider); + const modelCounts = crewMemberModelCounts(list, [provider]); + const levelCounts = crewMemberLevelCounts(reasoning, [provider]); + const allChecked = + modelCounts.checked === modelCounts.total && levelCounts.checked === levelCounts.total; const Chevron = props.open ? ChevronDownIcon : ChevronRightIcon; return (
@@ -84,37 +116,86 @@ function ProviderModels(props: { {entry.displayName} - {checked} of {total} + {crewMemberProviderSummary(provider, list, reasoning)}
-
    - {provider.models.map((model) => { - const pair = { instanceId: provider.instanceId, model: model.slug }; - return ( -
  • - - props.onChange(setCrewMemberModelChecked(list, props.providers, pair, next)) - } - /> -
  • - ); - })} -
+
+ + {provider.models.map((model) => { + const pair = { instanceId: provider.instanceId, model: model.slug }; + return ( +
  • + + props.onChange({ + crewMemberModels: setCrewMemberModelChecked( + list, + props.providers, + pair, + next, + ), + }) + } + /> +
  • + ); + })} +
    + {levels.length === 0 ? null : ( + + {levels.map((level) => { + const key = { instanceId: provider.instanceId, level: level.level }; + return ( +
  • + + props.onChange({ + crewMemberReasoning: setCrewMemberLevelChecked( + reasoning, + props.providers, + key, + next, + ), + }) + } + /> +
  • + ); + })} +
    + )} +
    @@ -122,17 +203,18 @@ function ProviderModels(props: { } /** - * Which models custom Crew members, and plain agents started without a persona, may run on. - * Personas keep their own model, and native subagents are outside the list on every provider - * (docs/j5/product/crews.md). + * Which models and reasoning levels custom Crew members, and plain agents started without a + * persona, may use. Personas keep their own model and level, and native subagents are outside the + * lists on every provider (docs/j5/product/crews.md). */ export function CrewMemberModelsSettings() { const settings = useScopedSettings(); - const mixed = useScopedSettingsMixed(["crewMemberModels"]); + const mixed = useScopedSettingsMixed(["crewMemberModels", "crewMemberReasoning"]); const updateSettings = useUpdateScopedSettings(); const { target } = useSettingsScope(); const environmentId = target?.environmentId ?? null; const list = settings.crewMemberModels; + const reasoning = settings.crewMemberReasoning; const [open, setOpen] = useState(false); const [openProvider, setOpenProvider] = useState(null); const providers = useAtomValue( @@ -146,32 +228,35 @@ export function CrewMemberModelsSettings() { const setUp = entries.filter((entry) => isCrewMemberProviderSetUp(entry.snapshot)); const notSetUp = entries.filter((entry) => !isCrewMemberProviderSetUp(entry.snapshot)); const summary = crewMemberModelsSummary(list, known); + const levelSummary = crewMemberLevelsSummary(reasoning, known); const offList = personasOffCrewMemberModels(catalog.data, list); - const save = (next: ReadonlyArray) => updateSettings({ crewMemberModels: next }); + const save = (patch: CrewMemberListsPatch) => updateSettings(patch); const Chevron = open ? ChevronDownIcon : ChevronRightIcon; return (