From a611dda9346ed232af3caa3b0c67d68fbffec0ca Mon Sep 17 00:00:00 2001 From: yannickmonney Date: Sat, 3 Oct 2026 22:27:42 +0200 Subject: [PATCH 1/3] feat(platform): serve GPT-6 models in chat, keep subscriptions to tasks Direct chat now speaks the OpenAI Responses API for a model whose catalog entry says its tools work only there (toolCallingApi: responses), instead of refusing it: a third body in chat_wire (instructions, input items, function_call / function_call_output pairs, flat non-strict tools, max_output_tokens, five effort levels, store: false) and a third stream dialect in stream_decode (text, refusal and reasoning deltas, call drafts keyed by call_id, closing usage and finish reason, error and response.failed). The picker, Auto and the turn offer such a model on any OpenAI-format connector; the Chat Completions model endpoints keep it out. The OpenAI catalog gains gpt-6-astra (Responses tools, no off switch), gpt-6-sol and gpt-6-luna (off: none, toolsRequireOff), as the vendor's model pages and latest-model guide state. Tasks serve a Responses-only model only on a harness that speaks it (Codex today): agent serving names the Responses API and the capable harness instead of reporting the model missing; the project-agent check, the standard agent's chooser, the agent pickers and the Agent runtimes status offer, accept or count it only there. Subscription credentials stay in tasks, inside their vendor's runtime: the vendors permit those tokens nowhere else, and Anthropic refuses other clients. The add form shows a static notice for both subscription methods, every subscription row says "Tasks and automations only", the chat model list names the subscriptions it leaves out, and the direct chat refusals give the reason. --- .../platform/system/models/openai/models.yml | 60 ++ packages/shared/src/schemas/providers.ts | 5 +- .../components/agent-node-fields.tsx | 19 +- .../features/chat/components/chat-surface.tsx | 17 + .../components/composer-selection-picker.tsx | 33 +- .../chat/components/composer.test.tsx | 40 ++ .../app/features/chat/components/composer.tsx | 7 + .../components/project-agent-dialog.tsx | 27 +- .../projects/lib/model-options.test.ts | 84 +++ .../features/projects/lib/model-options.ts | 29 + .../components/standard-agent-editor.tsx | 20 +- .../components/providers-settings.test.tsx | 31 ++ .../components/subscription-scope-notice.tsx | 25 + .../settings/providers/credential-adapter.tsx | 36 +- .../platform/app/lib/backend/contract/chat.ts | 4 + .../backend/core/automations/llm_call.ts | 6 + .../automations_builder/chat_wire.test.ts | 229 ++++++++ .../core/automations_builder/chat_wire.ts | 174 +++++- .../backend/core/chat/composer.test.ts | 24 + .../platform/backend/core/chat/composer.ts | 8 + .../backend/core/chat/stream_decode.ts | 178 +++++- .../core/chat/turn_action.responses.test.ts | 514 ++++++++++++++++++ .../platform/backend/core/chat/turn_action.ts | 64 ++- .../core/lib/providers/agent_serving.test.ts | 8 +- .../core/lib/providers/agent_serving.ts | 60 +- .../core/lib/providers/chat_catalog.test.ts | 23 +- .../core/lib/providers/chat_catalog.ts | 14 +- .../core/lib/providers/harness_status.test.ts | 24 + .../core/lib/providers/harness_status.ts | 18 +- .../lib/providers/load_system_config.test.ts | 73 +++ .../platform/backend/domains/chat/composer.ts | 21 +- .../backend/domains/model_api/models.test.ts | 18 + .../backend/domains/model_api/models.ts | 4 + .../domains/projects/agent-equipment.test.ts | 55 ++ .../domains/projects/agent-equipment.ts | 49 +- .../domains/projects/standard-agent.test.ts | 51 ++ .../domains/projects/standard-agent.ts | 60 +- .../backend/domains/providers/routes.ts | 23 +- services/platform/lib/chat/turn.test.ts | 30 +- services/platform/lib/chat/turn.ts | 9 +- .../providers/resolve_execution.test.ts | 15 + .../lib/shared/providers/resolve_execution.ts | 45 +- services/platform/messages/de-CH.yml | 9 + services/platform/messages/de.yml | 21 +- services/platform/messages/en.yml | 20 +- services/platform/messages/fr.yml | 21 +- 46 files changed, 2104 insertions(+), 201 deletions(-) create mode 100644 services/platform/app/features/projects/lib/model-options.test.ts create mode 100644 services/platform/app/features/settings/providers/components/subscription-scope-notice.tsx create mode 100644 services/platform/backend/core/chat/turn_action.responses.test.ts diff --git a/configs/platform/system/models/openai/models.yml b/configs/platform/system/models/openai/models.yml index d6e2f43a53..7a63715078 100644 --- a/configs/platform/system/models/openai/models.yml +++ b/configs/platform/system/models/openai/models.yml @@ -10,6 +10,16 @@ # (2026-10-03). Tools require Responses; Chat Completions accepts no tools. # Reasoning cannot be disabled: neither none nor minimal is supported. # Codex subscription availability: https://learn.chatgpt.com/docs/models +# The GPT-6 family (Astra, Sol, Luna) read from the same pages and from the +# vendor's latest-model guide on 2026-10-03: "GPT-6 Astra and GPT-6.1 Sol +# support Chat Completions, but tool calling requires Responses", and "GPT-6 +# Sol and GPT-6 Luna support function calling in Chat Completions only with +# reasoning_effort: none". So Astra declares the Responses tool API (direct +# chat calls it there), while Sol and Luna declare off + toolsRequireOff like +# the 5.6 trio. Astra and Sol bill prompts over 272K input tokens at 2x input +# and cache rates and 1.5x output, which this per-token schema cannot express; +# the short-context prices are listed. Luna's cache writes are 1.25x its input +# rate, as the vendor states it. - id: gpt-6.1-sol provider: openai tags: @@ -26,6 +36,56 @@ outputCentsPerMillion: 1000 cacheReadCentsPerMillion: 10 cacheWriteCentsPerMillion: 250 +- id: gpt-6-astra + provider: openai + tags: + - chat + supportsTools: true + toolCallingApi: responses + supportsVision: true + reasoning: + knob: effort + contextWindow: 1050000 + maxOutputTokens: 128000 + pricing: + inputCentsPerMillion: 1000 + outputCentsPerMillion: 5000 + cacheReadCentsPerMillion: 100 + cacheWriteCentsPerMillion: 1250 +- id: gpt-6-sol + provider: openai + tags: + - chat + supportsTools: true + supportsVision: true + reasoning: + knob: effort + off: none + toolsRequireOff: true + contextWindow: 1050000 + maxOutputTokens: 128000 + pricing: + inputCentsPerMillion: 200 + outputCentsPerMillion: 1000 + cacheReadCentsPerMillion: 20 + cacheWriteCentsPerMillion: 250 +- id: gpt-6-luna + provider: openai + tags: + - chat + supportsTools: true + supportsVision: true + reasoning: + knob: effort + off: none + toolsRequireOff: true + contextWindow: 1050000 + maxOutputTokens: 128000 + pricing: + inputCentsPerMillion: 10 + outputCentsPerMillion: 50 + cacheReadCentsPerMillion: 1 + cacheWriteCentsPerMillion: 12.5 - id: gpt-5.5 provider: openai tags: diff --git a/packages/shared/src/schemas/providers.ts b/packages/shared/src/schemas/providers.ts index eb4d74f137..04a22800f1 100644 --- a/packages/shared/src/schemas/providers.ts +++ b/packages/shared/src/schemas/providers.ts @@ -480,7 +480,10 @@ export const modelCatalogEntrySchema = z supportsTools: z.boolean(), /** Function tools require this API even when the model also accepts * plain text through Chat Completions. Absent preserves the provider's - * existing tool wire. This is a model capability, not an auth method. */ + * existing tool wire. This is a model capability, not an auth method: + * direct chat then calls the model on the provider's Responses API + * (`/responses`, OpenAI-compatible providers only), and an agent + * harness serves it only when it speaks that wire. */ toolCallingApi: z.literal('responses').optional(), supportsVision: z.boolean(), /** The model GENERATES media (its output modalities include audio, image, diff --git a/services/platform/app/features/automations/components/agent-node-fields.tsx b/services/platform/app/features/automations/components/agent-node-fields.tsx index 6196b2c688..f339f54674 100644 --- a/services/platform/app/features/automations/components/agent-node-fields.tsx +++ b/services/platform/app/features/automations/components/agent-node-fields.tsx @@ -31,6 +31,7 @@ import { import { useUnpinnedServingPreview } from '@/app/features/projects/hooks/use-unpinned-serving-preview'; import { findSelectedModel, + offeredToHarness, toModelOptions, } from '@/app/features/projects/lib/model-options'; import { @@ -150,18 +151,20 @@ export function AgentNodeFields({ () => toModelOptions(roster.data?.models ?? []), [roster.data], ); - // Subscription-served entries are bound to their forced harness — offer - // them only when the node's EFFECTIVE harness (the host default when the - // field is unset) is that one. Direct-served entries fit every harness. + // Subscription-served entries are bound to their forced harness, and a + // Responses-only model needs a harness that speaks that API — offer each + // only when the node's EFFECTIVE harness (the host default when the field + // is unset) can run it. Other direct-served entries fit every harness. const effectiveHarness = harness === '' ? DEFAULT_HARNESS : harness; + const harnessWire = roster.data?.harnesses.find( + (entry) => entry.harness === effectiveHarness, + )?.toolCallingWire; const offeredModels = useMemo( () => - models.filter( - (option) => - option.subscription === undefined || - option.subscription.harness === effectiveHarness, + models.filter((option) => + offeredToHarness(option, effectiveHarness, harnessWire), ), - [models, effectiveHarness], + [models, effectiveHarness, harnessWire], ); const selectedModel = findSelectedModel(offeredModels, model, modelProvider); // Only claim "not offered" once the listing has answered — an empty roster diff --git a/services/platform/app/features/chat/components/chat-surface.tsx b/services/platform/app/features/chat/components/chat-surface.tsx index b841da75de..93b7df85ba 100644 --- a/services/platform/app/features/chat/components/chat-surface.tsx +++ b/services/platform/app/features/chat/components/chat-surface.tsx @@ -160,6 +160,7 @@ import { WelcomeView } from './welcome-view'; const NO_SELECTION: ComposerSelection = {}; const NO_MODELS: readonly ComposerModelOption[] = []; +const NO_PROVIDERS: readonly string[] = []; /** The message field's DOM id — the chat skip link's target. */ const COMPOSER_TEXTAREA_ID = 'chat-composer'; @@ -486,6 +487,21 @@ function ChatSurfaceInner({ : NO_MODELS, [composerOptions], ); + // The providers whose models are left out for that reason, named in the + // picker so a short or empty list explains itself. + const subscriptionProviders = useMemo(() => { + if (composerOptions.status !== 'ready') return NO_PROVIDERS; + const offered = new Set(models); + const hidden = composerOptions.data.models.filter( + (model) => !offered.has(model), + ); + if (hidden.length === 0) return NO_PROVIDERS; + return [ + ...new Set( + hidden.map((model) => model.providerLabel ?? model.providerSlug), + ), + ]; + }, [composerOptions, models]); // The thread being viewed, once the list has answered. const activeThread = @@ -2085,6 +2101,7 @@ function ChatSurfaceInner({ textareaId={COMPOSER_TEXTAREA_ID} draftKey={draftKey} models={models} + subscriptionProviders={subscriptionProviders} selection={selection} onSelectionChange={stableSelectionChange} onSend={stableSend} diff --git a/services/platform/app/features/chat/components/composer-selection-picker.tsx b/services/platform/app/features/chat/components/composer-selection-picker.tsx index b8317cc357..753a5f015d 100644 --- a/services/platform/app/features/chat/components/composer-selection-picker.tsx +++ b/services/platform/app/features/chat/components/composer-selection-picker.tsx @@ -19,6 +19,7 @@ import { type DropdownMenuGroup, type DropdownMenuItem, } from '@tale/ui/dropdown-menu'; +import { useLocale } from '@tale/ui/i18n/locale-provider'; import { ChevronDown, Cpu, Gauge } from 'lucide-react'; import { useMemo, useState, type ComponentType } from 'react'; @@ -44,6 +45,10 @@ const LEVEL_LABEL_KEY: Record = { interface ComposerSelectionPickerProps { /** The direct-served models the chat lane can call. */ models: readonly ComposerModelOption[]; + /** Providers whose models only a subscription serves: chat leaves them out + * (a subscription runs only in its vendor's own runtime, in tasks and + * automations), and the model list says so under its rows. */ + subscriptionProviders?: readonly string[]; selection: ComposerSelection; onSelectionChange: (next: ComposerSelection) => void; disabled?: boolean; @@ -51,11 +56,21 @@ interface ComposerSelectionPickerProps { export function ComposerSelectionPicker({ models, + subscriptionProviders = [], selection, onSelectionChange, disabled, }: ComposerSelectionPickerProps) { const { t } = useT('chat'); + const { locale } = useLocale(); + const subscriptionNote = + subscriptionProviders.length > 0 + ? t('modelSelector.subscriptionsTasksOnly', { + providers: new Intl.ListFormat(locale, { + type: 'conjunction', + }).format(subscriptionProviders), + }) + : undefined; // Controlled so a single pick inside a section submenu can close the whole // menu the way a plain menu item would. const [open, setOpen] = useState(false); @@ -158,11 +173,18 @@ export function ComposerSelectionPicker({ { type: 'custom', content: ( - +
+ + {subscriptionNote !== undefined && ( +

+ {subscriptionNote} +

+ )} +
), }, ), @@ -229,6 +251,7 @@ export function ComposerSelectionPicker({ return groups; }, [ modelChoices, + subscriptionNote, selection, onSelectionChange, selectedModel, diff --git a/services/platform/app/features/chat/components/composer.test.tsx b/services/platform/app/features/chat/components/composer.test.tsx index 5442ade4a7..a8e285d370 100644 --- a/services/platform/app/features/chat/components/composer.test.tsx +++ b/services/platform/app/features/chat/components/composer.test.tsx @@ -67,6 +67,7 @@ beforeEach(() => { /** Renders the composer with real selection state so picks stick. */ function renderComposer({ models = [MODEL], + subscriptionProviders, initial = {}, onSend = vi.fn(), onStop = vi.fn(), @@ -93,6 +94,7 @@ function renderComposer({ onIngestVideoUrls, }: { models?: ComposerModelOption[]; + subscriptionProviders?: readonly string[]; initial?: ComposerSelection; onSend?: (text: string) => void; onStop?: () => void; @@ -130,6 +132,9 @@ function renderComposer({ { ).toHaveTextContent('No models available'); }); + it('says under the model list which subscriptions run only in tasks', async () => { + const { user } = renderComposer({ + subscriptionProviders: ['Anthropic', 'OpenAI'], + }); + + await openSection(user, /^Model/); + expect( + await screen.findByText( + 'Subscriptions from Anthropic and OpenAI run only in tasks and automations. To chat with their models, add an API key or environment-variable credential.', + ), + ).toBeInTheDocument(); + }); + + it('says it even when the subscriptions are all there is to list', async () => { + const { user } = renderComposer({ + models: [], + subscriptionProviders: ['Anthropic'], + }); + + await openSection(user, /^Model/); + // The trigger and the empty list both say so; the note says why. + expect(await screen.findAllByText('No models available')).toHaveLength(2); + expect( + screen.getByText(/^Subscriptions from Anthropic run only in tasks/), + ).toBeInTheDocument(); + }); + + it('adds no note when no subscription is left out', async () => { + const { user } = renderComposer(); + + await openSection(user, /^Model/); + await screen.findByRole('menuitemradio', { name: /^Claude Fable 5/ }); + expect(screen.queryByText(/run only in tasks/)).toBeNull(); + }); + it('lists the models under the Model section, and a pick sticks', async () => { const { user, selection } = renderComposer({ models: [MODEL, SECOND_MODEL], diff --git a/services/platform/app/features/chat/components/composer.tsx b/services/platform/app/features/chat/components/composer.tsx index fd3d54e1c1..e65c8ecd15 100644 --- a/services/platform/app/features/chat/components/composer.tsx +++ b/services/platform/app/features/chat/components/composer.tsx @@ -102,6 +102,9 @@ interface ComposerProps { textareaId?: string; /** The direct-served models the chat lane can call. */ models: readonly ComposerModelOption[]; + /** Providers whose models only a subscription serves, which chat leaves + * out — the picker says why. */ + subscriptionProviders?: readonly string[]; selection: ComposerSelection; onSelectionChange: (next: ComposerSelection) => void; onSend: (text: string) => void; @@ -180,6 +183,7 @@ export const Composer = memo( draftKey, textareaId, models, + subscriptionProviders, selection, onSelectionChange, onSend, @@ -541,6 +545,9 @@ export const Composer = memo( /> 0 && harness !== '' && model !== ''; - // Subscription-served entries are bound to their forced harness — offer - // them only when that harness is the one selected. Direct-served entries - // are offered to every harness. + // Subscription-served entries are bound to their forced harness, and a + // Responses-only model needs a harness that speaks that API — offer each + // only where it can run. Other direct-served entries fit every harness. + const harnessWire = harnesses.find( + (option) => option.harness === harness, + )?.toolCallingWire; const offeredModels = useMemo( () => - models.filter( - (option) => - option.subscription === undefined || - option.subscription.harness === harness, - ), - [models, harness], + models.filter((option) => offeredToHarness(option, harness, harnessWire)), + [models, harness, harnessWire], ); const selectedModel = findSelectedModel(offeredModels, model, modelProvider); // A pick saved before providers were part of it names a model but no diff --git a/services/platform/app/features/projects/lib/model-options.test.ts b/services/platform/app/features/projects/lib/model-options.test.ts new file mode 100644 index 0000000000..47187f18ae --- /dev/null +++ b/services/platform/app/features/projects/lib/model-options.test.ts @@ -0,0 +1,84 @@ +import { describe, expect, it } from 'vitest'; + +import { offeredToHarness, toModelOptions } from './model-options'; + +/** + * The agent pickers offer a model only where it can run: a subscription's + * model on the harness its credential is bound to, and a model whose tools + * work only on the Responses API on a harness that speaks that API. A model + * offered anywhere else saved fine and failed at the first task start. + */ +describe('toModelOptions + offeredToHarness', () => { + const [direct, responsesOnly, subscription] = toModelOptions([ + { + id: 'gpt-6-luna', + label: 'GPT 6 Luna', + providerSlug: 'openai', + providerLabel: 'OpenAI', + credential: { authMethod: 'api-key' }, + }, + { + id: 'gpt-6.1-sol', + label: 'GPT 6.1 Sol', + providerSlug: 'openai', + providerLabel: 'OpenAI', + toolCallingApi: 'responses', + credential: { authMethod: 'env' }, + }, + { + id: 'claude-fable-5', + label: 'Claude Fable 5', + providerSlug: 'anthropic', + providerLabel: 'Anthropic', + credential: { + authMethod: 'subscription-broker', + constraints: { harness: 'claude-code' }, + }, + }, + ]); + + it('marks what each listing row may run on', () => { + expect(direct).toEqual({ + id: 'gpt-6-luna', + label: 'GPT 6 Luna', + providerSlug: 'openai', + providerLabel: 'OpenAI', + }); + expect(responsesOnly).toMatchObject({ responsesOnly: true }); + expect(responsesOnly).not.toHaveProperty('subscription'); + expect(subscription).toMatchObject({ + subscription: { harness: 'claude-code' }, + }); + }); + + it('offers a direct model to every harness', () => { + if (direct === undefined) throw new Error('missing option'); + expect(offeredToHarness(direct, 'opencode', 'openai-chat')).toBe(true); + expect(offeredToHarness(direct, 'claude-code', 'anthropic')).toBe(true); + }); + + it('offers a Responses-only model only to a harness that speaks the Responses API', () => { + if (responsesOnly === undefined) throw new Error('missing option'); + expect(offeredToHarness(responsesOnly, 'codex', 'openai-responses')).toBe( + true, + ); + expect(offeredToHarness(responsesOnly, 'opencode', 'openai-chat')).toBe( + false, + ); + expect(offeredToHarness(responsesOnly, 'claude-code', 'anthropic')).toBe( + false, + ); + // Before the roster answers, the wire is unknown: nothing is promised. + expect(offeredToHarness(responsesOnly, 'codex', undefined)).toBe(false); + }); + + it('offers a subscription model only to the harness it is bound to', () => { + if (subscription === undefined) throw new Error('missing option'); + expect(offeredToHarness(subscription, 'claude-code', 'anthropic')).toBe( + true, + ); + expect(offeredToHarness(subscription, 'codex', 'openai-responses')).toBe( + false, + ); + }); +}); diff --git a/services/platform/app/features/projects/lib/model-options.ts b/services/platform/app/features/projects/lib/model-options.ts index 2cb4d994a4..f4e654f5e4 100644 --- a/services/platform/app/features/projects/lib/model-options.ts +++ b/services/platform/app/features/projects/lib/model-options.ts @@ -18,14 +18,21 @@ export interface ModelOption { /** Present when a subscription credential serves this entry — usable only * by its forced harness, so the picker offers it for that harness alone. */ subscription?: { harness: string }; + /** Present when the model's tools work only on the Responses API — usable + * only by a harness that speaks it. */ + responsesOnly?: true; } +/** The wire a harness speaks to the gateway, as the listing carries it. */ +export type HarnessToolWire = 'anthropic' | 'openai-chat' | 'openai-responses'; + /** A `listComposerModels` row, narrowed to the fields the mapping reads. */ export interface ComposerModelListingRow { id: string; label: string; providerSlug: string; providerLabel: string; + toolCallingApi?: 'responses'; credential: | { authMethod: 'api-key' | 'env' } | { @@ -52,10 +59,32 @@ export function toModelOptions( ) { option.subscription = { harness: row.credential.constraints.harness }; } + if (row.toolCallingApi === 'responses') option.responsesOnly = true; return option; }); } +/** + * Whether a picker offers `option` to an agent on `harness`, which speaks + * `wire`: a subscription-served entry only to the harness its credential is + * bound to, and a Responses-only entry only to a harness that speaks the + * Responses API. An unknown wire (the roster still loading) offers no + * Responses-only entry. + */ +export function offeredToHarness( + option: ModelOption, + harness: string, + wire: HarnessToolWire | undefined, +): boolean { + if ( + option.subscription !== undefined && + option.subscription.harness !== harness + ) { + return false; + } + return option.responsesOnly !== true || wire === 'openai-responses'; +} + /** The offered option matching a saved pick: the exact (provider, id) pair, * and nothing looser. A pinless legacy pick deliberately matches NOTHING * here — an id-alone fallback used to preselect whichever provider happened diff --git a/services/platform/app/features/settings/governance/components/standard-agent-editor.tsx b/services/platform/app/features/settings/governance/components/standard-agent-editor.tsx index c1812759b9..4678573729 100644 --- a/services/platform/app/features/settings/governance/components/standard-agent-editor.tsx +++ b/services/platform/app/features/settings/governance/components/standard-agent-editor.tsx @@ -203,16 +203,24 @@ export function StandardAgentEditor({ return rows; }, [harness, roster.data?.harnesses, t]); - // A subscription's model runs only on the runtime it is bound to: with a - // runtime chosen, offer what it can run. + // A subscription's model runs only on the runtime it is bound to, and a + // Responses-only model only on a runtime that speaks that API: with a + // runtime chosen, offer what it can run. Automatic picks the runtime. const modelOptions = useMemo(() => { + const harnessWire = roster.data?.harnesses.find( + (entry) => entry.harness === harness, + )?.toolCallingWire; const runnable = (roster.data?.models ?? []).filter((model) => { + if (harness === AUTOMATIC) return true; const credential = model.credential; - return ( - harness === AUTOMATIC || + const bound = credential.authMethod === 'api-key' || credential.authMethod === 'env' || - credential.constraints.harness === harness + credential.constraints.harness === harness; + return ( + bound && + (model.toolCallingApi !== 'responses' || + harnessWire === 'openai-responses') ); }); const rows: SearchableSelectOption[] = [ @@ -236,7 +244,7 @@ export function StandardAgentEditor({ }); } return rows; - }, [harness, roster.data?.models, selection, t]); + }, [harness, roster.data?.harnesses, roster.data?.models, selection, t]); // What a run would get, for the person looking — only once saved: a draft // is not what runs. diff --git a/services/platform/app/features/settings/providers/components/providers-settings.test.tsx b/services/platform/app/features/settings/providers/components/providers-settings.test.tsx index 5b2c9b83ab..02138cef3d 100644 --- a/services/platform/app/features/settings/providers/components/providers-settings.test.tsx +++ b/services/platform/app/features/settings/providers/components/providers-settings.test.tsx @@ -346,6 +346,16 @@ describe('ProvidersSettings', () => { expect(screen.getByText(/OpenRouter API unreachable/)).toBeInTheDocument(); }); + it('says on a subscription row that it serves tasks and automations, never chat', () => { + renderPage(); + // The broker row carries it; the api-key and env rows do not. + expect( + screen.getAllByText( + 'Tasks and automations only — chat needs an API key or environment variable', + ), + ).toHaveLength(1); + }); + it('names a credential whose provider left the catalog by its stored slug', () => { fixtures.catalogs = [openrouterProvider]; fixtures.credentials = [ @@ -449,6 +459,27 @@ describe('ProvidersSettings', () => { ).toEqual(['API key', 'Environment variable', 'Subscription broker']); }); + it('explains before the broker fields that a subscription never serves chat, and why', async () => { + const { user } = renderPage(); + const form = await pickProvider(user, 'Anthropic'); + // The direct method needs no such word. + expect(form.queryByText('Tasks and automations only')).toBeNull(); + await user.click( + form.getByRole('combobox', { name: /Authentication method/ }), + ); + await user.click( + screen.getByRole('option', { name: 'Subscription broker' }), + ); + expect(form.getByText('Tasks and automations only')).toBeInTheDocument(); + expect( + form.getByText( + /vendors do not\s+permit these tokens in other applications/, + ), + ).toBeInTheDocument(); + // A static notice describes the method; it announces nothing. + expect(form.queryByRole('alert')).toBeNull(); + }); + it('names the credential after its provider, numbered past a name that provider already holds', async () => { createCredential.mockResolvedValue({ credentialId: 'cred-9' }); fixtures.credentials = [ diff --git a/services/platform/app/features/settings/providers/components/subscription-scope-notice.tsx b/services/platform/app/features/settings/providers/components/subscription-scope-notice.tsx new file mode 100644 index 0000000000..935e1edb99 --- /dev/null +++ b/services/platform/app/features/settings/providers/components/subscription-scope-notice.tsx @@ -0,0 +1,25 @@ +'use client'; + +import { Alert } from '@tale/ui/alert'; + +import { useT } from '@/lib/i18n/client'; + +/** + * Why a subscription credential never serves chat, said where one is set + * up: its tokens run only inside the vendor's own agent runtime in a + * sandbox — the vendors permit them nowhere else, and Anthropic refuses them + * from any other client — so tasks and automations use it, and chat needs an + * API key or environment-variable credential. Static: it describes the + * method, it does not announce an event. + */ +export function SubscriptionScopeNotice() { + const { t } = useT('settings'); + return ( + + ); +} diff --git a/services/platform/app/features/settings/providers/credential-adapter.tsx b/services/platform/app/features/settings/providers/credential-adapter.tsx index 81f5f686ea..39ba0093d7 100644 --- a/services/platform/app/features/settings/providers/credential-adapter.tsx +++ b/services/platform/app/features/settings/providers/credential-adapter.tsx @@ -7,7 +7,6 @@ import { import { Input } from '@tale/ui/input'; import { Stack } from '@tale/ui/layout'; import { RadioGroup } from '@tale/ui/radio-group'; -import { Text } from '@tale/ui/text'; import { useToast } from '@tale/ui/use-toast'; import { RefreshCw } from 'lucide-react'; import { useEffect } from 'react'; @@ -34,6 +33,7 @@ import { mapProviderDefinitionError, type CustomProviderFacts, } from './components/provider-definition-form'; +import { SubscriptionScopeNotice } from './components/subscription-scope-notice'; import { useCreateProviderCredential, useUpdateProviderCredential, @@ -181,14 +181,10 @@ function SecretFields({ if (method === 'subscription-key') { return ( <> - {/* A subscription key is handed to a sandboxed harness rather than - called directly, which changes where it can leak — say so before - the field, not after. */} - {!replacing && ( - - {t('providers.dialog.sandboxedExplainer')} - - )} + {/* A subscription key is handed to the vendor's own harness in a + sandbox, never called directly — so it serves tasks and + automations and never chat. Say so before the field, not after. */} + {!replacing && } onChange({ ...value, broker })} - disabled={disabled} - /> + <> + {!replacing && } + onChange({ ...value, broker })} + disabled={disabled} + /> + ); } @@ -500,12 +499,17 @@ export const providerCredentialAdapter: CredentialAdapter< // A provider with two working keys and no model list still cannot serve a // request, so the catalog failure belongs on every row that depends on it. - detailLine: (t, _credential, vendor) => + // Otherwise a subscription row says where it runs: chat never offers its + // models, and the row is where an admin looks for why. + detailLine: (t, credential, vendor) => vendor?.catalog.catalogError !== undefined ? t('providers.card.catalogUnavailable', { error: vendor.catalog.catalogError, }) - : undefined, + : credential.authMethod === 'subscription-key' || + credential.authMethod === 'subscription-broker' + ? t('providers.credential.tasksOnly') + : undefined, // A custom provider lives and dies with its credentials: the last one going // retires the definition, and the delete dialog says so. diff --git a/services/platform/app/lib/backend/contract/chat.ts b/services/platform/app/lib/backend/contract/chat.ts index bae3c6a594..6dc7dc190b 100644 --- a/services/platform/app/lib/backend/contract/chat.ts +++ b/services/platform/app/lib/backend/contract/chat.ts @@ -65,6 +65,8 @@ export interface ChatContract { knob: 'effort' | 'budget-tokens'; }; vision?: boolean; + /** Its function tools work only on the Responses API. */ + toolCallingApi?: 'responses'; id: string; providerSlug: string; label: string; @@ -85,6 +87,8 @@ export interface ChatContract { harness: string; label: string; iconUrl: undefined | string; + /** The wire the harness speaks to the gateway. */ + toolCallingWire: 'anthropic' | 'openai-chat' | 'openai-responses'; }>; voice: { ttsAvailable: boolean; diff --git a/services/platform/backend/core/automations/llm_call.ts b/services/platform/backend/core/automations/llm_call.ts index e8eccd1569..9155d74478 100644 --- a/services/platform/backend/core/automations/llm_call.ts +++ b/services/platform/backend/core/automations/llm_call.ts @@ -31,6 +31,7 @@ import { } from '../automations_builder/model_call'; import type { ActionCtx } from '../lib/ctx'; import { + responsesToolsRefusal, walkDirectServing, type DirectServingWalk, } from '../lib/providers/agent_serving'; @@ -97,6 +98,11 @@ export async function resolveServingTarget( walk.unreachable.length > 0 ? ` (the catalog for ${walk.unreachable.map((name) => `"${name}"`).join(', ')} was unreachable)` : ''; + // Only an agent turn passes a wire; its model was listed, but its tools + // need the Responses API. + if (walk.wireRefused.length > 0) { + throw new Error(`${responsesToolsRefusal(modelId)}${detail}`); + } throw new Error( `no configured provider serves model "${modelId}" — an llm node's model must be listed in a connected provider's catalog and permitted by its credential${detail}`, ); diff --git a/services/platform/backend/core/automations_builder/chat_wire.test.ts b/services/platform/backend/core/automations_builder/chat_wire.test.ts index 1031c39f4b..f67c8716ef 100644 --- a/services/platform/backend/core/automations_builder/chat_wire.test.ts +++ b/services/platform/backend/core/automations_builder/chat_wire.test.ts @@ -751,3 +751,232 @@ describe('the openai-modern dialect', () => { expect(body).not.toHaveProperty('max_completion_tokens'); }); }); + +describe('the Responses API shape', () => { + const tools = [ + { + name: 'rag_search', + description: 'Search the knowledge.', + parameters: { type: 'object', properties: { query: { type: 'string' } } }, + }, + ]; + const transcript = [ + { role: 'system' as const, content: 'GUIDE' }, + { + role: 'user' as const, + content: 'WHAT IS THIS?', + images: [{ mediaType: 'image/png', dataBase64: 'AAAA' }], + }, + { + role: 'assistant' as const, + content: 'Let me check.', + toolCalls: [{ id: 'call_1', name: 'rag_search', input: { query: 'x' } }], + }, + { + role: 'tool' as const, + content: '', + toolResults: [{ callId: 'call_1', content: '{"hits":1}' }], + }, + { + role: 'assistant' as const, + content: '', + toolCalls: [{ id: 'call_2', name: 'rag_search', input: undefined }], + }, + { + role: 'tool' as const, + content: '', + toolResults: [{ callId: 'call_2', content: 'none' }], + }, + { role: 'user' as const, content: 'THANKS' }, + ]; + + function responsesRequest( + overrides: Partial[0]> = {}, + ) { + return buildChatRequest({ + apiFormat: 'openai', + wireDialect: 'openai-modern', + toolCallingApi: 'responses', + reasoningModel: true, + baseUrl: 'https://api.openai.test/v1/', + modelId: 'gpt-6.1-sol', + apiKey: 'secret-key', + messages: transcript, + tools, + temperature: 0.3, + maxTokens: 4096, + reasoning: { kind: 'effort', value: 'high' }, + extraHeaders: { 'x-attribution': 'tale' }, + ...overrides, + }); + } + + it('posts the transcript as input items to the responses path', () => { + const wire = responsesRequest(); + expect(wire.url).toBe('https://api.openai.test/v1/responses'); + expect(wire.headers).toEqual({ + 'content-type': 'application/json', + authorization: 'Bearer secret-key', + 'x-attribution': 'tale', + }); + expect(JSON.parse(wire.body)).toEqual({ + model: 'gpt-6.1-sol', + instructions: 'GUIDE', + max_output_tokens: 4096, + reasoning: { effort: 'high' }, + tools: [ + { + type: 'function', + name: 'rag_search', + description: 'Search the knowledge.', + parameters: { + type: 'object', + properties: { query: { type: 'string' } }, + }, + strict: false, + }, + ], + input: [ + { + role: 'user', + content: [ + { type: 'input_text', text: 'WHAT IS THIS?' }, + { type: 'input_image', image_url: 'data:image/png;base64,AAAA' }, + ], + }, + { role: 'assistant', content: 'Let me check.' }, + { + type: 'function_call', + call_id: 'call_1', + name: 'rag_search', + arguments: '{"query":"x"}', + }, + { + type: 'function_call_output', + call_id: 'call_1', + output: '{"hits":1}', + }, + // A call-only assistant turn adds no empty message, and arguments + // the model never sent read as an empty object. + { + type: 'function_call', + call_id: 'call_2', + name: 'rag_search', + arguments: '{}', + }, + { type: 'function_call_output', call_id: 'call_2', output: 'none' }, + { role: 'user', content: 'THANKS' }, + ], + store: false, + }); + }); + + it('sends a temperature only for a model known not to reason', () => { + expect(JSON.parse(responsesRequest().body)).not.toHaveProperty( + 'temperature', + ); + expect( + JSON.parse(responsesRequest({ reasoningModel: undefined }).body), + ).not.toHaveProperty('temperature'); + expect( + JSON.parse(responsesRequest({ reasoningModel: false }).body), + ).toMatchObject({ temperature: 0.3 }); + }); + + it('omits instructions, tools and reasoning it was not given', () => { + const body: unknown = JSON.parse( + responsesRequest({ + messages: [{ role: 'user', content: 'HI' }], + tools: undefined, + reasoning: undefined, + }).body, + ); + expect(body).toEqual({ + model: 'gpt-6.1-sol', + max_output_tokens: 4096, + input: [{ role: 'user', content: 'HI' }], + store: false, + }); + }); + + // The Responses API takes all five steps, unlike Chat Completions' three, + // and the off literals pass through. + it.each([ + ['low', 'low'], + ['medium', 'medium'], + ['high', 'high'], + ['extra', 'xhigh'], + ['max', 'max'], + ['none', 'none'], + ['minimal', 'minimal'], + ] as const)( + 'spells the %s step as the Responses effort %s', + (step, level) => { + const body: unknown = JSON.parse( + responsesRequest({ reasoning: { kind: 'effort', value: step } }).body, + ); + expect(body).toMatchObject({ reasoning: { effort: level } }); + expect(body).not.toHaveProperty('reasoning_effort'); + }, + ); + + it('drops a thinking budget, which the Responses API cannot spell', () => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}); + const body: unknown = JSON.parse( + responsesRequest({ + reasoning: { kind: 'thinking', budgetTokens: 2048 }, + }).body, + ); + expect(body).not.toHaveProperty('reasoning'); + expect(warn).toHaveBeenCalledOnce(); + warn.mockRestore(); + }); + + it('refuses the pairing with an Anthropic-format connector', () => { + expect(() => + responsesRequest({ apiFormat: 'anthropic', wireDialect: undefined }), + ).toThrow(/Responses API/); + }); + + it('serves the shipped Sol 6.1 at every effort step its page lists', () => { + const entry = loadStaticCatalogs() + .get('openai') + ?.find((model) => model.id === 'gpt-6.1-sol'); + if (entry === undefined) throw new Error('the catalog misses gpt-6.1-sol'); + for (const [effort, level] of [ + [undefined, undefined], + ['low', 'low'], + ['extra', 'xhigh'], + ['max', 'max'], + ] as const) { + const sampling = resolveTurnSampling(entry, effort); + const body: unknown = JSON.parse( + buildChatRequest({ + apiFormat: 'openai', + wireDialect: 'openai-modern', + toolCallingApi: entry.toolCallingApi, + reasoningModel: entry.reasoning !== undefined, + baseUrl: 'https://api.openai.test/v1', + modelId: entry.id, + apiKey: 'secret-key', + messages: [{ role: 'user', content: 'HI' }], + tools, + maxTokens: sampling.maxTokens, + ...(sampling.temperature !== undefined + ? { temperature: sampling.temperature } + : {}), + ...(sampling.reasoning !== undefined + ? { reasoning: sampling.reasoning } + : {}), + }).body, + ); + expect(body).not.toHaveProperty('temperature'); + if (level === undefined) { + // Default: the model's own effort, never an off literal it refuses. + expect(body).not.toHaveProperty('reasoning'); + } else { + expect(body).toMatchObject({ reasoning: { effort: level } }); + } + } + }); +}); diff --git a/services/platform/backend/core/automations_builder/chat_wire.ts b/services/platform/backend/core/automations_builder/chat_wire.ts index 4070d8396e..b682b8399c 100644 --- a/services/platform/backend/core/automations_builder/chat_wire.ts +++ b/services/platform/backend/core/automations_builder/chat_wire.ts @@ -6,15 +6,22 @@ * pure data mapping and deserves to be tested without a network, a * credential, or a Node runtime. Two formats exist because provider * connectors declare exactly two: OpenAI-compatible chat completions and - * Anthropic messages. + * Anthropic messages. An OpenAI-compatible connector speaks a third body for + * a model whose catalog entry says its function tools work only on the + * Responses API (`toolCallingApi: responses`). * * Two shape rules matter and are easy to get wrong: * - Anthropic takes the system prompt as a top-level parameter, not as a - * message. Consecutive messages of the same role are merged here. + * message (the Responses API too, as `instructions`). Consecutive + * Anthropic messages of the same role are merged here. * - `max_tokens` is mandatory for Anthropic and caps the reply on OpenAI. */ -import type { ApiFormat, WireDialect } from '@tale/shared/schemas/providers'; +import type { + ApiFormat, + ModelCatalogEntry, + WireDialect, +} from '@tale/shared/schemas/providers'; import type { TurnSampling } from '../../../lib/chat/effort'; import type { WireTool } from '../../../lib/chat/tools'; @@ -74,6 +81,14 @@ export interface ChatWireArgs { * model after Claude Opus 4.6 does (and an older one does while it thinks). */ reasoningModel?: boolean; + /** + * The model's tool API, from its catalog entry. `responses` builds the + * OpenAI Responses API body (`POST /responses`) instead of Chat + * Completions — the one wire on which such a model's function tools work. + * Only an OpenAI-compatible connector can spell it. Absent keeps the + * connector's own format. + */ + toolCallingApi?: ModelCatalogEntry['toolCallingApi']; /** The connector's API origin, with or without a trailing slash. */ baseUrl: string; modelId: string; @@ -88,11 +103,12 @@ export interface ChatWireArgs { temperature?: number; maxTokens: number; /** - * The turn's reasoning control, when one was resolved. BOTH dialects spell - * an effort level — `reasoning_effort` on the OpenAI surface, - * `output_config.effort` on the Anthropic one — each folding the step to - * its own vocabulary. A thinking-token budget is an Anthropic-wire control - * alone; an OpenAI body cannot spell it and drops it loudly. + * The turn's reasoning control, when one was resolved. EVERY body spells + * an effort level — `reasoning_effort` on Chat Completions, + * `reasoning.effort` on the Responses API, `output_config.effort` on the + * Anthropic wire — each folding the step to its own vocabulary. A + * thinking-token budget is an Anthropic-wire control alone; an OpenAI body + * cannot spell it and drops it loudly. */ reasoning?: TurnSampling['reasoning']; /** Provider attribution headers the platform sends where they apply. */ @@ -120,7 +136,9 @@ type EffortValue = Extract< * them. Anthropic's `output_config.effort` takes all five, spelling the * fourth `xhigh` — but has no off literal at all, so an `off` declaration on * an Anthropic-wire model resolves to `undefined` and the parameter is left - * off the body rather than guessed at. + * off the body rather than guessed at. The Responses API takes all five too + * (`xhigh`, `max`: the vendor's pages for the models that need this wire + * list both) and passes the off literals through. */ const OPENAI_EFFORT_LEVELS = { none: 'none', @@ -132,6 +150,16 @@ const OPENAI_EFFORT_LEVELS = { max: 'high', } as const satisfies Record; +const RESPONSES_EFFORT_LEVELS = { + none: 'none', + minimal: 'minimal', + low: 'low', + medium: 'medium', + high: 'high', + extra: 'xhigh', + max: 'max', +} as const satisfies Record; + const ANTHROPIC_EFFORT_LEVELS = { none: undefined, minimal: undefined, @@ -155,12 +183,12 @@ const ANTHROPIC_EFFORT_LEVELS = { * is exactly how both shipped mismatches went unnoticed. */ function reasoningParameter( - apiFormat: ApiFormat, + body: ApiFormat | 'responses', reasoning: TurnSampling['reasoning'], modelId: string, ): Record { if (reasoning === undefined) return {}; - if (apiFormat === 'anthropic') { + if (body === 'anthropic') { if (reasoning.kind === 'thinking') { return { thinking: { type: 'enabled', budget_tokens: reasoning.budgetTokens }, @@ -181,6 +209,9 @@ function reasoningParameter( ); return {}; } + if (body === 'responses') { + return { reasoning: { effort: RESPONSES_EFFORT_LEVELS[reasoning.value] } }; + } return { reasoning_effort: OPENAI_EFFORT_LEVELS[reasoning.value] }; } @@ -303,6 +334,115 @@ function anthropicBlockTurns( return turns; } +/** The transcript as Responses API `input` items. System turns are left to + * `instructions`. A user turn is a message (its images `input_image` parts), + * an assistant turn its text as a message followed by one `function_call` + * item per call, and each tool result a `function_call_output` item, paired + * by `call_id`. No item carries a stored id: the request is `store: false`, + * so each round sends the whole transcript, as Chat Completions does. */ +function responsesInput( + messages: ChatWireMessage[], +): Array> { + const input: Array> = []; + for (const message of messages) { + if (message.role === 'system') continue; + if (message.role === 'tool') { + for (const result of message.toolResults ?? []) { + input.push({ + type: 'function_call_output', + call_id: result.callId, + output: result.content, + }); + } + continue; + } + if (message.role === 'user') { + // Images force the content-parts array; a text-only turn keeps the + // plain string, as on Chat Completions. + const images = message.images ?? []; + input.push({ + role: 'user', + content: + images.length > 0 + ? [ + ...(message.content.length > 0 + ? [{ type: 'input_text', text: message.content }] + : []), + ...images.map((image) => ({ + type: 'input_image', + image_url: `data:${image.mediaType};base64,${image.dataBase64}`, + })), + ] + : message.content, + }); + continue; + } + if (message.content.length > 0) { + input.push({ role: 'assistant', content: message.content }); + } + for (const call of message.toolCalls ?? []) { + input.push({ + type: 'function_call', + call_id: call.id, + name: call.name, + arguments: JSON.stringify(call.input ?? {}), + }); + } + } + return input; +} + +/** + * The OpenAI Responses API request, for a model whose function tools work + * only there. The system prompt rides `instructions`; the output cap is + * `max_output_tokens`, the surface's only spelling; a custom temperature + * rides only a model KNOWN not to reason, as on the `openai-modern` dialect. + * Function tools are declared flat and NOT strict: the Responses API + * validates strictly unless told otherwise, and the chat's tool schemas were + * written for Chat Completions, which does not. `store: false` keeps the + * conversation off the vendor's side. + */ +function buildResponsesRequest( + args: ChatWireArgs, + base: string, + extra: Record, +): ChatWireRequest { + const instructions = args.messages + .filter((message) => message.role === 'system') + .map((message) => message.content) + .join('\n\n'); + const sendTemperature = + args.temperature !== undefined && args.reasoningModel === false; + return { + url: `${base}/responses`, + headers: { + 'content-type': 'application/json', + authorization: `Bearer ${args.apiKey}`, + ...extra, + }, + body: JSON.stringify({ + model: args.modelId, + ...(instructions ? { instructions } : {}), + max_output_tokens: args.maxTokens, + ...(sendTemperature ? { temperature: args.temperature } : {}), + ...reasoningParameter('responses', args.reasoning, args.modelId), + ...(args.tools !== undefined && args.tools.length > 0 + ? { + tools: args.tools.map((tool) => ({ + type: 'function', + name: tool.name, + description: tool.description, + parameters: tool.parameters, + strict: false, + })), + } + : {}), + input: responsesInput(args.messages), + store: false, + }), + }; +} + export function buildChatRequest(args: ChatWireArgs): ChatWireRequest { const base = stripTrailingSlash(args.baseUrl); const extra = args.extraHeaders ?? {}; @@ -311,6 +451,18 @@ export function buildChatRequest(args: ChatWireArgs): ChatWireRequest { // prompt caches and golden tests never move. const toolMode = carriesToolMaterial(args) || carriesImages(args); + if (args.toolCallingApi === 'responses') { + // The Responses API is an OpenAI surface; an Anthropic-format connector + // has nothing to send such a model's tools on. The chat host refuses + // that pairing before the turn starts — this is the last line. + if (args.apiFormat !== 'openai') { + throw new Error( + `model "${args.modelId}" needs the Responses API for its tools, which an ${args.apiFormat} connector cannot speak`, + ); + } + return buildResponsesRequest(args, base, extra); + } + if (args.apiFormat === 'anthropic') { const system = args.messages .filter((message) => message.role === 'system') diff --git a/services/platform/backend/core/chat/composer.test.ts b/services/platform/backend/core/chat/composer.test.ts index c40a167f32..b8eac01d72 100644 --- a/services/platform/backend/core/chat/composer.test.ts +++ b/services/platform/backend/core/chat/composer.test.ts @@ -64,5 +64,29 @@ describe('collectComposerOptions', () => { label: 'GLM 5v Turbo', providerLabel: 'Z.ai (GLM)', }); + expect(byId.get('zai glm-5v-turbo')).not.toHaveProperty('toolCallingApi'); + }); + + it('carries the Responses tool API, which decides the harnesses an agent picker offers it to', () => { + const hit = { + connector: { name: 'openai', displayName: 'OpenAI', apiFormat: 'openai' }, + credential: { authMethod: 'api-key' }, + credentialAuth: { authMethod: 'api-key' as const }, + entry: { + id: 'gpt-6.1-sol', + provider: 'openai', + tags: ['chat'], + supportsTools: true, + toolCallingApi: 'responses', + supportsVision: true, + contextWindow: 1_050_000, + }, + }; + // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- the walk's hit shape, narrowed to what the projection reads + const { byId } = collectComposerOptions([hit as never]); + expect(byId.get('openai gpt-6.1-sol')).toMatchObject({ + id: 'gpt-6.1-sol', + toolCallingApi: 'responses', + }); }); }); diff --git a/services/platform/backend/core/chat/composer.ts b/services/platform/backend/core/chat/composer.ts index 1668caec15..28633c999d 100644 --- a/services/platform/backend/core/chat/composer.ts +++ b/services/platform/backend/core/chat/composer.ts @@ -98,6 +98,11 @@ export interface ComposerModelOption { vision?: boolean; /** The model accepts function tools (catalog `supportsTools`). */ tools: boolean; + /** Its function tools work only on the Responses API (catalog + * `toolCallingApi`): direct chat calls it there, an agent harness only + * when it speaks that wire, and the Chat Completions model endpoints not + * at all. */ + toolCallingApi?: 'responses'; /** Total context window in tokens (catalog `contextWindow`). */ contextWindow: number; maxOutputTokens?: number; @@ -164,6 +169,9 @@ export function collectComposerOptions( : {}), ...(entry.supportsVision ? { vision: true } : {}), tools: entry.supportsTools, + ...(entry.toolCallingApi !== undefined + ? { toolCallingApi: entry.toolCallingApi } + : {}), contextWindow: entry.contextWindow, ...(entry.maxOutputTokens !== undefined ? { maxOutputTokens: entry.maxOutputTokens } diff --git a/services/platform/backend/core/chat/stream_decode.ts b/services/platform/backend/core/chat/stream_decode.ts index 690584e0d0..f9ae3a5f73 100644 --- a/services/platform/backend/core/chat/stream_decode.ts +++ b/services/platform/backend/core/chat/stream_decode.ts @@ -1,6 +1,7 @@ /** - * How a streamed model answer is read, event by event, in the two dialects - * the platform's chat speaks — OpenAI-compatible chat completions and + * How a streamed model answer is read, event by event, in the three dialects + * the platform's chat speaks — OpenAI-compatible chat completions, the + * OpenAI Responses API (for a model whose tools work only there) and * Anthropic Messages: the incremental text, the reasoning, the tool-call * fragments, the finish reason, the usage the provider reports, and a * failure it reports after the stream opened. The chat turn's stream reader @@ -17,6 +18,11 @@ import type { ApiFormat } from '@tale/shared/schemas/providers'; import type { TurnFinishReason, TurnUsage } from '../../../lib/chat/types'; import { isRecord } from '../../../lib/utils/type-utils'; +/** What a stream is read as: a connector's API format, or the OpenAI + * Responses API an OpenAI-compatible connector speaks for a model whose + * catalog entry declares `toolCallingApi: responses`. */ +export type StreamDialect = ApiFormat | 'openai-responses'; + function asRecord(value: unknown): Record | null { return isRecord(value) ? value : null; } @@ -97,6 +103,129 @@ function openAiFinishReason(value: unknown): TurnFinishReason | undefined { } } +/** Why a Responses API answer ended, read off its closing event: a completed + * response that called tools ends on them, an incomplete one names its + * reason (`max_output_tokens`, `content_filter`). */ +function responsesFinishReason( + type: string, + response: Record | null, + calledTools: boolean, +): TurnFinishReason | undefined { + if (type === 'response.completed') return calledTools ? 'tool-calls' : 'stop'; + if (type !== 'response.incomplete') return undefined; + const reason = asRecord(response?.incomplete_details)?.reason; + switch (reason) { + case 'max_output_tokens': + return 'length'; + case 'content_filter': + return 'content-filter'; + default: + return 'other'; + } +} + +/** + * One Responses API event, folded the way {@link readEvent} folds the other + * dialects. Text and refusal deltas are the reply; reasoning deltas arrive + * only for a request that asked for summaries. A function call is announced + * by its output item (carrying `call_id` and `name`), drips its arguments as + * deltas, and closes with the complete arguments, which win over what the + * deltas put together. Usage arrives once, on the closing `response.*` + * event — never earlier, as on Chat Completions. + */ +function readResponsesEvent( + event: Record, + state: StreamDecodeState, +): { + text: string; + reasoning?: string; + usage?: TurnUsage; + finishReason?: TurnFinishReason; +} { + const type = typeof event.type === 'string' ? event.type : ''; + const delta = typeof event.delta === 'string' ? event.delta : ''; + const index = + typeof event.output_index === 'number' ? event.output_index : null; + switch (type) { + case 'response.output_text.delta': + case 'response.refusal.delta': + return { text: delta }; + case 'response.reasoning_summary_text.delta': + case 'response.reasoning_text.delta': + return { text: '', ...(delta ? { reasoning: delta } : {}) }; + case 'response.output_item.added': + case 'response.output_item.done': { + const item = asRecord(event.item); + if (item?.type !== 'function_call' || index === null) return { text: '' }; + const draft = state.drafts.get(index) ?? { + id: '', + name: '', + argumentsJson: '', + }; + // The call's own id is `call_id`; the item `id` names the stored item + // and is never what a function result answers. + if (typeof item.call_id === 'string' && item.call_id.length > 0) { + draft.id = item.call_id; + } + if (typeof item.name === 'string' && item.name.length > 0) { + draft.name = item.name; + } + if ( + type === 'response.output_item.done' && + typeof item.arguments === 'string' + ) { + draft.argumentsJson = item.arguments; + } + state.drafts.set(index, draft); + return { text: '' }; + } + case 'response.function_call_arguments.delta': { + const draft = index !== null ? state.drafts.get(index) : undefined; + if (draft) draft.argumentsJson += delta; + return { text: '' }; + } + case 'response.function_call_arguments.done': { + const draft = index !== null ? state.drafts.get(index) : undefined; + if (draft && typeof event.arguments === 'string') { + draft.argumentsJson = event.arguments; + } + return { text: '' }; + } + case 'response.completed': + case 'response.incomplete': + case 'response.failed': { + const response = asRecord(event.response); + const usage = asRecord(response?.usage); + if (usage) { + state.running.input = tokenCount(usage, 'input_tokens'); + state.running.output = tokenCount(usage, 'output_tokens'); + const cached = optionalTokenCount( + asRecord(usage.input_tokens_details), + 'cached_tokens', + ); + if (cached !== undefined) state.running.cached = cached; + const reasoning = optionalTokenCount( + asRecord(usage.output_tokens_details), + 'reasoning_tokens', + ); + if (reasoning !== undefined) state.running.reasoning = reasoning; + } + const finishReason = responsesFinishReason( + type, + response, + state.drafts.size > 0, + ); + return { + text: '', + ...(usage ? { usage: totals(state.running) } : {}), + ...(finishReason !== undefined ? { finishReason } : {}), + }; + } + default: + return { text: '' }; + } +} + /** The Anthropic `stop_reason` vocabulary folded onto the platform's. */ function anthropicStopReason(value: unknown): TurnFinishReason | undefined { if (typeof value !== 'string' || value.length === 0) return undefined; @@ -123,7 +252,7 @@ function anthropicStopReason(value: unknown): TurnFinishReason | undefined { * for its unit tests — fragment accumulation across events is exactly the * kind of seam a live stream hides. */ export function readEvent( - apiFormat: ApiFormat, + dialect: StreamDialect, event: Record, state: StreamDecodeState, ): { @@ -133,7 +262,8 @@ export function readEvent( finishReason?: TurnFinishReason; } { const runningUsage = state.running; - if (apiFormat === 'anthropic') { + if (dialect === 'openai-responses') return readResponsesEvent(event, state); + if (dialect === 'anthropic') { const type = event.type; if (type === 'message_start') { const message = asRecord(event.message); @@ -299,14 +429,18 @@ export interface StreamFailure { * overloaded or disconnected provider — arrives as an EVENT on a `200` * stream. OpenAI-compatible servers send `{"error": {…}}` (OpenRouter beside * a choice whose `finish_reason` is `error`); the Anthropic wire sends - * `{"type": "error", "error": {…}}`. Read as an ordinary event it carries no - * text and no usage, so the round used to end as a completed, empty reply: - * the provider's words were dropped and the reader was shown nothing at all. + * `{"type": "error", "error": {…}}`; the Responses API sends an `error` event + * with its code and message on the event itself, or closes the response as + * `response.failed` with them under `response.error`. Read as an ordinary + * event it carries no text and no usage, so the round used to end as a + * completed, empty reply: the provider's words were dropped and the reader + * was shown nothing at all. */ export function readStreamFailure( - apiFormat: ApiFormat, + dialect: StreamDialect, event: Record, ): StreamFailure | undefined { + if (dialect === 'openai-responses') return readResponsesFailure(event); const raw = event.error; const error = asRecord(raw); // An error that says something. Some servers stamp `"error": null` (or an @@ -318,7 +452,7 @@ export function readStreamFailure( error.code != null || error.type != null)); const failed = - apiFormat === 'anthropic' + dialect === 'anthropic' ? event.type === 'error' : reported || (Array.isArray(event.choices) && @@ -327,6 +461,32 @@ export function readStreamFailure( if (typeof raw === 'string') return { message: raw }; // The failure was announced with no body to go with it. if (!error) return { message: '' }; + return failureOf(error); +} + +/** A Responses API failure: the `error` event (its code and message on the + * event itself, or — from a server that wraps it — under `error`), or a + * response that closed as `response.failed`. */ +function readResponsesFailure( + event: Record, +): StreamFailure | undefined { + if (event.type === 'error') { + // The event's own `type` names the event, not the failure: only its + // code may stand for one. + return failureOf( + asRecord(event.error) ?? { message: event.message, code: event.code }, + ); + } + if (event.type === 'response.failed') { + const error = asRecord(asRecord(event.response)?.error); + return error ? failureOf(error) : { message: '' }; + } + return undefined; +} + +/** The provider's sentence, its code or type, and the HTTP status that code + * stands for when it is one, read off one error object. */ +function failureOf(error: Record): StreamFailure { const message = typeof error.message === 'string' ? error.message : ''; const named = error.code ?? error.type; const code = diff --git a/services/platform/backend/core/chat/turn_action.responses.test.ts b/services/platform/backend/core/chat/turn_action.responses.test.ts new file mode 100644 index 0000000000..906ff7fab8 --- /dev/null +++ b/services/platform/backend/core/chat/turn_action.responses.test.ts @@ -0,0 +1,514 @@ +// @vitest-environment node + +/** + * A model whose function tools work only on the Responses API streams its + * answer in that API's events, not as Chat Completions deltas: the text and + * refusal deltas, each function call announced by its output item and + * closed with its complete arguments, and the usage once, on the closing + * `response.*` event. A failure arrives as an `error` event or a response + * that closed as `response.failed`. Read through the same stream reader a + * chat turn uses, so the turn sees the chunks it sees from every other + * dialect. + */ + +import { afterEach, describe, expect, it, vi } from 'vitest'; + +import type { ModelCallRequest } from '../../../lib/chat/turn'; +import type { ActionCtx } from '../lib/ctx'; +import { loadProviderDefinitions } from '../lib/providers/load_system_config'; +import { readEvent, readStreamFailure } from './stream_decode'; +import { + createDirectModelCall, + streamSse, + type DirectWire, +} from './turn_action'; + +/** An SSE body the way the Responses API writes one: an `event:` line naming + * each event, then its `data:` line (which repeats the type). */ +function responsesStream(events: readonly Record[]): Response { + const body = events + .map( + (event) => + `event: ${String(event.type)}\ndata: ${JSON.stringify(event)}\n\n`, + ) + .join(''); + return new Response(body, { + headers: { 'content-type': 'text/event-stream' }, + }); +} + +async function chunksOf(response: Response) { + const chunks = []; + for await (const chunk of streamSse(response, 'openai-responses')) { + chunks.push(chunk); + } + return chunks; +} + +const USAGE = { + input_tokens: 1200, + input_tokens_details: { cached_tokens: 1000 }, + output_tokens: 80, + output_tokens_details: { reasoning_tokens: 50 }, + total_tokens: 1280, +}; + +describe('streamSse — the Responses API stream', () => { + it('streams the text and settles the closing usage, cache and reasoning counts included', async () => { + const chunks = await chunksOf( + responsesStream([ + { type: 'response.created', response: { status: 'in_progress' } }, + { + type: 'response.output_item.added', + output_index: 0, + item: { type: 'reasoning', id: 'rs_1' }, + }, + { + type: 'response.output_item.added', + output_index: 1, + item: { type: 'message', id: 'msg_1', role: 'assistant' }, + }, + { type: 'response.output_text.delta', output_index: 1, delta: 'Hel' }, + { type: 'response.output_text.delta', output_index: 1, delta: 'lo.' }, + { + type: 'response.completed', + response: { status: 'completed', usage: USAGE }, + }, + ]), + ); + expect(chunks.map((chunk) => chunk.text).join('')).toBe('Hello.'); + expect(chunks.at(-1)).toEqual({ + text: '', + usage: { + inputTokens: 1200, + outputTokens: 80, + totalTokens: 1280, + cachedInputTokens: 1000, + reasoningTokens: 50, + }, + finishReason: 'stop', + }); + }); + + it('settles the function calls it announced, keyed by call_id, in output order', async () => { + const chunks = await chunksOf( + responsesStream([ + { + type: 'response.output_item.added', + output_index: 1, + item: { + type: 'function_call', + id: 'fc_1', + call_id: 'call_a', + name: 'rag_search', + arguments: '', + }, + }, + { + type: 'response.output_item.added', + output_index: 2, + item: { + type: 'function_call', + id: 'fc_2', + call_id: 'call_b', + name: 'rag_fetch', + arguments: '', + }, + }, + { + type: 'response.function_call_arguments.delta', + output_index: 2, + item_id: 'fc_2', + delta: '{"ref":', + }, + { + type: 'response.function_call_arguments.delta', + output_index: 1, + item_id: 'fc_1', + delta: '{"query":"tax"}', + }, + { + type: 'response.function_call_arguments.delta', + output_index: 2, + item_id: 'fc_2', + delta: '"doc-1"}', + }, + // A delta for an item that was never announced has nowhere to go. + { + type: 'response.function_call_arguments.delta', + output_index: 7, + delta: '{"lost":true}', + }, + { + type: 'response.function_call_arguments.done', + output_index: 1, + item_id: 'fc_1', + arguments: '{"query":"tax"}', + }, + { + type: 'response.output_item.done', + output_index: 2, + item: { + type: 'function_call', + id: 'fc_2', + call_id: 'call_b', + name: 'rag_fetch', + arguments: '{"ref":"doc-1"}', + }, + }, + { + type: 'response.completed', + response: { + status: 'completed', + usage: { input_tokens: 300, output_tokens: 40 }, + }, + }, + ]), + ); + expect(chunks.at(-1)).toEqual({ + text: '', + usage: { inputTokens: 300, outputTokens: 40, totalTokens: 340 }, + finishReason: 'tool-calls', + toolCalls: [ + { id: 'call_a', name: 'rag_search', input: { query: 'tax' } }, + { id: 'call_b', name: 'rag_fetch', input: { ref: 'doc-1' } }, + ], + }); + }); + + it('lets the closing arguments win over what the deltas put together', async () => { + const chunks = await chunksOf( + responsesStream([ + { + type: 'response.output_item.added', + output_index: 0, + item: { type: 'function_call', call_id: 'call_a', name: 'lookup' }, + }, + { + type: 'response.function_call_arguments.delta', + output_index: 0, + delta: '{"q":"partial', + }, + { + type: 'response.function_call_arguments.done', + output_index: 0, + arguments: '{"q":"whole"}', + }, + { type: 'response.completed', response: { status: 'completed' } }, + ]), + ); + expect(chunks.at(-1)).toMatchObject({ + finishReason: 'tool-calls', + toolCalls: [{ id: 'call_a', name: 'lookup', input: { q: 'whole' } }], + }); + }); + + it('reads a refusal as the reply text', async () => { + const chunks = await chunksOf( + responsesStream([ + { type: 'response.refusal.delta', output_index: 0, delta: 'I cannot.' }, + { type: 'response.completed', response: { status: 'completed' } }, + ]), + ); + expect(chunks.map((chunk) => chunk.text).join('')).toBe('I cannot.'); + }); + + it('carries the reasoning summary a request asked for', async () => { + const chunks = await chunksOf( + responsesStream([ + { + type: 'response.reasoning_summary_text.delta', + output_index: 0, + delta: 'Thinking it over.', + }, + { type: 'response.reasoning_summary_text.delta', delta: '' }, + { type: 'response.output_text.delta', delta: 'Done.' }, + ]), + ); + expect(chunks).toEqual([ + { text: '', reasoning: 'Thinking it over.' }, + { text: 'Done.' }, + ]); + }); + + it.each([ + ['max_output_tokens', 'length'], + ['content_filter', 'content-filter'], + ['something_new', 'other'], + ])( + 'names an incomplete answer cut by %s as %s', + async (reason, finishReason) => { + const chunks = await chunksOf( + responsesStream([ + { type: 'response.output_text.delta', delta: 'Partial' }, + { + type: 'response.incomplete', + response: { + status: 'incomplete', + incomplete_details: { reason }, + usage: { input_tokens: 10, output_tokens: 20 }, + }, + }, + ]), + ); + expect(chunks.at(-1)).toEqual({ + text: '', + usage: { inputTokens: 10, outputTokens: 20, totalTokens: 30 }, + finishReason, + }); + }, + ); + + it('ends the round with the words of an error event', async () => { + const response = responsesStream([ + { type: 'response.output_text.delta', delta: 'Start' }, + { + type: 'error', + code: 'rate_limit_exceeded', + message: 'Rate limit reached for gpt-6.1-sol.', + param: null, + }, + { type: 'response.output_text.delta', delta: 'never read' }, + ]); + const seen: string[] = []; + await expect(async () => { + for await (const chunk of streamSse(response, 'openai-responses')) { + seen.push(chunk.text); + } + }).rejects.toMatchObject({ + message: expect.stringContaining('Rate limit reached for gpt-6.1-sol.'), + code: 'rate_limit_exceeded', + }); + expect(seen).toEqual(['Start']); + }); + + it('books what a failed response reports before ending the round with its words', async () => { + const response = responsesStream([ + { + type: 'response.failed', + response: { + status: 'failed', + error: { code: 'server_error', message: 'The server had an error.' }, + usage: { input_tokens: 500, output_tokens: 0 }, + }, + }, + ]); + const chunks: unknown[] = []; + await expect(async () => { + for await (const chunk of streamSse(response, 'openai-responses')) { + chunks.push(chunk); + } + }).rejects.toMatchObject({ + message: expect.stringContaining('The server had an error.'), + code: 'server_error', + }); + expect(chunks).toEqual([ + { + text: '', + usage: { inputTokens: 500, outputTokens: 0, totalTokens: 500 }, + }, + ]); + }); +}); + +describe('readStreamFailure — the Responses API', () => { + it('reads an error a server wrapped under `error`', () => { + expect( + readStreamFailure('openai-responses', { + type: 'error', + error: { code: 429, message: 'Too many requests' }, + }), + ).toEqual({ message: 'Too many requests', code: '429', status: 429 }); + }); + + it('reads an error event with no code without taking its type for one', () => { + expect( + readStreamFailure('openai-responses', { + type: 'error', + code: null, + message: 'Something broke', + }), + ).toEqual({ message: 'Something broke' }); + }); + + it('reads a failed response that named no error', () => { + expect( + readStreamFailure('openai-responses', { + type: 'response.failed', + response: { status: 'failed' }, + }), + ).toEqual({ message: '' }); + }); + + it('reads no failure from an ordinary event, nor from a Chat Completions error shape', () => { + expect( + readStreamFailure('openai-responses', { + type: 'response.output_text.delta', + delta: 'ok', + }), + ).toBeUndefined(); + // `{"error": {...}}` is a Chat Completions failure; the Responses API + // names its failures by event type. + expect( + readStreamFailure('openai-responses', { + type: 'response.in_progress', + error: null, + }), + ).toBeUndefined(); + }); +}); + +describe('readEvent — the Responses API', () => { + it('ignores the control events and output items that are not function calls', () => { + const state = { running: { input: 0, output: 0 }, drafts: new Map() }; + for (const event of [ + { type: 'response.created' }, + { type: 'response.in_progress' }, + { type: 'response.content_part.added', output_index: 0 }, + { type: 'response.output_text.done', output_index: 0, text: 'x' }, + { type: 'response.output_item.added', item: { type: 'function_call' } }, + { + type: 'response.output_item.done', + output_index: 0, + item: { type: 'message' }, + }, + { type: 'response.function_call_arguments.done', arguments: '{}' }, + { output_index: 0, delta: 'untyped' }, + ]) { + expect(readEvent('openai-responses', event, state)).toEqual({ + text: '', + }); + } + expect(state.drafts.size).toBe(0); + }); +}); + +describe('createDirectModelCall — the wire a direct chat turn takes', () => { + afterEach(() => { + vi.unstubAllGlobals(); + }); + + const openai = loadProviderDefinitions().find( + (provider) => provider.name === 'openai', + ); + if (openai === undefined) + throw new Error('the shipped openai provider is gone'); + const wire: DirectWire = { + apiFormat: 'openai', + wireDialect: 'openai-modern', + baseUrl: 'https://api.openai.com/v1', + apiKey: 'sk-test', + attribution: {}, + }; + // The call reads nothing off the context unless a message carries an + // attachment to inline. + // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- unread without attachments + const ctx = {} as ActionCtx; + + function request(overrides: Partial): ModelCallRequest { + return { + organizationId: 'org_a', + model: 'gpt-6.1-sol', + providerSlug: 'openai', + system: 'GUIDE', + messages: [{ role: 'user', parts: [{ type: 'text', text: 'HI' }] }], + tools: [ + { + name: 'rag_search', + description: 'Search the knowledge.', + parameters: { type: 'object', properties: {} }, + }, + ], + execution: { mode: 'direct' }, + sampling: { + maxTokens: 4096, + temperature: 0.7, + reasoning: { kind: 'effort', value: 'extra' }, + }, + ...overrides, + }; + } + + /** Stub the provider: record each request, answer with `answer`. */ + function stubProvider(answer: () => Response) { + const seen: Array<{ url: string; body: Record }> = []; + vi.stubGlobal( + 'fetch', + vi.fn(async (url: string, init?: RequestInit) => { + // The direct call always sends its body as a JSON string. + const body = typeof init?.body === 'string' ? init.body : '{}'; + seen.push({ url, body: JSON.parse(body) }); + return answer(); + }), + ); + return seen; + } + + it('calls a Responses-only model on the Responses API and reads its stream', async () => { + const seen = stubProvider(() => + responsesStream([ + { type: 'response.output_text.delta', delta: 'Hello.' }, + { + type: 'response.completed', + response: { + status: 'completed', + usage: { input_tokens: 30, output_tokens: 3 }, + }, + }, + ]), + ); + const call = createDirectModelCall(ctx, 'org_a', openai, wire); + const chunks = []; + for await (const chunk of call(request({ toolCallingApi: 'responses' }))) { + chunks.push(chunk); + } + expect(seen).toHaveLength(1); + expect(seen[0]?.url).toBe('https://api.openai.com/v1/responses'); + expect(seen[0]?.body).toMatchObject({ + model: 'gpt-6.1-sol', + instructions: 'GUIDE', + max_output_tokens: 4096, + reasoning: { effort: 'xhigh' }, + input: [{ role: 'user', content: 'HI' }], + store: false, + stream: true, + }); + // The shipped entry reasons, so the platform's temperature stays off; + // the Responses API refuses the Chat Completions usage option. + expect(seen[0]?.body).not.toHaveProperty('temperature'); + expect(seen[0]?.body).not.toHaveProperty('stream_options'); + expect(chunks.map((chunk) => chunk.text).join('')).toBe('Hello.'); + expect(chunks.at(-1)).toMatchObject({ + usage: { inputTokens: 30, outputTokens: 3 }, + finishReason: 'stop', + }); + }); + + it('keeps a model without the flag on Chat Completions, usage frame requested', async () => { + const seen = stubProvider( + () => + new Response( + `data: ${JSON.stringify({ + choices: [ + { index: 0, delta: { content: 'Hi.' }, finish_reason: 'stop' }, + ], + })}\n\ndata: [DONE]\n\n`, + { headers: { 'content-type': 'text/event-stream' } }, + ), + ); + const call = createDirectModelCall(ctx, 'org_a', openai, wire); + const chunks = []; + for await (const chunk of call(request({ model: 'gpt-5.6-sol' }))) { + chunks.push(chunk); + } + expect(seen[0]?.url).toBe('https://api.openai.com/v1/chat/completions'); + expect(seen[0]?.body).toMatchObject({ + model: 'gpt-5.6-sol', + stream: true, + stream_options: { include_usage: true }, + reasoning_effort: 'high', + }); + expect(seen[0]?.body).not.toHaveProperty('input'); + expect(chunks.map((chunk) => chunk.text).join('')).toBe('Hi.'); + }); +}); diff --git a/services/platform/backend/core/chat/turn_action.ts b/services/platform/backend/core/chat/turn_action.ts index e1b75987db..df92ddb068 100644 --- a/services/platform/backend/core/chat/turn_action.ts +++ b/services/platform/backend/core/chat/turn_action.ts @@ -80,6 +80,7 @@ import { readEvent, readStreamFailure, type StreamDecodeState, + type StreamDialect, type StreamFailure, type ToolCallDraft, } from './stream_decode'; @@ -94,7 +95,7 @@ const ERROR_EXCERPT = 2000; // ------------------------------------------------------------- the model call -interface DirectWire { +export interface DirectWire { readonly apiFormat: ApiFormat; readonly wireDialect?: WireDialect; readonly baseUrl: string; @@ -104,7 +105,8 @@ interface DirectWire { /** Resolve the credential and endpoint for a direct call, refusing anything a * direct chat turn cannot serve. Mirrors the one resolution every direct model - * call shares: a subscription credential is bound to a vendor harness and + * call shares: a subscription credential is bound to a vendor harness — the + * vendors permit subscription tokens only in their own agent runtime — and * cannot answer a chat endpoint. */ async function resolveDirectWire( ctx: ActionCtx, @@ -118,7 +120,7 @@ async function resolveDirectWire( if (credential.authMethod !== 'api-key' && credential.authMethod !== 'env') { throw new AppError({ code: 'CHAT_CREDENTIAL_UNSUPPORTED', - message: `The default "${connector.name}" credential is a ${credential.authMethod} credential, which is bound to a vendor harness and only runs in a sandbox. Configure an API-key or environment-variable credential to chat with this model directly.`, + message: `The default "${connector.name}" credential is a ${credential.authMethod} credential. The vendor permits subscription tokens only in its own agent runtime, so it runs in tasks and automations, never in chat. Configure an API-key or environment-variable credential to chat with this model.`, }); } const baseUrl = credential.endpointUrl ?? connector.baseUrl; @@ -234,7 +236,7 @@ function streamFailureError(failure: StreamFailure): Error { * words ({@link streamFailureError}), whatever had streamed before it. */ export async function* streamSse( response: Response, - apiFormat: ApiFormat, + dialect: StreamDialect, stall?: StallGuard, ): AsyncGenerator { const body = response.body; @@ -294,12 +296,12 @@ export async function* streamSse( continue; } if (!event) continue; - const failure = readStreamFailure(apiFormat, event); + const failure = readStreamFailure(dialect, event); if (failure !== undefined) { // Usage the failure event itself reports is what the round had // consumed: hand it on before the round ends, so it is booked. A // count of nothing is no evidence of consumption, and stays behind. - const { usage } = readEvent(apiFormat, event, state); + const { usage } = readEvent(dialect, event, state); if ( usage !== undefined && (usage.inputTokens > 0 || usage.outputTokens > 0) @@ -315,7 +317,7 @@ export async function* streamSse( throw streamFailureError(failure); } const { text, reasoning, usage, finishReason } = readEvent( - apiFormat, + dialect, event, state, ); @@ -444,8 +446,9 @@ async function settleWireAttachments( /** Build the real streaming model call for direct execution over a wire * the host resolved UP FRONT (`resolveDirectWire`) — so a credential fault - * is a pre-turn refusal, never a failed bubble inside the stream. */ -function createDirectModelCall( + * is a pre-turn refusal, never a failed bubble inside the stream. Exported + * for its tests, which drive it against a stubbed `fetch`. */ +export function createDirectModelCall( ctx: ActionCtx, organizationId: string, connector: ProviderDefinition, @@ -468,12 +471,22 @@ function createDirectModelCall( // TALE_ALLOW_PRIVATE_PROVIDER_HOSTS=1. checkProviderHostPolicy(wire.baseUrl); - // The modern OpenAI dialect and the Anthropic wire send a custom - // temperature only for a model KNOWN not to reason; that fact lives on - // the catalog entry (absent for credential-allowlist connectors like - // Azure, where unknown must count as reasoning). + // A model whose function tools work only on the Responses API (its + // catalog entry says so) is called there; everything else keeps the + // connector's own wire. + const responses = request.toolCallingApi === 'responses'; + const dialect: StreamDialect = responses + ? 'openai-responses' + : wire.apiFormat; + + // The modern OpenAI dialect, the Responses API and the Anthropic wire + // send a custom temperature only for a model KNOWN not to reason; that + // fact lives on the catalog entry (absent for credential-allowlist + // connectors like Azure, where unknown must count as reasoning). if ( - (wire.wireDialect !== undefined || wire.apiFormat === 'anthropic') && + (wire.wireDialect !== undefined || + wire.apiFormat === 'anthropic' || + responses) && !reasoningResolved ) { const entry = (await getProviderCatalog(connector)).find( @@ -502,6 +515,7 @@ function createDirectModelCall( ? { wireDialect: wire.wireDialect } : {}), ...(reasoningModel !== undefined ? { reasoningModel } : {}), + ...(responses ? { toolCallingApi: 'responses' as const } : {}), baseUrl: wire.baseUrl, modelId: request.model, apiKey: wire.apiKey, @@ -518,15 +532,16 @@ function createDirectModelCall( : {}), extraHeaders: wire.attribution, }); - // Reuse the dialect shaping, then flip streaming on. OpenAI-compatible - // endpoints must be asked for a usage frame explicitly. + // Reuse the dialect shaping, then flip streaming on. Chat Completions + // endpoints must be asked for a usage frame explicitly; the Responses + // API reports usage on its closing event and refuses the option. const parsed: unknown = JSON.parse(base.body); const body = JSON.stringify({ ...(isRecord(parsed) ? parsed : {}), stream: true, - ...(wire.apiFormat === 'anthropic' - ? {} - : { stream_options: { include_usage: true } }), + ...(dialect === 'openai' + ? { stream_options: { include_usage: true } } + : {}), }); // The round's only clock is a SILENCE clock — never a whole-request @@ -557,12 +572,7 @@ function createDirectModelCall( ); } try { - yield* streamProviderAnswer( - response, - wire.apiFormat, - stall, - request.onAccepted, - ); + yield* streamProviderAnswer(response, dialect, stall, request.onAccepted); } finally { stall.dispose(); } @@ -581,7 +591,7 @@ function createDirectModelCall( */ export async function* streamProviderAnswer( response: Response, - apiFormat: ApiFormat, + dialect: StreamDialect, stall: StallGuard, onAccepted?: () => void, ): AsyncGenerator { @@ -599,7 +609,7 @@ export async function* streamProviderAnswer( // Headers count as the first sign of life; the body's bytes take over. stall.touch(); onAccepted?.(); - yield* streamSse(response, apiFormat, stall); + yield* streamSse(response, dialect, stall); } // ----------------------------------------------------------------- the turn diff --git a/services/platform/backend/core/lib/providers/agent_serving.test.ts b/services/platform/backend/core/lib/providers/agent_serving.test.ts index ad11af5201..3490f262c4 100644 --- a/services/platform/backend/core/lib/providers/agent_serving.test.ts +++ b/services/platform/backend/core/lib/providers/agent_serving.test.ts @@ -244,8 +244,10 @@ describe('shipped Sol 6.1 serving', () => { }); }); + // Listed, but not on the harness's wire: the refusal says so and names the + // harness that can run it, instead of reporting the model as missing. it.each([undefined, 'openai'])( - 'refuses a managed chat-wire harness with provider pin %s', + 'refuses a managed chat-wire harness with provider pin %s, naming the Responses API', async (modelProvider) => { await shippedOpenAi(); credentials = { openai: DIRECT }; @@ -256,7 +258,9 @@ describe('shipped Sol 6.1 serving', () => { modelProvider, harness: 'opencode', }), - ).rejects.toThrow(/cannot serve|no configured provider serves/); + ).rejects.toThrow( + 'model "gpt-6.1-sol" takes tools only through the Responses API, which the "opencode" harness does not speak — run the agent on "codex", or pick another model', + ); }, ); }); diff --git a/services/platform/backend/core/lib/providers/agent_serving.ts b/services/platform/backend/core/lib/providers/agent_serving.ts index cfdd05b761..fd58fa36cc 100644 --- a/services/platform/backend/core/lib/providers/agent_serving.ts +++ b/services/platform/backend/core/lib/providers/agent_serving.ts @@ -255,9 +255,37 @@ function findChatModel( export interface DirectServingWalk { target: { providerSlug: string; modelId: string } | null; unreachable: string[]; + /** Connectors whose catalog lists the model with tools on the Responses + * API alone, which the turn's wire cannot carry. */ + wireRefused: string[]; rows: Map; } +/** The managed harnesses that speak the Responses API to the gateway — the + * ones a model whose tools need that API can run on. */ +function responsesHarnesses(): string[] { + return loadHarnesses() + .filter( + (harness) => + harness.credentialPolicy.managed && + harnessToolCallingWire(harness) === 'openai-responses', + ) + .map((harness) => harness.slug); +} + +/** Why a turn on a wire that cannot carry a Responses-only model's tools + * refuses it, naming the harnesses that could run it. */ +export function responsesToolsRefusal(model: string, harness?: string): string { + const speaker = + harness === undefined ? "this agent's harness" : `the "${harness}" harness`; + const capable = responsesHarnesses(); + const way = + capable.length > 0 + ? `run the agent on ${capable.map((slug) => `"${slug}"`).join(', ')}, or pick another model` + : 'pick another model'; + return `model "${model}" takes tools only through the Responses API, which ${speaker} does not speak — ${way}`; +} + /** * The direct-credential connector walk (the llm node's, the legacy task * walk's, and the agent walk's first pass — ONE implementation so they can @@ -277,6 +305,7 @@ export async function walkDirectServing( toolCallingWire?: HarnessGatewayWire, ): Promise { const unreachable: string[] = []; + const wireRefused: string[] = []; const rows = new Map(); for (const connector of connectors) { const row: unknown = await ctx.runQuery( @@ -301,19 +330,24 @@ export async function walkDirectServing( continue; } const entry = findChatModel(catalog, modelId); + if (entry === undefined) continue; if ( - entry !== undefined && - (toolCallingWire === undefined || - supportsToolCallingWire(entry, toolCallingWire)) + toolCallingWire !== undefined && + !supportsToolCallingWire(entry, toolCallingWire) ) { - return { - target: { providerSlug: connector.name, modelId: entry.id }, - unreachable, - rows, - }; + // Listed, but not on a wire this turn speaks: say so if nothing else + // serves it, rather than reporting the model as missing. + wireRefused.push(connector.name); + continue; } + return { + target: { providerSlug: connector.name, modelId: entry.id }, + unreachable, + wireRefused, + rows, + }; } - return { target: null, unreachable, rows }; + return { target: null, unreachable, wireRefused, rows }; } /** @@ -421,6 +455,9 @@ export async function resolvePinnedAgentServing( : {}), }; } + if (walk.wireRefused.length > 0) { + throw new Error(responsesToolsRefusal(args.model, args.harness)); + } const detail = walk.unreachable.length > 0 ? ` (the catalog for ${walk.unreachable.map((name) => `"${name}"`).join(', ')} was unreachable)` @@ -616,6 +653,11 @@ export async function resolveWorkflowAgentServing( refusals.length > 0 ? `; subscription credentials that could not serve it: ${refusals.join('; ')}` : ''; + if (direct.wireRefused.length > 0) { + throw new Error( + `${responsesToolsRefusal(args.model, args.harness)}${unreachableDetail}${refusalDetail}`, + ); + } throw new Error( `no configured provider serves model "${args.model}" for this agent turn — the model must be listed in a connected provider's catalog and permitted by its credential: a direct api-key/env credential, or a subscription credential whose forced harness is the turn's ("${args.harness}")${unreachableDetail}${refusalDetail}`, ); diff --git a/services/platform/backend/core/lib/providers/chat_catalog.test.ts b/services/platform/backend/core/lib/providers/chat_catalog.test.ts index f1405be1b7..12ee2078bb 100644 --- a/services/platform/backend/core/lib/providers/chat_catalog.test.ts +++ b/services/platform/backend/core/lib/providers/chat_catalog.test.ts @@ -53,7 +53,7 @@ beforeEach(() => { }); describe('walkChatCatalog — model allowlist', () => { - it('offers Responses-only tools through the subscription without enabling native chat or Auto', async () => { + it('offers a Responses-only model on every credential: direct chat calls it on the Responses API', async () => { resolveProvidersMock.mockResolvedValue([ providerDefinitionSchema.parse({ ...OPENAI, @@ -79,13 +79,34 @@ describe('walkChatCatalog — model allowlist', () => { expect( hits.map((hit) => [hit.credential.authMethod, hit.entry.id]), ).toEqual([ + ['api-key', 'gpt-6.1-sol'], ['api-key', 'gpt-5.6-sol'], + ['env', 'gpt-6.1-sol'], ['env', 'gpt-5.6-sol'], ['subscription-broker', 'gpt-6.1-sol'], ['subscription-broker', 'gpt-5.6-sol'], ]); }); + it('skips a Responses-only entry on an Anthropic-format connector, which has no wire for its tools', async () => { + resolveProvidersMock.mockResolvedValue([ + providerDefinitionSchema.parse({ + ...OPENAI, + name: 'messages-only', + displayName: 'Messages only', + apiFormat: 'anthropic', + }), + ]); + catalogMock.mockResolvedValue([ + { ...entry('responses-only'), toolCallingApi: 'responses' }, + entry('plain'), + ]); + const hits = await walkChatCatalog(ctx, ORG, [ + { providerSlug: 'messages-only', authMethod: 'api-key' }, + ]); + expect(hits.map((hit) => hit.entry.id)).toEqual(['plain']); + }); + it('offers every catalog entry when the credential has no allowlist', async () => { catalogMock.mockResolvedValue([entry('gpt-5'), entry('gpt-4o-mini')]); diff --git a/services/platform/backend/core/lib/providers/chat_catalog.ts b/services/platform/backend/core/lib/providers/chat_catalog.ts index cd51db6f25..bc2b074f69 100644 --- a/services/platform/backend/core/lib/providers/chat_catalog.ts +++ b/services/platform/backend/core/lib/providers/chat_catalog.ts @@ -24,7 +24,6 @@ import type { ModelCatalogEntry } from '@tale/shared/schemas/providers'; import { modelAllowlistPermits } from '@tale/shared/utils/model-ref'; -import { supportsToolCallingWire } from '../../../../lib/shared/providers/resolve_execution'; import type { ActionCtx } from '../ctx'; import { credentialAuthFor } from './credential_auth'; import { resolveProvidersForOrgId } from './org_providers'; @@ -109,14 +108,13 @@ export async function walkChatCatalog( // exactly as it does there, so the picker never disagrees with a turn. for (const entry of catalog) { if (!modelAllowlistPermits(credential.modelAllowlist, entry.id)) continue; - // This shared picker/Auto surface offers direct chat or a subscription - // harness. Direct chat always carries tools over Chat Completions; - // adding a Responses-only model must not turn those calls into 400s. - // A pinned managed Codex agent resolves separately against its wire. + // Direct chat calls a model whose tools need the Responses API on that + // API — an OpenAI surface, so an Anthropic-format connector has no + // wire for one and must not offer it. A pinned managed agent resolves + // separately against its harness's wire. if ( - (credential.authMethod === 'api-key' || - credential.authMethod === 'env') && - !supportsToolCallingWire(entry, 'openai-chat') + entry.toolCallingApi === 'responses' && + connector.apiFormat !== 'openai' ) continue; hits.push({ connector, credential, credentialAuth, entry }); diff --git a/services/platform/backend/core/lib/providers/harness_status.test.ts b/services/platform/backend/core/lib/providers/harness_status.test.ts index edb4da5fcf..fa6d6f6d0d 100644 --- a/services/platform/backend/core/lib/providers/harness_status.test.ts +++ b/services/platform/backend/core/lib/providers/harness_status.test.ts @@ -52,6 +52,30 @@ describe('deriveHarnessStatus — against the real shipped harness facts', () => }); }); + it('counts a Responses-only model only for a harness that speaks the Responses API', () => { + const rows = deriveHarnessStatus({ + harnesses: HARNESSES, + directModels: [ + { id: 'gpt-6.1-sol', toolCallingApi: 'responses' }, + ...DIRECT, + ], + subscriptions: [], + }); + + // Codex speaks Responses: the model counts, and leads as the default. + expect(entryOf(rows, 'codex').managed).toEqual({ + available: true, + modelCount: 3, + defaultModelId: 'gpt-6.1-sol', + }); + // Claude Code does not: it neither counts the model nor falls back to it. + expect(entryOf(rows, 'claude-code').managed).toEqual({ + available: true, + modelCount: 2, + defaultModelId: 'deepseek/deepseek-v3.2', + }); + }); + it('omits byo-only harnesses (cursor) from the status list', () => { const rows = deriveHarnessStatus({ harnesses: HARNESSES, diff --git a/services/platform/backend/core/lib/providers/harness_status.ts b/services/platform/backend/core/lib/providers/harness_status.ts index 2285863df6..15f72c5f77 100644 --- a/services/platform/backend/core/lib/providers/harness_status.ts +++ b/services/platform/backend/core/lib/providers/harness_status.ts @@ -28,7 +28,9 @@ import type { import { buildHarnessTable, + harnessToolCallingWire, resolveExecution, + supportsToolCallingWire, type CredentialAuth, } from '../../../../lib/shared/providers/resolve_execution'; @@ -87,24 +89,30 @@ function neutralModelEntry(id: string): ModelCatalogEntry { export function deriveHarnessStatus(inputs: { harnesses: readonly HarnessDefinition[]; /** Direct-served composer models, in the order the picker lists them — - * the first is the kick's fallback default. */ - directModels: readonly { id: string }[]; + * the first a harness can run is the kick's fallback default. A model + * whose tools need the Responses API counts only for a harness that + * speaks it. */ + directModels: readonly { id: string; toolCallingApi?: 'responses' }[]; subscriptions: readonly SubscriptionCredentialFact[]; }): HarnessStatusEntry[] { const table = buildHarnessTable(inputs.harnesses); - const firstDirect = inputs.directModels[0]; - const probe = neutralModelEntry(firstDirect?.id ?? 'none'); + const probe = neutralModelEntry(inputs.directModels[0]?.id ?? 'none'); return [...inputs.harnesses] .filter((harness) => harness.credentialPolicy.managed) .sort((a, b) => a.displayName.localeCompare(b.displayName)) .map((harness) => { + const wire = harnessToolCallingWire(harness); + const pool = inputs.directModels.filter((model) => + supportsToolCallingWire(model, wire), + ); + const firstDirect = pool[0]; const managed: HarnessStatusEntry['managed'] = firstDirect === undefined ? { available: false, reason: 'no-direct-credential' } : { available: true, - modelCount: inputs.directModels.length, + modelCount: pool.length, defaultModelId: firstDirect.id, }; diff --git a/services/platform/backend/core/lib/providers/load_system_config.test.ts b/services/platform/backend/core/lib/providers/load_system_config.test.ts index dcbe92c49f..db85dda816 100644 --- a/services/platform/backend/core/lib/providers/load_system_config.test.ts +++ b/services/platform/backend/core/lib/providers/load_system_config.test.ts @@ -153,6 +153,79 @@ describe('shipped static model catalogs', () => { expect(model?.reasoning?.toolsRequireOff).toBeUndefined(); }); + // The vendor's latest-model guide: Astra, like Sol 6.1, takes tools only + // on Responses and cannot switch reasoning off; Sol and Luna take tools on + // Chat Completions only with reasoning_effort none. + it('ships the GPT-6 family with the tool API and reasoning switch the vendor documents', () => { + const openai = loadStaticCatalogs().get('openai') ?? []; + const byId = new Map(openai.map((entry) => [entry.id, entry] as const)); + const family = { + tags: ['chat'], + supportsTools: true, + supportsVision: true, + contextWindow: 1_050_000, + maxOutputTokens: 128_000, + }; + expect(byId.get('gpt-6-astra')).toEqual({ + id: 'gpt-6-astra', + provider: 'openai', + ...family, + toolCallingApi: 'responses', + reasoning: { knob: 'effort' }, + pricing: { + inputCentsPerMillion: 1000, + outputCentsPerMillion: 5000, + cacheReadCentsPerMillion: 100, + cacheWriteCentsPerMillion: 1250, + }, + }); + expect(byId.get('gpt-6-sol')).toEqual({ + id: 'gpt-6-sol', + provider: 'openai', + ...family, + reasoning: { knob: 'effort', off: 'none', toolsRequireOff: true }, + pricing: { + inputCentsPerMillion: 200, + outputCentsPerMillion: 1000, + cacheReadCentsPerMillion: 20, + cacheWriteCentsPerMillion: 250, + }, + }); + expect(byId.get('gpt-6-luna')).toEqual({ + id: 'gpt-6-luna', + provider: 'openai', + ...family, + reasoning: { knob: 'effort', off: 'none', toolsRequireOff: true }, + pricing: { + inputCentsPerMillion: 10, + outputCentsPerMillion: 50, + cacheReadCentsPerMillion: 1, + cacheWriteCentsPerMillion: 12.5, + }, + }); + }); + + // The Responses API is an OpenAI surface: direct chat calls a model that + // declares it at `/responses`, which an Anthropic-format + // connector does not have — the chat walk would hide such an entry. + it('declares the Responses tool API only on an OpenAI-format connector', () => { + const formatBySlug = new Map( + loadProviderDefinitions().map((p) => [p.name, p.apiFormat] as const), + ); + const misplaced: string[] = []; + for (const [provider, entries] of loadStaticCatalogs()) { + for (const entry of entries) { + if ( + entry.toolCallingApi === 'responses' && + formatBySlug.get(provider) !== 'openai' + ) { + misplaced.push(`${provider}/${entry.id}`); + } + } + } + expect(misplaced).toEqual([]); + }); + it('every catalog entry validates and carries its file provider', () => { const catalogs = loadStaticCatalogs(); expect(catalogs.size).toBeGreaterThan(0); diff --git a/services/platform/backend/domains/chat/composer.ts b/services/platform/backend/domains/chat/composer.ts index bb89edc393..8d2f370b58 100644 --- a/services/platform/backend/domains/chat/composer.ts +++ b/services/platform/backend/domains/chat/composer.ts @@ -1,6 +1,8 @@ +import type { HarnessGatewayWire } from '@tale/shared/schemas/providers'; import type { SkillOrigin } from '@tale/shared/schemas/skills'; import type { Sql } from 'postgres'; +import { harnessToolCallingWire } from '../../../lib/shared/providers/resolve_execution.ts'; import { collectComposerOptions, type ComposerModelOption, @@ -193,12 +195,22 @@ export async function listGovernedChatModels( return (await walkGovernedChatModels(sql, args)).models; } +/** One harness the managed lane can run, as the agent pickers list it. */ +export interface ComposerHarnessRow { + harness: string; + label: string; + iconUrl?: string; + /** The wire the harness speaks to the gateway (its declaration, else + * derived). */ + toolCallingWire: HarnessGatewayWire; +} + export async function listComposerModels( sql: Sql, args: { organizationId: string; userId: string }, ): Promise<{ models: ComposerModelOption[]; - harnesses: Array<{ harness: string; label: string; iconUrl?: string }>; + harnesses: ComposerHarnessRow[]; voice: { ttsAvailable: boolean; transcriptionAvailable: boolean; @@ -215,14 +227,17 @@ export async function listComposerModels( args.organizationId, ); - // Only harnesses the managed lane can actually run. + // Only harnesses the managed lane can actually run, each with the wire it + // speaks to the gateway: a model whose tools need the Responses API is + // offered only to a harness that speaks it. const harnesses = loadHarnesses() .filter((harness) => harness.credentialPolicy.managed) .map((harness) => { const iconUrl = readSystemEntryIcon('harnesses', harness.slug); - const row: { harness: string; label: string; iconUrl?: string } = { + const row: ComposerHarnessRow = { harness: harness.slug, label: harness.displayName, + toolCallingWire: harnessToolCallingWire(harness), }; if (iconUrl !== undefined) row.iconUrl = iconUrl; return row; diff --git a/services/platform/backend/domains/model_api/models.test.ts b/services/platform/backend/domains/model_api/models.test.ts index 2a8e55338f..211551e409 100644 --- a/services/platform/backend/domains/model_api/models.test.ts +++ b/services/platform/backend/domains/model_api/models.test.ts @@ -115,6 +115,24 @@ describe('listModelApiModels', () => { }, ]); }); + + it('leaves out a model whose tools work only on the Responses API, which these endpoints do not relay', async () => { + providers.resolveProvidersForOrg.mockReturnValue([{ name: 'openai' }]); + composer.listGovernedChatModels.mockResolvedValue([ + option('openai', 'gpt-6.1-sol', 'api-key', { + toolCallingApi: 'responses', + }), + option('openai', 'gpt-6-luna', 'api-key'), + ]); + + const models = await listModelApiModels({} as never, { + organizationId: 'org-1', + orgSlug: 'acme', + userId: 'user-1', + }); + + expect(models.map((model) => model.id)).toEqual(['openai/gpt-6-luna']); + }); }); describe('model ids', () => { diff --git a/services/platform/backend/domains/model_api/models.ts b/services/platform/backend/domains/model_api/models.ts index 1bf7873f80..cef4785c76 100644 --- a/services/platform/backend/domains/model_api/models.ts +++ b/services/platform/backend/domains/model_api/models.ts @@ -110,6 +110,10 @@ export async function listModelApiModels( const models: ModelApiModel[] = []; for (const option of options) { if (!servedByDirectCredential(option)) continue; + // These endpoints relay Chat Completions and Anthropic Messages; a model + // whose tools work only on the Responses API would answer an editor's + // tool call with a 400. + if (option.toolCallingApi === 'responses') continue; const connector = connectors.get(option.providerSlug); if (connector === undefined || !gatewayServable(connector)) continue; models.push(toModel(option, connector)); diff --git a/services/platform/backend/domains/projects/agent-equipment.test.ts b/services/platform/backend/domains/projects/agent-equipment.test.ts index 70e0e6df44..a4857197d7 100644 --- a/services/platform/backend/domains/projects/agent-equipment.test.ts +++ b/services/platform/backend/domains/projects/agent-equipment.test.ts @@ -123,6 +123,61 @@ describe('agentModelRefusal', () => { expect(refusal).toMatchObject({ code: 'PROJECT_AGENT_MODEL_INVALID' }); expect(refusal?.message).toContain('claude-code'); }); + + it('holds a Responses-only model to a harness that speaks the Responses API', async () => { + composer.listComposerModels.mockResolvedValue({ + models: [ + { + id: 'gpt-6.1-sol', + label: 'GPT 6.1 Sol', + providerSlug: 'openai', + providerLabel: 'OpenAI', + credential: { authMethod: 'api-key' }, + tools: true, + toolCallingApi: 'responses', + contextWindow: 1_050_000, + tags: ['chat'], + }, + ], + harnesses: [ + { + harness: 'claude-code', + label: 'Claude Code', + toolCallingWire: 'anthropic', + }, + { + harness: 'codex', + label: 'Codex', + toolCallingWire: 'openai-responses', + }, + { + harness: 'opencode', + label: 'OpenCode', + toolCallingWire: 'openai-chat', + }, + ], + voice: { ttsAvailable: false, transcriptionAvailable: false }, + }); + await expect( + agentModelRefusal(sql, { + ...org, + harness: 'codex', + model: 'gpt-6.1-sol', + modelProvider: 'openai', + }), + ).resolves.toBeNull(); + const refusal = await agentModelRefusal(sql, { + ...org, + harness: 'opencode', + model: 'gpt-6.1-sol', + modelProvider: 'openai', + }); + expect(refusal).toEqual({ + code: 'PROJECT_AGENT_MODEL_INVALID', + message: + 'Model "gpt-6.1-sol" takes tools only through the Responses API, which the opencode harness does not speak. Run it on codex, or pick another model. GET /api/v1/models lists the models and providers this organization can call.', + }); + }); }); describe('agentEquipmentRefusal', () => { diff --git a/services/platform/backend/domains/projects/agent-equipment.ts b/services/platform/backend/domains/projects/agent-equipment.ts index 53ff6e51a5..98a0c5aed6 100644 --- a/services/platform/backend/domains/projects/agent-equipment.ts +++ b/services/platform/backend/domains/projects/agent-equipment.ts @@ -39,7 +39,9 @@ export const AGENT_TOOL_GRANT_NAMES: readonly string[] = AGENT_TOOL_CATALOG.map( * Whether (`model`, `modelProvider`) is a pair this organization can call, * from the composer's servable listing (governance model access applied for * the configuring user). A subscription-served entry runs only in the - * harness its credential is bound to, so it counts only for that harness. + * harness its credential is bound to, so it counts only for that harness; + * an entry whose tools work only on the Responses API counts only for a + * harness that speaks it. */ export async function agentModelRefusal( sql: Sql, @@ -51,7 +53,7 @@ export async function agentModelRefusal( modelProvider?: string; }, ): Promise { - const { models } = await listComposerModels(sql, { + const { models, harnesses } = await listComposerModels(sql, { organizationId: args.organizationId, userId: args.userId, }); @@ -81,30 +83,45 @@ export async function agentModelRefusal( : `Provider "${args.modelProvider}" does not serve model "${args.model}". ${hint}`, }; } - const servesHarness = candidates.some((option) => { + const harnessFits = candidates.filter((option) => { const credential = option.credential; return credential.authMethod === 'api-key' || credential.authMethod === 'env' ? true : credential.constraints.harness === args.harness; }); - if (!servesHarness) { - const bound = [ - ...new Set( - candidates.flatMap((option) => - option.credential.authMethod === 'api-key' || - option.credential.authMethod === 'env' - ? [] - : [option.credential.constraints.harness], - ), - ), - ]; + if (harnessFits.length > 0) { + const wire = harnesses.find( + (row) => row.harness === args.harness, + )?.toolCallingWire; + if ( + wire === 'openai-responses' || + harnessFits.some((option) => option.toolCallingApi !== 'responses') + ) { + return null; + } + const capable = harnesses + .filter((row) => row.toolCallingWire === 'openai-responses') + .map((row) => row.harness); return { code: 'PROJECT_AGENT_MODEL_INVALID', - message: `Model "${args.model}" is served by a subscription bound to the ${bound.join(', ')} harness, not ${args.harness}. ${hint}`, + message: `Model "${args.model}" takes tools only through the Responses API, which the ${args.harness} harness does not speak. Run it on ${capable.length > 0 ? capable.join(', ') : 'a harness that speaks it'}, or pick another model. ${hint}`, }; } - return null; + const bound = [ + ...new Set( + candidates.flatMap((option) => + option.credential.authMethod === 'api-key' || + option.credential.authMethod === 'env' + ? [] + : [option.credential.constraints.harness], + ), + ), + ]; + return { + code: 'PROJECT_AGENT_MODEL_INVALID', + message: `Model "${args.model}" is served by a subscription bound to the ${bound.join(', ')} harness, not ${args.harness}. ${hint}`, + }; } /** diff --git a/services/platform/backend/domains/projects/standard-agent.test.ts b/services/platform/backend/domains/projects/standard-agent.test.ts index 6b551f6edd..aeeb8ee7b1 100644 --- a/services/platform/backend/domains/projects/standard-agent.test.ts +++ b/services/platform/backend/domains/projects/standard-agent.test.ts @@ -193,6 +193,57 @@ describe('chooseStandardAgentServing — what runs the standard agent', () => { ).toMatchObject({ ok: true, harness: 'codex', source: 'pinned' }); }); + it('runs a Responses-only model only on a runtime that speaks the Responses API', () => { + const responsesOnly = option('gpt-6.1-sol', 'openai', { + toolCallingApi: 'responses', + pricing: { inputCentsPerMillion: 1, outputCentsPerMillion: 1 }, + }); + const speakers = new Set(['codex']); + // Pinned with no runtime: the default runtime cannot carry its tools, + // so the first one that can runs it. + expect( + chooseStandardAgentServing( + [responsesOnly], + { providerSlug: 'openai', modelId: 'gpt-6.1-sol' }, + ELIGIBLE, + speakers, + ), + ).toEqual({ + ok: true, + harness: 'codex', + model: 'gpt-6.1-sol', + modelProvider: 'openai', + source: 'pinned', + }); + // Pinned onto a runtime that cannot carry it: refused, never swapped. + expect( + chooseStandardAgentServing( + [responsesOnly], + { harness: 'opencode', providerSlug: 'openai', modelId: 'gpt-6.1-sol' }, + ELIGIBLE, + speakers, + ), + ).toEqual({ ok: false, refusal: 'pin-unavailable' }); + // Automatic on the default runtime: the cheaper Responses-only model is + // passed over for one the default runtime can run. + expect( + chooseStandardAgentServing( + [responsesOnly, option('modest', 'acme')], + {}, + ELIGIBLE, + speakers, + ), + ).toMatchObject({ ok: true, harness: 'claude-code', model: 'modest' }); + // Without any runtime that speaks it, nothing runs it. + expect( + chooseStandardAgentServing( + [responsesOnly], + { providerSlug: 'openai', modelId: 'gpt-6.1-sol' }, + ELIGIBLE, + ), + ).toEqual({ ok: false, refusal: 'pin-unavailable' }); + }); + it('refuses a pin it cannot run, and never swaps in another model', () => { expect( chooseStandardAgentServing( diff --git a/services/platform/backend/domains/projects/standard-agent.ts b/services/platform/backend/domains/projects/standard-agent.ts index 67c121fc98..bb9a006298 100644 --- a/services/platform/backend/domains/projects/standard-agent.ts +++ b/services/platform/backend/domains/projects/standard-agent.ts @@ -7,6 +7,7 @@ import { eligibleChatCandidates, } from '../../../lib/chat/model-choice.ts'; import { DOCUMENT_SKILL_SLUGS } from '../../../lib/shared/document-skills.ts'; +import { harnessToolCallingWire } from '../../../lib/shared/providers/resolve_execution.ts'; import { getOrganizationDefaultLocale } from '../../../lib/shared/utils/get-organization-default-locale.ts'; import type { ComposerModelOption } from '../../core/chat/composer.ts'; import { catalogString } from '../../core/i18n/catalog.ts'; @@ -129,12 +130,15 @@ function boundHarness(option: ComposerModelOption): string | undefined { /** * What runs the standard agent, from the models a person may use. Pure: the - * listing and the eligible runtimes in, the choice or the refusal out. + * listing and the eligible runtimes in, the choice or the refusal out. A + * model whose tools work only on the Responses API runs only on a runtime in + * `responsesHarnesses`, the ones that speak it. */ export function chooseStandardAgentServing( options: readonly ComposerModelOption[], config: Pick, eligibleHarnesses: readonly string[], + responsesHarnesses: ReadonlySet = new Set(), ): StandardAgentServing { if ( config.harness !== undefined && @@ -149,7 +153,10 @@ export function chooseStandardAgentServing( : eligibleHarnesses[0]; const runnable = (option: ComposerModelOption, harness: string) => { const bound = boundHarness(option); - return bound === undefined || bound === harness; + return ( + (bound === undefined || bound === harness) && + (option.toolCallingApi !== 'responses' || responsesHarnesses.has(harness)) + ); }; if (config.providerSlug !== undefined && config.modelId !== undefined) { @@ -158,10 +165,22 @@ export function chooseStandardAgentServing( option.providerSlug === config.providerSlug && option.id === config.modelId, ); - const direct = pinned.some((option) => boundHarness(option) === undefined); + const direct = pinned.filter( + (option) => boundHarness(option) === undefined, + ); + // A directly served pin runs on the default runtime, unless its tools + // need the Responses API the default does not speak: then on the first + // runtime that does. + const directHarness = + defaultHarness !== undefined && + direct.some((option) => runnable(option, defaultHarness)) + ? defaultHarness + : eligibleHarnesses.find((harness) => responsesHarnesses.has(harness)); const harness = config.harness ?? - (direct ? defaultHarness : pinned.map(boundHarness).find(Boolean)); + (direct.length > 0 + ? directHarness + : pinned.map(boundHarness).find(Boolean)); if ( harness === undefined || !eligibleHarnesses.includes(harness) || @@ -186,15 +205,24 @@ export function chooseStandardAgentServing( const pinnedHarness = config.harness; pool = options.filter((option) => runnable(option, pinnedHarness)); } else { - const direct = options.filter( - (option) => boundHarness(option) === undefined, - ); + const direct = + defaultHarness === undefined + ? [] + : options.filter( + (option) => + boundHarness(option) === undefined && + runnable(option, defaultHarness), + ); pool = - direct.length > 0 && defaultHarness !== undefined + direct.length > 0 ? direct : options.filter((option) => { const bound = boundHarness(option); - return bound !== undefined && eligibleHarnesses.includes(bound); + return ( + bound !== undefined && + eligibleHarnesses.includes(bound) && + runnable(option, bound) + ); }); } const screened = eligibleChatCandidates( @@ -249,7 +277,19 @@ async function resolveStandardAgentServing( organizationId: args.organizationId, userId: args.userId, }); - return chooseStandardAgentServing(options, args.config, eligible); + const responsesHarnesses = new Set( + loadHarnesses() + .filter( + (harness) => harnessToolCallingWire(harness) === 'openai-responses', + ) + .map((harness) => harness.slug), + ); + return chooseStandardAgentServing( + options, + args.config, + eligible, + responsesHarnesses, + ); } /** Whether this person can hand work to the standard agent now, and what diff --git a/services/platform/backend/domains/providers/routes.ts b/services/platform/backend/domains/providers/routes.ts index 0ed73ea891..09af0d2717 100644 --- a/services/platform/backend/domains/providers/routes.ts +++ b/services/platform/backend/domains/providers/routes.ts @@ -323,14 +323,25 @@ export function createProviderSettingRoutes(deps: { const candidate = model as { id?: unknown; credential?: { authMethod?: unknown }; + toolCallingApi?: unknown; }; - return typeof candidate.id === 'string' && - (candidate.credential?.authMethod === 'api-key' || - candidate.credential?.authMethod === 'env') - ? { id: candidate.id } - : null; + if ( + typeof candidate.id !== 'string' || + (candidate.credential?.authMethod !== 'api-key' && + candidate.credential?.authMethod !== 'env') + ) { + return null; + } + // A model whose tools need the Responses API counts only for a + // harness that speaks it. + return candidate.toolCallingApi === 'responses' + ? { id: candidate.id, toolCallingApi: 'responses' as const } + : { id: candidate.id }; }) - .filter((entry): entry is { id: string } => entry !== null); + .filter( + (entry): entry is { id: string; toolCallingApi?: 'responses' } => + entry !== null, + ); const credentials = await listCredentials(deps.sql, { organizationId, userId: c.get('sessionBundle').user.id, diff --git a/services/platform/lib/chat/turn.test.ts b/services/platform/lib/chat/turn.test.ts index 9995c68e97..4fc8430097 100644 --- a/services/platform/lib/chat/turn.test.ts +++ b/services/platform/lib/chat/turn.test.ts @@ -888,28 +888,26 @@ describe('runTurn — input guardrails', () => { }); describe('runTurn — execution resolution', () => { - it('refuses a Responses-only tool model before native chat calls the provider', async () => { - const model = vi.fn(); - const d = deps({ model: model as unknown as ModelCall }); + it('runs a Responses-only tool model directly and hands its tool API to the model call', async () => { + const seen: ModelCallRequest[] = []; + const recorder: ModelCall = async function* recorder(call) { + seen.push(call); + yield { text: 'ok' }; + }; const outcome = await runTurn( request({ model: { ...MODEL, toolCallingApi: 'responses' }, executionMode: 'direct', }), - d.deps, + deps({ model: recorder }).deps, ); - expect(outcome).toMatchObject({ - status: 'refused', - step: 'resolve-execution', - reason: expect.stringContaining('Responses'), - }); - expect(model).not.toHaveBeenCalled(); - expect(d.store.ops).toEqual(['appendMessage', 'appendMessage']); - expect(d.store.appended.at(-1)).toMatchObject({ - role: 'assistant', - blockedReason: expect.stringContaining('Responses'), - }); - expect(d.usage).toEqual([]); + expect(outcome).toMatchObject({ status: 'completed' }); + expect(seen[0]?.execution).toEqual({ mode: 'direct' }); + expect(seen[0]?.toolCallingApi).toBe('responses'); + + // A model that declares no tool API leaves the field off the call. + await runTurn(request(), deps({ model: recorder }).deps); + expect(seen[1]).not.toHaveProperty('toolCallingApi'); }); it('refuses before the model call when the credential forbids the mode', async () => { diff --git a/services/platform/lib/chat/turn.ts b/services/platform/lib/chat/turn.ts index d2a8c17fc0..fe7fd76636 100644 --- a/services/platform/lib/chat/turn.ts +++ b/services/platform/lib/chat/turn.ts @@ -181,6 +181,10 @@ export interface ModelCallRequest { /** The model can SEE images (catalog `vision` tag): the host inlines image * attachments as content blocks. Without it they read as text surfaces. */ readonly vision?: boolean; + /** The model's function tools work only on the Responses API (catalog + * `toolCallingApi`): a direct host speaks that API for the call instead of + * Chat Completions. */ + readonly toolCallingApi?: ModelCatalogEntry['toolCallingApi']; readonly signal?: AbortSignal; /** The host calls this once the provider ACCEPTED the request: it answered * with a success status and its stream opened. From then on the round has @@ -813,8 +817,11 @@ async function streamWithOutputGuardrails( sampling, // The catalog's own capability flag decides whether image attachments // are inlined on the wire — the pipeline resolves it here so the host - // never re-derives capability from a model id. + // never re-derives capability from a model id. The tool API likewise. vision: request.model.supportsVision, + ...(request.model.toolCallingApi !== undefined + ? { toolCallingApi: request.model.toolCallingApi } + : {}), signal: round.signal ?? request.signal, onAccepted: () => { observed.accepted = true; diff --git a/services/platform/lib/shared/providers/resolve_execution.test.ts b/services/platform/lib/shared/providers/resolve_execution.test.ts index 067ead0c45..aa66f4b05b 100644 --- a/services/platform/lib/shared/providers/resolve_execution.test.ts +++ b/services/platform/lib/shared/providers/resolve_execution.test.ts @@ -95,6 +95,21 @@ describe('resolveExecution — direct mode', () => { expect(result.reason).toContain('claude-code'); expect(result.reason).toContain('sandbox'); expect(result.reason).toContain(MODEL.id); + // Why, not only what: the vendor's terms bind the token to its runtime. + expect(result.reason).toContain( + 'the vendor permits subscription tokens only in its own agent runtime', + ); + } + }); + + // Native chat calls such a model on the Responses API itself, so a direct + // credential runs it directly; the harness check stays the sandbox's. + it('runs a Responses-only model directly on an api-key or env credential', () => { + const model = { ...MODEL, toolCallingApi: 'responses' as const }; + for (const credential of [API_KEY, ENV]) { + expect( + resolveExecution({ model, credential, mode: 'direct' }, HARNESSES), + ).toEqual({ mode: 'direct' }); } }); }); diff --git a/services/platform/lib/shared/providers/resolve_execution.ts b/services/platform/lib/shared/providers/resolve_execution.ts index 38625a1479..54667fc794 100644 --- a/services/platform/lib/shared/providers/resolve_execution.ts +++ b/services/platform/lib/shared/providers/resolve_execution.ts @@ -8,25 +8,28 @@ * * - `api-key` / `env` — the platform holds the secret and can mint a * session-scoped gateway virtual key, so BOTH modes are allowed: - * `direct` runs the platform chat loop; `sandbox` runs the requested - * harness in managed posture (gateway VK). The harness must accept - * managed credentials (`credentialPolicy.managed` in its yml) — Cursor - * does not (its CLI cannot route through the gateway), so it refuses. + * `direct` runs the platform chat loop (on the Responses API for a model + * whose tools need it); `sandbox` runs the requested harness in managed + * posture (gateway VK). The harness must accept managed credentials + * (`credentialPolicy.managed` in its yml) — Cursor does not (its CLI + * cannot route through the gateway), so it refuses. * - `subscription-key` / `subscription-broker` — a vendor subscription * (a static coding-plan key, an OAuth blob, or a brokered rotating - * token) is only usable by the vendor's sanctioned CLI inside a sandbox, - * so `direct` is REFUSED with a reason naming the forced harness, and - * `sandbox` is REQUIRED to run that exact harness (requesting another - * refuses). The secret is injected into the session environment, i.e. - * bring-your-own posture — the forced harness must accept byo - * credentials (`credentialPolicy.byo`); OpenCode is managed-only and - * refuses. + * token) is only usable by the vendor's sanctioned CLI inside a sandbox: + * the vendors permit those tokens in their own agent runtime alone, and + * Anthropic refuses them from any other client. So `direct` is REFUSED + * with a reason naming the forced harness, and `sandbox` is REQUIRED to + * run that exact harness (requesting another refuses). The secret is + * injected into the session environment, i.e. bring-your-own posture — + * the forced harness must accept byo credentials (`credentialPolicy.byo`); + * OpenCode is managed-only and refuses. * * Sandbox with no harness selected is a refusal, not a guess: the caller * owns default-harness policy and passes a concrete slug (a subscription * credential is the one case that carries its own forced harness). - * A model's explicit tool API requirement also holds: native chat uses - * Chat Completions, while a sandbox must declare the compatible wire. + * A model's explicit tool API requirement also holds in a sandbox: the + * harness must declare the compatible wire. Native chat speaks that API + * itself. * * Refusal reasons are user-facing API — actionable one-liners naming the * offending piece and the way out. @@ -82,8 +85,10 @@ export function buildHarnessTable( } /** A model may accept plain text on a wire that cannot carry its tools. - * Native chat uses Chat Completions; Codex uses Responses. Keep that - * distinction shared by the picker, the turn and agent serving. */ + * A harness speaks one wire (Codex: Responses; most others: Chat + * Completions or Anthropic), so agent serving and the sandbox arm below + * check it. Native chat needs no check: it calls such a model on the + * Responses API. */ export function supportsToolCallingWire( model: Pick, wire: HarnessGatewayWire, @@ -178,14 +183,10 @@ export function resolveExecution( case 'api-key': case 'env': { // The platform holds (or resolves) the secret and mints a session - // gateway key, so both modes are open; sandbox runs managed. + // gateway key, so both modes are open; sandbox runs managed. A direct + // turn speaks the Responses API for a model whose tools need it. switch (mode) { case 'direct': - if (!supportsToolCallingWire(model, 'openai-chat')) { - return refused( - `Model "${model.id}" requires the Responses API for tools and cannot run in direct chat. Select a Responses-capable sandbox harness.`, - ); - } return { mode: 'direct' }; case 'sandbox': { if (!selection.harness) { @@ -216,7 +217,7 @@ export function resolveExecution( switch (mode) { case 'direct': return refused( - `Model "${model.id}" is selected with a subscription credential that cannot run in direct chat — it only works in a sandbox with the "${forced}" harness. Switch to sandbox execution, or pick an api-key or env credential.`, + `Model "${model.id}" is selected with a subscription credential that cannot run in direct chat — the vendor permits subscription tokens only in its own agent runtime, so it works only in a sandbox with the "${forced}" harness. Switch to sandbox execution, or pick an api-key or env credential.`, ); case 'sandbox': { if (selection.harness !== undefined && selection.harness !== forced) { diff --git a/services/platform/messages/de-CH.yml b/services/platform/messages/de-CH.yml index 5987573900..a61ab6dce7 100644 --- a/services/platform/messages/de-CH.yml +++ b/services/platform/messages/de-CH.yml @@ -110,6 +110,15 @@ settings: embedding: toggleHelp: Ausgeschaltet bleibt jede Seite ausserhalb von Frames; die Liste unten bleibt erhalten. providers: + subscriptionScope: + description: >- + Ein Abo-Token läuft nur in der Agent-Laufzeit, die sein Anbieter + unterstützt, etwa Claude Code oder Codex, in einer Sandbox: Die + Anbieter erlauben diese Tokens nicht in anderen Anwendungen, und + Anthropic weist sie bei jedem Client ausser Claude Code ab. Im Chat + lassen sich diese Zugangsdaten nicht verwenden. Um mit diesen Modellen + zu chatten, füge für den Anbieter Zugangsdaten per API-Schlüssel oder + Umgebungsvariable hinzu. broker: maxResponseBytes: Maximale Antwortgrösse (Bytes) tables: diff --git a/services/platform/messages/de.yml b/services/platform/messages/de.yml index 26a99157e6..c5b3ee9e3e 100644 --- a/services/platform/messages/de.yml +++ b/services/platform/messages/de.yml @@ -1172,6 +1172,10 @@ chat: auto: Auto autoDescription: Tale wählt für jede Nachricht das passende Modell — abgewogen zwischen Qualität, Geschwindigkeit und Kosten. noModelsAvailable: Keine Modelle verfügbar + subscriptionsTasksOnly: + Abos von {providers} laufen nur in Aufgaben und Automatisierungen. + Um mit ihren Modellen zu chatten, füge Zugangsdaten per + API-Schlüssel oder Umgebungsvariable hinzu. viewProvider: Anbietereinstellungen anzeigen viewInfo: Modelldetails info: @@ -6391,6 +6395,9 @@ settings: catalogUnavailable: 'Modellkatalog nicht verfügbar: {error}' credential: disabled: Deaktiviert + tasksOnly: + Nur für Aufgaben und Automatisierungen — für den Chat brauchst du + einen API-Schlüssel oder eine Umgebungsvariable deleteEmbeddingWarning: >- Das Embedding-Modell der Wissenssuche verwendet diese Zugangsdaten: Nach dem Löschen stehen Dokumentindexierung und Suche für die ganze @@ -6414,7 +6421,6 @@ settings: dialog: secret: API-Schlüssel subscriptionSecret: Abo-Schlüssel - sandboxedExplainer: Läuft in der Sandbox auf dem Harness des Anbieters. envName: Umgebungsvariable envNameHelp: Name der Deployment-Variable mit dem Schlüssel — das Präfix ist @@ -6434,11 +6440,20 @@ settings: deiner Ressource; ohne sie ist kein Modell verfügbar. allowlistFreeTextPlaceholder: gpt-4o, o4-mini removeModel: '{model} entfernen' + subscriptionScope: + title: Nur für Aufgaben und Automatisierungen + description: >- + Ein Abo-Token läuft nur in der Agent-Laufzeit, die sein Anbieter + unterstützt, etwa Claude Code oder Codex, in einer Sandbox: Die + Anbieter erlauben diese Tokens nicht in anderen Anwendungen, und + Anthropic weist sie bei jedem Client außer Claude Code ab. Im Chat + lassen sich diese Zugangsdaten nicht verwenden. Um mit diesen Modellen + zu chatten, füge für den Anbieter Zugangsdaten per API-Schlüssel oder + Umgebungsvariable hinzu. broker: explainer: Ein Abo-Broker liefert wechselnde OAuth-Tokens für Claude- oder - ChatGPT-Abonnements. Damit nutzen Aufgaben- und Automatisierungsagenten - die Sandbox-Laufzeit des Anbieters. + ChatGPT-Abonnements. invalid: 'Ungültige Broker-Konfiguration: {error}' endpoint: Broker-Endpunkt httpMethod: HTTP-Methode diff --git a/services/platform/messages/en.yml b/services/platform/messages/en.yml index ba4dc1b11e..6fb922cb14 100644 --- a/services/platform/messages/en.yml +++ b/services/platform/messages/en.yml @@ -1130,6 +1130,10 @@ chat: auto: Auto autoDescription: Let Tale pick the best model for each message — balances quality, speed, and cost. noModelsAvailable: No models available + subscriptionsTasksOnly: + Subscriptions from {providers} run only in tasks and automations. + To chat with their models, add an API key or environment-variable + credential. viewProvider: View provider settings viewInfo: Model details info: @@ -6566,6 +6570,9 @@ settings: catalogUnavailable: 'Model catalog unavailable: {error}' credential: disabled: Disabled + tasksOnly: + Tasks and automations only — chat needs an API key or environment + variable deleteEmbeddingWarning: >- The knowledge embedding model uses this credential: deleting it stops document indexing and search for the whole organization. Choose @@ -6588,7 +6595,6 @@ settings: dialog: secret: API key subscriptionSecret: Subscription key - sandboxedExplainer: Runs sandboxed on its provider's harness. envName: Environment variable envNameHelp: Name of the deployment variable that holds the key — the prefix is @@ -6608,11 +6614,19 @@ settings: no model is available. allowlistFreeTextPlaceholder: gpt-4o, o4-mini removeModel: Remove {model} + subscriptionScope: + title: Tasks and automations only + description: >- + A subscription token runs only inside the agent runtime its vendor + supports, such as Claude Code or Codex, in a sandbox: vendors do not + permit these tokens in other applications, and Anthropic refuses them + from any client other than Claude Code. Chat cannot use this + credential. To chat with these models, add an API key or + environment-variable credential for the provider. broker: explainer: A subscription broker supplies rotating OAuth tokens for Claude or - ChatGPT subscriptions. Use them for task and automation agents running - in the provider's sandbox runtime. + ChatGPT subscriptions. invalid: 'Invalid broker configuration: {error}' endpoint: Broker endpoint httpMethod: HTTP method diff --git a/services/platform/messages/fr.yml b/services/platform/messages/fr.yml index 8c07a003c9..46d72fd1fb 100644 --- a/services/platform/messages/fr.yml +++ b/services/platform/messages/fr.yml @@ -1184,6 +1184,10 @@ chat: auto: Auto autoDescription: Tale choisit le meilleur modèle pour chaque message — équilibre qualité, vitesse et coût. noModelsAvailable: Aucun modèle disponible + subscriptionsTasksOnly: + Les abonnements des fournisseurs {providers} ne fonctionnent que dans + les tâches et les automatisations. Pour discuter avec leurs modèles, + ajoute des identifiants par clé API ou variable d'environnement. viewProvider: Voir les paramètres du fournisseur viewInfo: Détails du modèle info: @@ -6488,6 +6492,9 @@ settings: catalogUnavailable: 'Catalogue de modèles indisponible : {error}' credential: disabled: Désactivé + tasksOnly: + Tâches et automatisations uniquement — le chat nécessite une clé API + ou une variable d'environnement deleteEmbeddingWarning: >- Le modèle d'embedding de la recherche de connaissances utilise ces identifiants : les supprimer arrête l'indexation des documents et la @@ -6512,7 +6519,6 @@ settings: dialog: secret: Clé API subscriptionSecret: Clé d'abonnement - sandboxedExplainer: S'exécute en sandbox sur le harness de son fournisseur. envName: Variable d'environnement envNameHelp: Nom de la variable du déploiement qui contient la clé — le préfixe @@ -6533,11 +6539,20 @@ settings: ta ressource ; sans eux, aucun modèle n'est disponible. allowlistFreeTextPlaceholder: gpt-4o, o4-mini removeModel: Retirer {model} + subscriptionScope: + title: Tâches et automatisations uniquement + description: >- + Un jeton d'abonnement ne s'exécute que dans l'environnement d'agent + pris en charge par son fournisseur, comme Claude Code ou Codex, dans + une sandbox : les fournisseurs n'autorisent pas ces jetons dans + d'autres applications, et Anthropic les refuse depuis tout client + autre que Claude Code. Le chat ne peut pas utiliser ces identifiants. + Pour discuter avec ces modèles, ajoute des identifiants par clé API + ou variable d'environnement pour ce fournisseur. broker: explainer: Un courtier d'abonnement fournit des jetons OAuth renouvelés pour les - abonnements Claude ou ChatGPT. Ils servent aux agents de tâche et - d'automatisation dans l'environnement sandbox du fournisseur. + abonnements Claude ou ChatGPT. invalid: 'Configuration du courtier invalide : {error}' endpoint: Endpoint du courtier httpMethod: Méthode HTTP From 7c1aa3b84991bedc7bd726a77710346f3f47b2ff Mon Sep 17 00:00:00 2001 From: yannickmonney Date: Sat, 3 Oct 2026 22:28:05 +0200 Subject: [PATCH 2/3] docs: say where GPT-6 models and subscriptions run AI providers gains "Use subscriptions in tasks, not in chat" (why a subscription credential works only in its vendor's runtime, where the app says so, and how to chat with the same model) and "Run the GPT-6 models" (chat through an API key or environment credential, Astra and GPT-6.1 Sol on the Responses API, Codex-only in tasks). Harnesses, Models, Project agents, Chat basics and the editor guide carry the same facts, in en, de and fr. The manual layer gains CHAT-F59, CHAT-F60 and SET-F74 and the automation rows that own the rest. --- docs/de/develop/use-tale-from-your-editor.md | 2 +- docs/de/platform/admin/providers.md | 23 +++++++++++++++---- docs/de/platform/agents/harnesses.md | 4 ++-- docs/de/platform/chat/basics.md | 2 +- docs/de/platform/models.md | 3 ++- docs/de/platform/projects/project-agents.md | 2 +- docs/en/develop/use-tale-from-your-editor.md | 2 +- docs/en/platform/admin/providers.md | 23 +++++++++++++++---- docs/en/platform/agents/harnesses.md | 4 ++-- docs/en/platform/chat/basics.md | 2 +- docs/en/platform/models.md | 3 ++- docs/en/platform/projects/project-agents.md | 2 +- docs/fr/develop/use-tale-from-your-editor.md | 2 +- docs/fr/platform/admin/providers.md | 23 +++++++++++++++---- docs/fr/platform/agents/harnesses.md | 4 ++-- docs/fr/platform/chat/basics.md | 2 +- docs/fr/platform/models.md | 3 ++- docs/fr/platform/projects/project-agents.md | 2 +- .../tests/manual/reference/automation.md | 3 ++- services/platform/tests/manual/suites/chat.md | 20 +++++++++++++++- .../platform/tests/manual/suites/settings.md | 13 ++++++++++- 21 files changed, 111 insertions(+), 33 deletions(-) diff --git a/docs/de/develop/use-tale-from-your-editor.md b/docs/de/develop/use-tale-from-your-editor.md index 8be83d4745..b749ec1f79 100644 --- a/docs/de/develop/use-tale-from-your-editor.md +++ b/docs/de/develop/use-tale-from-your-editor.md @@ -70,7 +70,7 @@ Die Antwort ist eine Modellliste im OpenAI-Format: `owned_by` ist der Slug des A } ``` -Die Liste enthält die Chatmodelle deiner Organisation, die Anbieter-Zugangsdaten vom Typ **API-Schlüssel** oder **Umgebungsvariable** bereitstellen, eingeschränkt durch die erlaubten Modelle der jeweiligen Zugangsdaten und durch deinen Modellzugriff. Modelle, die über Abonnement-Zugangsdaten laufen, fehlen darin, ebenso Modelle eines Anbieters, dessen Endpunkt je Zugangsdaten-Eintrag festgelegt wird, etwa Azure. `GET /api/v1/models` nennt für jedes dieser Modelle Kontextfenster, Fähigkeiten und Preise, unter demselben `providerSlug` und derselben `id`. +Die Liste enthält die Chatmodelle deiner Organisation, die Anbieter-Zugangsdaten vom Typ **API-Schlüssel** oder **Umgebungsvariable** bereitstellen, eingeschränkt durch die erlaubten Modelle der jeweiligen Zugangsdaten und durch deinen Modellzugriff. Modelle, die über Abonnement-Zugangsdaten laufen, fehlen darin, ebenso Modelle eines Anbieters, dessen Endpunkt je Zugangsdaten-Eintrag festgelegt wird, etwa Azure, und Modelle, die Tools nur über die Responses-API von OpenAI aufrufen, etwa GPT-6.1 Sol, denn diese Endpunkte leiten sie nicht weiter. `GET /api/v1/models` nennt für jedes dieser Modelle Kontextfenster, Fähigkeiten und Preise, unter demselben `providerSlug` und derselben `id`. ### opencode auf Tale ausrichten diff --git a/docs/de/platform/admin/providers.md b/docs/de/platform/admin/providers.md index cf6ca6bd0a..0977fc1d37 100644 --- a/docs/de/platform/admin/providers.md +++ b/docs/de/platform/admin/providers.md @@ -27,14 +27,22 @@ Teste Zugangsdaten vom Typ **API-Schlüssel** oder **Umgebungsvariable** mit ein | --- | --- | --- | | **API-Schlüssel** | Der geheime Schlüssel des Anbieters | Gewöhnlicher, nutzungsabhängig abgerechneter API-Zugriff. Der gespeicherte Wert ist verschlüsselt und später nur maskiert sichtbar. | | **Umgebungsvariable** | Der Name einer Bereitstellungsvariable | Ein Betreiber verwaltet das Geheimnis außerhalb der Oberfläche. Der Name muss mit `TALE_PROVIDER_KEY_` beginnen. | -| **Abo-Schlüssel** | Ein unterstütztes Abonnement-Geheimnis des Anbieters | Ausführung über die unterstützte Agent-Laufzeit des Anbieters statt eines direkten API-Aufrufs. | -| **Abo-Broker** | Broker-Endpunkt und Konfiguration seiner Token-Antwort | Die Bereitstellung bezieht nutzbare Abonnement-Tokens von einem Broker. | +| **Abo-Schlüssel** | Ein unterstütztes Abonnement-Geheimnis des Anbieters | Ausführung über die unterstützte Agent-Laufzeit des Anbieters in Aufgaben und Automatisierungen, nie im Chat. | +| **Abo-Broker** | Broker-Endpunkt und Konfiguration seiner Token-Antwort | Die Bereitstellung bezieht nutzbare Abonnement-Tokens von einem Broker, für die Agent-Laufzeit des Anbieters in Aufgaben und Automatisierungen, nie im Chat. | Es erscheinen nur Methoden, die der ausgewählte Anbieter unterstützt. Ein Variablenverweis legt die Variable nicht an. Der Betreiber muss sie gemäß der [Anbieterkonfiguration](/de/self-hosted/configuration/providers) bereitstellen. +## Abos in Aufgaben nutzen, nicht im Chat + +Zugangsdaten vom Typ **Abo-Schlüssel** oder **Abo-Broker** funktionieren nur in der Agent-Laufzeit, an die sie gebunden sind: Claude Code für ein Anthropic-Abonnement und für die Coding-Pläne von Moonshot und Z.ai, Codex für ein ChatGPT-Abonnement, Gemini CLI für Gemini und Hermes für Nous Portal. Die Anbieter erlauben Abo-Tokens nicht in anderen Anwendungen, und Anthropic weist sie bei jedem Client außer Claude Code ab. Der Chat ruft die API des Anbieters direkt aus Tale auf und kann deshalb keine Abo-Zugangsdaten verwenden. + +Tale führt ein Abo deshalb in Aufgaben und Automatisierungen aus, wo seine Laufzeit in einer Sandbox arbeitet. Der Chat bietet nur Modelle an, die Zugangsdaten vom Typ **API-Schlüssel** oder **Umgebungsvariable** bereitstellen. Die App weist an drei Stellen darauf hin: Das Formular zum Hinzufügen zeigt **Nur für Aufgaben und Automatisierungen**, sobald du eine Abo-Methode wählst, jede Abo-Zeile in der Tabelle der Zugangsdaten trägt denselben Hinweis, und die Modellliste im Chat nennt die Abos, die sie auslässt. + +Um mit einem Modell zu chatten, das du über ein Abo erreichst, füge für denselben Anbieter Zugangsdaten per API-Schlüssel oder Umgebungsvariable hinzu oder verbinde einen Anbieter wie OpenRouter, der das Modell bereitstellt. + ## Einen Abo-Broker verbinden -Abo-Broker unterstützen Anthropic-Abonnements über Claude Code und OpenAI-ChatGPT-Abonnements über Codex. Diese Zugangsdaten dienen Agenten für Aufgaben und Automatisierungen. Chats benötigen Zugangsdaten für den direkten API-Zugriff. +Abo-Broker unterstützen Anthropic-Abonnements über Claude Code und OpenAI-ChatGPT-Abonnements über Codex. Diese Zugangsdaten dienen Agenten für Aufgaben und Automatisierungen. Chats benötigen Zugangsdaten für den direkten API-Zugriff, aus den [oben genannten Gründen](#abos-in-aufgaben-nutzen-nicht-im-chat). | Anbieter und Laufzeit | Zielvariable | | --- | --- | @@ -47,7 +55,7 @@ Trage unter **Pfad zum Token-Array** den Wert `$.tokens` ein, unter **Token-Feld Begrenze bei OpenAI **Erlaubte Modelle** auf Modell-IDs, die dein ChatGPT-Abonnement unterstützt. Der OpenAI-API-Katalog kann Modelle enthalten, die dieses Abonnement nicht nutzen kann. -Für Sol 6.1 (`gpt-6.1-sol`) speicherst du zuerst die OpenAI-Broker-Zugangsdaten. Wähle dann bei einem [Projektagenten](/de/platform/projects/project-agents) unter **Agent-Laufzeit** den Eintrag **Codex**. Suche unter **Modell** nach `gpt-6.1-sol` und wähle den Eintrag mit **OpenAI · Abo**. Codex nutzt die Responses-API, die dieses Modell für Tool-Aufrufe benötigt. Tales direkter Chat nutzt Chat Completions; dort wird dieses Modell über OpenAI deshalb auch bei der automatischen Modellauswahl nicht angeboten. +Um ein GPT-6-Modell über das ChatGPT-Abonnement zu nutzen, speicherst du zuerst die OpenAI-Broker-Zugangsdaten. Wähle dann bei einem [Projektagenten](/de/platform/projects/project-agents) unter **Agent-Laufzeit** den Eintrag **Codex**. Suche unter **Modell** nach der Modell-ID, etwa `gpt-6.1-sol`, und wähle den Eintrag mit **OpenAI · Abo**. [Die GPT-6-Modelle nutzen](#die-gpt-6-modelle-nutzen) erklärt, wo jedes Modell sonst läuft. Mit **Token-Auswahl** bestimmst du, wie neue Agentendurchläufe verteilt werden: @@ -57,6 +65,13 @@ Mit **Token-Auswahl** bestimmst du, wie neue Agentendurchläufe verteilt werden: Speichere die Zugangsdaten und starte eine kurze Aufgabe oder Automatisierung mit dem passenden Anbieter und der passenden Agent-Laufzeit. Prüfe, ob der Agent eine Antwort abschließt. Ist kein Konto nutzbar, sollte der Betreiber Autorisierung, Token-Ablauf und geplante Token-Erneuerungen sowie das gemeldete Kontingent prüfen. Die [Broker-Konfigurationsreferenz](/de/self-hosted/configuration/providers#einen-abo-broker-verbinden) erklärt optionale Kontometadaten, Standardwerte und Abhilfe. +## Die GPT-6-Modelle nutzen + +Der OpenAI-Katalog enthält GPT-6 Astra (`gpt-6-astra`), GPT-6 Sol (`gpt-6-sol`), GPT-6 Luna (`gpt-6-luna`) und GPT-6.1 Sol (`gpt-6.1-sol`). + +- Der **Chat** bietet alle vier über OpenAI-Zugangsdaten vom Typ **API-Schlüssel** oder **Umgebungsvariable** an, auch in der automatischen Modellauswahl. Astra und GPT-6.1 Sol rufen Tools nur über die Responses-API von OpenAI auf, deshalb spricht Tale sie über diese API an. GPT-6 Sol und Luna nehmen die Tools des Chats nur mit ausgeschaltetem Reasoning an, deshalb bietet die Auswahl für sie keine Stufen für **Denkaufwand** an. +- **Projektagenten und Automatisierungen** führen Astra und GPT-6.1 Sol nur auf **Codex** aus, der Laufzeit, die die Responses-API spricht, mit Zugangsdaten per API-Schlüssel, Umgebungsvariable oder ChatGPT-Abo. Für andere Laufzeiten bietet die Modellauswahl sie nicht an. + ## Azure oder einen eigenen Endpunkt einrichten Azure OpenAI benötigt eine **Endpoint-URL**, gewöhnlich `https://.openai.azure.com/openai/v1`. Jeder Zugangsdaten-Eintrag gehört zu dieser Ressource. Azure verwendet die dort konfigurierten Bereitstellungsnamen als Modell-IDs. Trage diese Namen in die Liste **Erlaubte Modelle** ein. Ohne Katalog stellt eine leere Liste keine Modelle bereit. diff --git a/docs/de/platform/agents/harnesses.md b/docs/de/platform/agents/harnesses.md index d9cf0ce9e6..11a22fd7fd 100644 --- a/docs/de/platform/agents/harnesses.md +++ b/docs/de/platform/agents/harnesses.md @@ -9,7 +9,7 @@ Ein Harness ist das Coding-Programm, das die Sitzung eines Agenten in einer Sand Öffne im Tab **Agenten** eines Projekts einen Agenten und wähle die **Agent-Laufzeit**. Bei einer Agent-Node heißt das Feld **Harness**. Wähle danach Modell und Provider. Unter **Einstellungen > KI-Anbieter** zeigt **Agent-Laufzeiten**, welche Ausführungswege der Organisation derzeit zur Verfügung stehen. -Die Laufzeit braucht passende Zugangsdaten und [Sandbox-Kapazität](/de/platform/admin/sandboxes). Ein funktionierendes Chat-Modell genügt nicht. Fehlt die Laufzeit oder bietet sie keine Modelle an, prüfe ihren Status und die Provider-Zugangsdaten, bevor du den Aufgabenauftrag änderst. +Die Laufzeit braucht passende Zugangsdaten und [Sandbox-Kapazität](/de/platform/admin/sandboxes). Ein funktionierendes Chat-Modell genügt nicht. Fehlt die Laufzeit oder bietet sie keine Modelle an, prüfe ihren Status und die Provider-Zugangsdaten, bevor du den Aufgabenauftrag änderst. Ein Modell, das Tools nur über die Responses-API von OpenAI aufruft, etwa GPT-6 Astra oder GPT-6.1 Sol, läuft nur auf Codex; für andere Laufzeiten bietet die Modellauswahl es deshalb nicht an. ## Unterstützte Laufzeiten vergleichen @@ -37,7 +37,7 @@ Gemini CLI ist die Ausnahme: Tale setzt eine seiner Unterhaltungen nie fort. Ein Bei einem gespeicherten API-Schlüssel oder einer Deployment-Umgebungsvariable stellt Tale einen sitzungsgebundenen Gateway-Schlüssel bereit. Der ursprüngliche Modell-Provider-Schlüssel bleibt bei der Plattform. Gateway-Aufrufe werden gemessen und unterliegen den geltenden Ausgabenregeln. Bereits an andere laufende Durchläufe vergebene Beträge werden berücksichtigt. -Provider-Abonnements verwenden ihren unterstützten Harness und erhalten den Abonnement-Zugang in der Sitzungsumgebung. Sie dienen weder als normale Chat-Zugangsdaten noch für inkompatible Harnesses. Ihre direkten Aufrufe umgehen die Kostenmessung und Ausgabengrenzen des Tale-Gateways. Prüfe die Nutzung beim Abonnement-Provider. +Provider-Abonnements verwenden ihren unterstützten Harness und erhalten den Abonnement-Zugang in der Sitzungsumgebung. Sie dienen weder als normale Chat-Zugangsdaten noch für inkompatible Harnesses, weil die Anbieter Abo-Tokens nur in ihrer eigenen Laufzeit erlauben; mehr dazu unter [KI-Anbieter](/de/platform/admin/providers#abos-in-aufgaben-nutzen-nicht-im-chat). Ihre direkten Aufrufe umgehen die Kostenmessung und Ausgabengrenzen des Tale-Gateways. Prüfe die Nutzung beim Abonnement-Provider. Diese Regeln für Modellzugänge bedeuten nicht, dass die Sandbox keinerlei Geheimnisse enthält. Ausdrücklich vergebene **Secrets** sowie ein Token für einen zugeordneten GitHub-Zugang können darin verfügbar sein. Vergib nur den für die Aufgabe nötigen Zugriff. diff --git a/docs/de/platform/chat/basics.md b/docs/de/platform/chat/basics.md index 5d25217e54..89cb730426 100644 --- a/docs/de/platform/chat/basics.md +++ b/docs/de/platform/chat/basics.md @@ -33,7 +33,7 @@ Wähle ein bestimmtes Modell, wenn du Antworten vergleichen möchtest oder weiß -Sind keine Modelle verfügbar, bitte einen Admin, aktive Zugangsdaten und den Modellzugriff zu prüfen. Unter [Modelle](/de/platform/models) steht, wie der Katalog entsteht. +Sind keine Modelle verfügbar, bitte einen Admin, aktive Zugangsdaten und den Modellzugriff zu prüfen. Der Chat bietet nur Modelle an, die Zugangsdaten per API-Schlüssel oder Umgebungsvariable bereitstellen: Ein Abo läuft nur in Aufgaben und Automatisierungen, und die Modellliste nennt die Abos, die sie auslässt. Unter [Modelle](/de/platform/models) steht, wie der Katalog entsteht. ## Die passenden Quellen bereitstellen diff --git a/docs/de/platform/models.md b/docs/de/platform/models.md index 3b0bf2c581..44b0119c7c 100644 --- a/docs/de/platform/models.md +++ b/docs/de/platform/models.md @@ -39,6 +39,7 @@ Prüfe die Grenzen in dieser Reihenfolge. Wenn du die Einstellungen nicht änder 1. Prüfe, ob der Provider aktivierte, nutzbare Zugangsdaten hat. Ein Katalogeintrag allein verbindet noch kein Konto. 2. Lies die **Erlaubte Modelle** dieser Zugangsdaten. Bei einem Provider mit Katalog begrenzt sie die Auswahl, ohne Katalog legt sie sie fest. 3. Prüfe die Modellzugriffsregeln für Organisation, Team oder Person unter [Inhalte & Modelle](/de/platform/admin/governance/content-models). -4. Prüfe bei einem Projektagenten, ob die Zugangsdaten seinen gewählten [Harness](/de/platform/agents/harnesses) unterstützen. Ein Abonnement kann an eine bestimmte Laufzeit gebunden sein. +4. Prüfe bei einem Projektagenten, ob die Zugangsdaten seinen gewählten [Harness](/de/platform/agents/harnesses) unterstützen. Ein Abonnement kann an eine bestimmte Laufzeit gebunden sein, und ein Modell, das Tools nur über die Responses-API von OpenAI aufruft, etwa GPT-6.1 Sol, wird nur für Codex angeboten. +5. Im Chat erscheint kein Modell, das nur Abo-Zugangsdaten bereitstellen: Ein Abo läuft nur in Aufgaben und Automatisierungen, und die Modellliste im Chat nennt die Abos, die sie auslässt. Füge Zugangsdaten per API-Schlüssel oder Umgebungsvariable hinzu, um mit diesem Modell zu chatten; [KI-Provider](/de/platform/admin/providers#abos-in-aufgaben-nutzen-nicht-im-chat) erklärt, warum. Ist das Modell sichtbar, aber der Aufruf schlägt fehl, lies die Begründung. Abgelaufene Zugangsdaten, Provider-Ausfälle, Budgetgrenzen und fehlende Sandbox-Kapazität sind unterschiedliche Probleme. Ein Katalogabruf behebt sie nicht alle. [KI-Provider](/de/platform/admin/providers) erklärt Zugangsdaten; [Richtlinien und Limits](/de/platform/admin/governance/policies-and-limits) behandelt Ausgabengrenzen. diff --git a/docs/de/platform/projects/project-agents.md b/docs/de/platform/projects/project-agents.md index f3d69fbcd2..2f38fbd577 100644 --- a/docs/de/platform/projects/project-agents.md +++ b/docs/de/platform/projects/project-agents.md @@ -31,7 +31,7 @@ Du kannst auch bei einer Aufgabe beginnen: Solange das Projekt keinen Agenten ha -Suche unter **Modell** nach Name oder API-ID. Dasselbe Modell kann pro Provider einmal erscheinen. Lies den Provider des Eintrags, bevor du ihn wählst. Damit legst du diese Kombination für künftige Läufe fest. Abonnementeinträge erscheinen nur bei kompatibler Laufzeit. +Suche unter **Modell** nach Name oder API-ID. Dasselbe Modell kann pro Provider einmal erscheinen. Lies den Provider des Eintrags, bevor du ihn wählst. Damit legst du diese Kombination für künftige Läufe fest. Abonnementeinträge erscheinen nur bei kompatibler Laufzeit, und ein Modell, das Tools nur über die Responses-API von OpenAI aufruft, etwa GPT-6.1 Sol, erscheint nur bei Codex. Eine ältere Konfiguration kann ein Modell ohne festgelegten Provider enthalten. Der Dialog zeigt, welcher Provider es derzeit bereitstellen würde oder warum kein Zugang verfügbar ist. Wähle einen Eintrag, wenn du den Provider festlegen möchtest. diff --git a/docs/en/develop/use-tale-from-your-editor.md b/docs/en/develop/use-tale-from-your-editor.md index fdbcd1dc26..96584c4e87 100644 --- a/docs/en/develop/use-tale-from-your-editor.md +++ b/docs/en/develop/use-tale-from-your-editor.md @@ -70,7 +70,7 @@ The answer is an OpenAI model list: `owned_by` is the provider slug, and `create } ``` -The list holds your organization's chat models that a provider credential of type **API key** or **Environment variable** serves, narrowed by each credential's model allowlist and by your model access. Models served through a subscription credential are not listed, and neither are models of a provider whose endpoint is set per credential, such as Azure. `GET /api/v1/models` gives each of these models' context window, capabilities, and prices under the same `providerSlug` and `id`. +The list holds your organization's chat models that a provider credential of type **API key** or **Environment variable** serves, narrowed by each credential's model allowlist and by your model access. Models served through a subscription credential are not listed, and neither are models of a provider whose endpoint is set per credential, such as Azure, or models whose tool calls work only through OpenAI's Responses API, such as GPT-6.1 Sol, which these endpoints do not relay. `GET /api/v1/models` gives each of these models' context window, capabilities, and prices under the same `providerSlug` and `id`. ### Point opencode at Tale diff --git a/docs/en/platform/admin/providers.md b/docs/en/platform/admin/providers.md index b7e4227952..8b671fea5f 100644 --- a/docs/en/platform/admin/providers.md +++ b/docs/en/platform/admin/providers.md @@ -27,14 +27,22 @@ For **API key** or **Environment variable** credentials, open a chat and send a | --- | --- | --- | | **API key** | The provider's secret key | Standard metered API access. The stored secret is encrypted and later shown only as a masked fragment. | | **Environment variable** | The name of a deployment variable | An operator manages the secret outside the UI. The name must start with `TALE_PROVIDER_KEY_`. | -| **Subscription key** | A supported vendor subscription secret | Runs through the vendor's supported agent runtime, rather than a direct API call. | -| **Subscription broker** | A broker endpoint and token-response configuration | The deployment obtains usable subscription tokens from a broker. | +| **Subscription key** | A supported vendor subscription secret | Runs through the vendor's supported agent runtime in tasks and automations, never in chat. | +| **Subscription broker** | A broker endpoint and token-response configuration | The deployment obtains usable subscription tokens from a broker for the vendor's agent runtime in tasks and automations, never in chat. | Only methods supported by the selected provider appear. An environment reference does not create the variable: ask the operator to provision it using the [provider configuration guide](/self-hosted/configuration/providers). +## Use subscriptions in tasks, not in chat + +A **Subscription key** or **Subscription broker** credential works only inside the agent runtime it is bound to: Claude Code for an Anthropic subscription and for the Moonshot and Z.ai coding plans, Codex for a ChatGPT subscription, Gemini CLI for Gemini, and Hermes for Nous Portal. Vendors do not permit subscription tokens in other applications, and Anthropic refuses them from any client other than Claude Code. Chat calls the provider's API from Tale itself, so it cannot use a subscription credential. + +Tale therefore runs a subscription in tasks and automations, where its runtime works in a sandbox. Chat offers only models that an **API key** or **Environment variable** credential serves. The app says so in three places: the add form shows **Tasks and automations only** when you choose a subscription method, every subscription row in the credentials table carries the same note, and the chat model list names the subscriptions it leaves out. + +To chat with a model you reach through a subscription, add an API key or environment-variable credential for the same provider, or connect a provider such as OpenRouter that serves the model. + ## Connect a subscription broker -Subscription brokers support Anthropic subscriptions through Claude Code and OpenAI ChatGPT subscriptions through Codex. These credentials serve task and automation agents; chats require direct API credentials. +Subscription brokers support Anthropic subscriptions through Claude Code and OpenAI ChatGPT subscriptions through Codex. These credentials serve task and automation agents; chats require direct API credentials, for the [reasons above](#use-subscriptions-in-tasks-not-in-chat). | Provider and runtime | Target variable | | --- | --- | @@ -47,7 +55,7 @@ Set **Token array path** to `$.tokens`, **Token field** to `access_token`, and * For OpenAI, restrict **Model allowlist** to model IDs your ChatGPT plan supports. The OpenAI API catalog can include models that the subscription cannot use. -For Sol 6.1 (`gpt-6.1-sol`), save the OpenAI broker credential, then configure a [project agent](/platform/projects/project-agents) with **Agent type** set to **Codex**. Under **Model**, search for `gpt-6.1-sol` and select the entry marked **OpenAI · Subscription**. Codex uses the Responses API required by this model's tool calls. Tale's direct chat uses Chat Completions, so it does not offer this model through OpenAI, including automatic model selection. +To run a GPT-6 model on the ChatGPT subscription, save the OpenAI broker credential, then configure a [project agent](/platform/projects/project-agents) with **Agent type** set to **Codex**. Under **Model**, search for the model ID, such as `gpt-6.1-sol`, and select the entry marked **OpenAI · Subscription**. [Run the GPT-6 models](#run-the-gpt-6-models) explains where else each model runs. Choose **Token selection** according to how you want to distribute new agent turns: @@ -57,6 +65,13 @@ Choose **Token selection** according to how you want to distribute new agent tur Save the credential, then run a short task or automation with the matching provider and agent runtime. Check that the agent completes a reply. If no account is usable, ask the operator to check account authorization, token expiry and planned refreshes, and reported quota. The [broker configuration reference](/self-hosted/configuration/providers#connect-a-subscription-broker) explains the optional account metadata, defaults and recovery. +## Run the GPT-6 models + +The OpenAI catalog includes GPT-6 Astra (`gpt-6-astra`), GPT-6 Sol (`gpt-6-sol`), GPT-6 Luna (`gpt-6-luna`) and GPT-6.1 Sol (`gpt-6.1-sol`). + +- **Chat** offers all four through an OpenAI **API key** or **Environment variable** credential, automatic model selection included. Astra and GPT-6.1 Sol make tool calls only through OpenAI's Responses API, so Tale calls them through it. GPT-6 Sol and Luna accept the chat's tools only with reasoning switched off, so the picker offers no effort levels for them. +- **Project agents and automations** run Astra and GPT-6.1 Sol only on **Codex**, the runtime that speaks the Responses API, on an API-key, environment-variable or ChatGPT-subscription credential. The model picker offers them for no other runtime. + ## Configure Azure or another custom endpoint Azure OpenAI requires **Endpoint URL**, typically `https://.openai.azure.com/openai/v1`. Each credential belongs to that resource. Azure model IDs are the deployment names configured in the Azure resource, so enter those names in **Model allowlist**; an empty list provides no models when there is no catalog to inherit. diff --git a/docs/en/platform/agents/harnesses.md b/docs/en/platform/agents/harnesses.md index e643454484..7c62568242 100644 --- a/docs/en/platform/agents/harnesses.md +++ b/docs/en/platform/agents/harnesses.md @@ -9,7 +9,7 @@ A harness is the coding program that runs an agent’s session in a sandbox. It In a project’s **Agents** tab, open an agent and choose **Agent type**. An automation’s agent node calls the field **Harness**. Then choose the model and provider. Under **Settings > AI providers**, **Agent runtimes** shows which execution paths the organization can currently serve. -A runtime needs both compatible credentials and [sandbox capacity](/platform/admin/sandboxes). A working chat model is not enough. If a runtime is missing or has no models, inspect its status and provider credential before changing the task prompt. +A runtime needs both compatible credentials and [sandbox capacity](/platform/admin/sandboxes). A working chat model is not enough. If a runtime is missing or has no models, inspect its status and provider credential before changing the task prompt. A model whose tool calls need OpenAI’s Responses API, such as GPT-6 Astra or GPT-6.1 Sol, runs only on Codex, so the model picker offers it for no other runtime. ## Compare supported runtimes @@ -37,7 +37,7 @@ Gemini CLI is the exception: Tale never continues one of its conversations. A la With a stored API key or deployment-environment credential, Tale supplies a session-scoped gateway key. The original model-provider key stays at the platform. Calls through this gateway are metered and subject to the applicable spending rules, including allowance already assigned to other running turns. -Vendor subscriptions use their supported harness and receive the subscription credential in the session environment. They cannot be used as ordinary chat credentials or with an incompatible harness. Their direct provider calls bypass Tale’s gateway metering and spending caps; review usage with the subscription provider. +Vendor subscriptions use their supported harness and receive the subscription credential in the session environment. They cannot be used as ordinary chat credentials or with an incompatible harness, because the vendors permit subscription tokens only in their own runtime; [AI providers](/platform/admin/providers#use-subscriptions-in-tasks-not-in-chat) explains this. Their direct provider calls bypass Tale’s gateway metering and spending caps; review usage with the subscription provider. These model-credential rules do not mean the sandbox contains no secrets. Explicitly granted **Secrets**, and the token supplied for an equipped GitHub connection, can be available inside it. Grant only the access the task needs. diff --git a/docs/en/platform/chat/basics.md b/docs/en/platform/chat/basics.md index 5a5df6de82..e0ad8f6b7e 100644 --- a/docs/en/platform/chat/basics.md +++ b/docs/en/platform/chat/basics.md @@ -33,7 +33,7 @@ Pick a named model when you need consistent comparisons or know which model the -If no models are available, ask an admin to check active provider credentials and model access. [Models](/platform/models) explains how the catalog is built. +If no models are available, ask an admin to check active provider credentials and model access. Chat offers only models that an API key or environment-variable credential serves: a subscription runs only in tasks and automations, and the model list names any it leaves out. [Models](/platform/models) explains how the catalog is built. ## Give the assistant the right sources diff --git a/docs/en/platform/models.md b/docs/en/platform/models.md index a924837440..518b4d459c 100644 --- a/docs/en/platform/models.md +++ b/docs/en/platform/models.md @@ -39,6 +39,7 @@ Check these boundaries in order, or give the details to an administrator if you 1. Confirm the provider has an enabled, usable credential. A catalog entry by itself is not an account connection. 2. Inspect that credential’s **Model allowlist**. For a catalog provider it restricts the list; for a provider without a catalog it defines the list. 3. Check the model-access rules for the relevant organization, team or user under [Content & models](/platform/admin/governance/content-models). -4. For a project agent, check that the credential supports its selected [harness](/platform/agents/harnesses). A subscription may work only with its required runtime. +4. For a project agent, check that the credential supports its selected [harness](/platform/agents/harnesses). A subscription may work only with its required runtime, and a model whose tool calls need OpenAI’s Responses API, such as GPT-6.1 Sol, is offered only for Codex. +5. In Chat, a model that only a subscription credential serves is not offered: a subscription runs only in tasks and automations, and the chat model list names the subscriptions it leaves out. Add an API key or environment-variable credential to chat with that model; [AI providers](/platform/admin/providers#use-subscriptions-in-tasks-not-in-chat) explains why. If the model is visible but a call fails, read the displayed reason. Expired credentials, provider failure, budget limits and lack of sandbox capacity are different problems. Refreshing a catalog cannot repair all of them. [AI providers](/platform/admin/providers) covers credentials; [Policies and limits](/platform/admin/governance/policies-and-limits) covers spending refusals. diff --git a/docs/en/platform/projects/project-agents.md b/docs/en/platform/projects/project-agents.md index 98ea4f4bbf..efdf034730 100644 --- a/docs/en/platform/projects/project-agents.md +++ b/docs/en/platform/projects/project-agents.md @@ -31,7 +31,7 @@ You can also start from a task: while the project has no agent, **Create an agen -Search **Model** by name or API ID. The same model can appear once per provider; read the provider on the entry before selecting it. Selecting an entry pins that pair for future runs. Subscription entries appear only for a compatible runtime. +Search **Model** by name or API ID. The same model can appear once per provider; read the provider on the entry before selecting it. Selecting an entry pins that pair for future runs. Subscription entries appear only for a compatible runtime, and a model whose tool calls need OpenAI’s Responses API, such as GPT-6.1 Sol, appears only for Codex. An older configuration may name a model without a pinned provider. The dialog reports which provider currently resolves it, or why none can serve it. Select an entry if you want to pin that choice. diff --git a/docs/fr/develop/use-tale-from-your-editor.md b/docs/fr/develop/use-tale-from-your-editor.md index fdf104404f..5891d6d769 100644 --- a/docs/fr/develop/use-tale-from-your-editor.md +++ b/docs/fr/develop/use-tale-from-your-editor.md @@ -70,7 +70,7 @@ La réponse est une liste de modèles au format OpenAI : `owned_by` est le slug } ``` -La liste contient les modèles de chat de ton organisation que servent des identifiants de fournisseur de type **Clé API** ou **Variable d'environnement**, restreints par les modèles autorisés de chaque identifiant et par ton accès aux modèles. Les modèles servis par des identifiants d’abonnement n’y figurent pas, pas plus que ceux d’un fournisseur dont l’adresse est définie pour chaque identifiant, comme Azure. `GET /api/v1/models` donne pour chacun de ces modèles sa fenêtre de contexte, ses capacités et ses prix, sous les mêmes `providerSlug` et `id`. +La liste contient les modèles de chat de ton organisation que servent des identifiants de fournisseur de type **Clé API** ou **Variable d'environnement**, restreints par les modèles autorisés de chaque identifiant et par ton accès aux modèles. Les modèles servis par des identifiants d’abonnement n’y figurent pas, pas plus que ceux d’un fournisseur dont l’adresse est définie pour chaque identifiant, comme Azure, ni les modèles qui n’appellent des tools que via l’API Responses d’OpenAI, comme GPT-6.1 Sol, car ces endpoints ne les relaient pas. `GET /api/v1/models` donne pour chacun de ces modèles sa fenêtre de contexte, ses capacités et ses prix, sous les mêmes `providerSlug` et `id`. ### Brancher opencode sur Tale diff --git a/docs/fr/platform/admin/providers.md b/docs/fr/platform/admin/providers.md index 01d8b0ec7f..e6da048884 100644 --- a/docs/fr/platform/admin/providers.md +++ b/docs/fr/platform/admin/providers.md @@ -27,14 +27,22 @@ Pour des identifiants de type **Clé API** ou **Variable d'environnement**, envo | --- | --- | --- | | **Clé API** | La clé secrète du fournisseur | Accès API facturé à l’usage. Le secret enregistré est chiffré et seul un fragment masqué reste visible. | | **Variable d'environnement** | Le nom d’une variable du déploiement | L’opérateur gère le secret hors de l’interface. Son nom doit commencer par `TALE_PROVIDER_KEY_`. | -| **Clé d'abonnement** | Un secret d’abonnement pris en charge | Exécution dans l’environnement d’agent du fournisseur, plutôt que par un appel API direct. | -| **Courtier d'abonnement** | L’adresse du courtier et la configuration de sa réponse | Le déploiement obtient des tokens d’abonnement utilisables auprès du courtier. | +| **Clé d'abonnement** | Un secret d’abonnement pris en charge | Exécution dans l’environnement d’agent du fournisseur, dans les tâches et les automatisations, jamais dans le chat. | +| **Courtier d'abonnement** | L’adresse du courtier et la configuration de sa réponse | Le déploiement obtient auprès du courtier des tokens d’abonnement pour l’environnement d’agent du fournisseur, dans les tâches et les automatisations, jamais dans le chat. | Seules les méthodes du fournisseur sélectionné apparaissent. Référencer une variable ne la crée pas : demande à l’opérateur de la fournir selon le [guide de configuration des fournisseurs](/fr/self-hosted/configuration/providers). +## Utiliser les abonnements dans les tâches, pas dans le chat + +Des identifiants de type **Clé d'abonnement** ou **Courtier d'abonnement** ne fonctionnent que dans l’environnement d’agent auquel ils sont liés : Claude Code pour un abonnement Anthropic et pour les forfaits de programmation de Moonshot et de Z.ai, Codex pour un abonnement ChatGPT, Gemini CLI pour Gemini et Hermes pour Nous Portal. Les fournisseurs n’autorisent pas les jetons d’abonnement dans d’autres applications, et Anthropic les refuse depuis tout client autre que Claude Code. Le chat appelle l’API du fournisseur depuis Tale même : il ne peut donc pas utiliser d’identifiants d’abonnement. + +Tale exécute donc un abonnement dans les tâches et les automatisations, où son environnement travaille dans une sandbox. Le chat ne propose que les modèles servis par des identifiants de type **Clé API** ou **Variable d'environnement**. L’application l’indique à trois endroits : le formulaire d’ajout affiche **Tâches et automatisations uniquement** quand tu choisis une méthode d’abonnement, chaque ligne d’abonnement du tableau des identifiants porte la même mention, et la liste des modèles du chat nomme les abonnements qu’elle laisse de côté. + +Pour discuter avec un modèle auquel tu accèdes par un abonnement, ajoute des identifiants par clé API ou variable d’environnement pour le même fournisseur, ou connecte un fournisseur comme OpenRouter qui sert ce modèle. + ## Connecter un courtier d’abonnement -Les courtiers d’abonnement prennent en charge les abonnements Anthropic via Claude Code et les abonnements OpenAI ChatGPT via Codex. Ces identifiants servent aux agents de tâche et d’automatisation ; les chats nécessitent des identifiants d’accès direct à l’API. +Les courtiers d’abonnement prennent en charge les abonnements Anthropic via Claude Code et les abonnements OpenAI ChatGPT via Codex. Ces identifiants servent aux agents de tâche et d’automatisation ; les chats nécessitent des identifiants d’accès direct à l’API, pour les [raisons expliquées plus haut](#utiliser-les-abonnements-dans-les-taches-pas-dans-le-chat). | Fournisseur et agent | Variable cible | | --- | --- | @@ -47,7 +55,7 @@ Renseigne `$.tokens` dans **Chemin du tableau de jetons**, `access_token` dans * Pour OpenAI, limite **Modèles autorisés** aux identifiants de modèles pris en charge par ton abonnement ChatGPT. Le catalogue de l’API OpenAI peut inclure des modèles auxquels cet abonnement ne donne pas accès. -Pour utiliser Sol 6.1 (`gpt-6.1-sol`), enregistre les identifiants du courtier OpenAI, puis configure un [agent de projet](/fr/platform/projects/project-agents) en choisissant **Codex** sous **Harness**. Sous **Modèle**, recherche `gpt-6.1-sol` et sélectionne l’entrée **OpenAI · Abonnement**. Codex utilise l’API Responses, requise par les appels aux tools de ce modèle. Le chat direct de Tale utilise Chat Completions ; il ne propose donc pas ce modèle via OpenAI, y compris avec la sélection automatique du modèle. +Pour utiliser un modèle GPT-6 avec l’abonnement ChatGPT, enregistre les identifiants du courtier OpenAI, puis configure un [agent de projet](/fr/platform/projects/project-agents) en choisissant **Codex** sous **Harness**. Sous **Modèle**, recherche l’identifiant du modèle, par exemple `gpt-6.1-sol`, et sélectionne l’entrée **OpenAI · Abonnement**. [Utiliser les modèles GPT-6](#utiliser-les-modeles-gpt-6) indique où chaque modèle fonctionne par ailleurs. Choisis **Sélection du jeton** selon la répartition souhaitée pour les nouveaux tours d’agent : @@ -57,6 +65,13 @@ Choisis **Sélection du jeton** selon la répartition souhaitée pour les nouvea Enregistre les identifiants, puis lance une courte tâche ou automatisation avec le fournisseur et l’environnement d’agent correspondants. Vérifie que l’agent termine sa réponse. Si aucun compte n’est utilisable, demande à l’opérateur de vérifier l’autorisation des comptes, l’expiration et les actualisations prévues des jetons, ainsi que les quotas signalés. La [référence de configuration du courtier](/fr/self-hosted/configuration/providers#connecter-un-courtier-dabonnement) décrit les métadonnées facultatives, les valeurs par défaut et les solutions aux erreurs. +## Utiliser les modèles GPT-6 + +Le catalogue OpenAI comprend GPT-6 Astra (`gpt-6-astra`), GPT-6 Sol (`gpt-6-sol`), GPT-6 Luna (`gpt-6-luna`) et GPT-6.1 Sol (`gpt-6.1-sol`). + +- Le **chat** propose les quatre via des identifiants OpenAI de type **Clé API** ou **Variable d'environnement**, y compris pour la sélection automatique du modèle. Astra et GPT-6.1 Sol n’appellent des tools que via l’API Responses d’OpenAI : Tale les interroge donc par cette API. GPT-6 Sol et Luna n’acceptent les tools du chat qu’avec le raisonnement désactivé : le sélecteur ne propose donc pas de niveau d’**Effort de raisonnement** pour eux. +- Les **agents de projet et les automatisations** n’exécutent Astra et GPT-6.1 Sol que sur **Codex**, l’environnement qui parle l’API Responses, avec des identifiants par clé API, variable d’environnement ou abonnement ChatGPT. Le sélecteur de modèle ne les propose pour aucun autre environnement. + ## Configurer Azure ou une adresse propre au compte Azure OpenAI demande une **URL de l'endpoint**, généralement `https://.openai.azure.com/openai/v1`. Les identifiants appartiennent à cette ressource. Les identifiants de modèle Azure sont les noms de déploiement définis dans la ressource : saisis-les dans la liste **Modèles autorisés**. Sans catalogue, laisser cette liste vide ne rend aucun modèle disponible. diff --git a/docs/fr/platform/agents/harnesses.md b/docs/fr/platform/agents/harnesses.md index f33ba1e847..0cabe75448 100644 --- a/docs/fr/platform/agents/harnesses.md +++ b/docs/fr/platform/agents/harnesses.md @@ -9,7 +9,7 @@ Un harness est le programme de code qui exécute la session d’un agent dans un Dans l’onglet **Agents** d’un projet, ouvre un agent et choisis son **Harness**. Le nœud agent d’une automatisation utilise le même nom de champ. Choisis ensuite le modèle et le fournisseur. Sous **Paramètres > Fournisseurs IA**, la section **Harnesses** montre les voies d’exécution actuellement disponibles pour l’organisation. -Il faut des identifiants compatibles et de la [capacité de sandbox](/fr/platform/admin/sandboxes). Un modèle qui fonctionne dans Chat ne suffit pas. Si un environnement manque ou ne propose aucun modèle, examine son état et les identifiants du fournisseur avant de modifier la demande de travail. +Il faut des identifiants compatibles et de la [capacité de sandbox](/fr/platform/admin/sandboxes). Un modèle qui fonctionne dans Chat ne suffit pas. Si un environnement manque ou ne propose aucun modèle, examine son état et les identifiants du fournisseur avant de modifier la demande de travail. Un modèle qui n’appelle des tools que via l’API Responses d’OpenAI, comme GPT-6 Astra ou GPT-6.1 Sol, ne fonctionne que sur Codex : le sélecteur de modèle ne le propose donc pour aucun autre environnement. ## Comparer les environnements pris en charge @@ -37,7 +37,7 @@ Gemini CLI fait exception : Tale ne poursuit jamais une de ses conversations. Un Avec une clé API stockée ou fournie par l’environnement du déploiement, Tale remet une clé de passerelle limitée à la session. La clé d’origine du fournisseur de modèle reste dans la plateforme. Les appels de passerelle sont mesurés et soumis aux règles de dépense applicables, en tenant compte des montants déjà attribués aux autres échanges en cours. -Les abonnements fournisseurs utilisent leur harness compatible et reçoivent les identifiants d’abonnement dans l’environnement de la session. Ils ne servent pas d’identifiants de chat ordinaire et ne fonctionnent pas avec un harness incompatible. Leurs appels directs échappent à la mesure et aux plafonds de la passerelle Tale. Examine la consommation auprès du fournisseur d’abonnement. +Les abonnements fournisseurs utilisent leur harness compatible et reçoivent les identifiants d’abonnement dans l’environnement de la session. Ils ne servent pas d’identifiants de chat ordinaire et ne fonctionnent pas avec un harness incompatible, car les fournisseurs n’autorisent les jetons d’abonnement que dans leur propre environnement ; la page [Fournisseurs IA](/fr/platform/admin/providers#utiliser-les-abonnements-dans-les-taches-pas-dans-le-chat) l’explique. Leurs appels directs échappent à la mesure et aux plafonds de la passerelle Tale. Examine la consommation auprès du fournisseur d’abonnement. Ces règles sur les identifiants de modèle ne signifient pas que la sandbox ne contient aucun secret. Les **Secrets** explicitement accordés et le jeton d’un accès GitHub équipé peuvent y être disponibles. Limite ces accès aux besoins de la tâche. diff --git a/docs/fr/platform/chat/basics.md b/docs/fr/platform/chat/basics.md index c56fcfd6b7..967301958d 100644 --- a/docs/fr/platform/chat/basics.md +++ b/docs/fr/platform/chat/basics.md @@ -33,7 +33,7 @@ Choisis un modèle précis pour comparer des réponses dans les mêmes condition -Si aucun modèle n’est disponible, demande à un admin de vérifier les identifiants actifs des fournisseurs et les règles d’accès. La page [Modèles](/fr/platform/models) explique la composition du catalogue. +Si aucun modèle n’est disponible, demande à un admin de vérifier les identifiants actifs des fournisseurs et les règles d’accès. Le chat ne propose que les modèles servis par des identifiants par clé API ou variable d’environnement : un abonnement ne fonctionne que dans les tâches et les automatisations, et la liste des modèles nomme les abonnements qu’elle laisse de côté. La page [Modèles](/fr/platform/models) explique la composition du catalogue. ## Fournir les bonnes sources diff --git a/docs/fr/platform/models.md b/docs/fr/platform/models.md index 3a34b77a9c..da799dafc5 100644 --- a/docs/fr/platform/models.md +++ b/docs/fr/platform/models.md @@ -39,6 +39,7 @@ Vérifie ces limites dans l’ordre, ou transmets les détails à un administrat 1. Vérifie que le fournisseur possède des identifiants activés et utilisables. Une entrée de catalogue ne connecte pas un compte. 2. Examine leur **Modèles autorisés**. Avec un catalogue, elle restreint la sélection ; sans catalogue, elle la définit. 3. Vérifie les règles d’accès aux modèles pour l’organisation, l’équipe ou la personne dans [Contenu et modèles](/fr/platform/admin/governance/content-models). -4. Pour un agent de projet, vérifie la compatibilité des identifiants avec le [harness](/fr/platform/agents/harnesses) choisi. Un abonnement peut imposer un environnement précis. +4. Pour un agent de projet, vérifie la compatibilité des identifiants avec le [harness](/fr/platform/agents/harnesses) choisi. Un abonnement peut imposer un environnement précis, et un modèle qui n’appelle des tools que via l’API Responses d’OpenAI, comme GPT-6.1 Sol, n’est proposé que pour Codex. +5. Dans Chat, un modèle que seuls des identifiants d’abonnement servent n’apparaît pas : un abonnement ne fonctionne que dans les tâches et les automatisations, et la liste des modèles du chat nomme les abonnements qu’elle laisse de côté. Ajoute des identifiants par clé API ou variable d’environnement pour discuter avec ce modèle ; la page [Fournisseurs IA](/fr/platform/admin/providers#utiliser-les-abonnements-dans-les-taches-pas-dans-le-chat) explique pourquoi. Si le modèle apparaît mais que l’appel échoue, lis la cause affichée. Des identifiants expirés, un fournisseur indisponible, une limite de dépense et un manque de sandbox sont des problèmes distincts. Actualiser le catalogue ne les résout pas tous. [Fournisseurs IA](/fr/platform/admin/providers) explique les identifiants ; [Politiques et limites](/fr/platform/admin/governance/policies-and-limits) couvre les refus liés aux dépenses. diff --git a/docs/fr/platform/projects/project-agents.md b/docs/fr/platform/projects/project-agents.md index 7a3a01b74c..6440431798 100644 --- a/docs/fr/platform/projects/project-agents.md +++ b/docs/fr/platform/projects/project-agents.md @@ -31,7 +31,7 @@ Tu peux aussi partir d’une tâche : tant que le projet n’a pas d’agent, * -Recherche un **Modèle** par nom ou identifiant API. Le même modèle peut apparaître une fois par fournisseur : lis le fournisseur de l’entrée avant de la choisir. Cela fixe la combinaison pour les prochaines exécutions. Les offres par abonnement n’apparaissent qu’avec un environnement compatible. +Recherche un **Modèle** par nom ou identifiant API. Le même modèle peut apparaître une fois par fournisseur : lis le fournisseur de l’entrée avant de la choisir. Cela fixe la combinaison pour les prochaines exécutions. Les offres par abonnement n’apparaissent qu’avec un environnement compatible, et un modèle qui n’appelle des tools que via l’API Responses d’OpenAI, comme GPT-6.1 Sol, n’apparaît qu’avec Codex. Une ancienne configuration peut nommer un modèle sans fournisseur fixé. Le dialogue indique alors quel fournisseur le servirait actuellement ou pourquoi aucun ne peut le faire. Choisis une entrée pour fixer ce choix. diff --git a/services/platform/tests/manual/reference/automation.md b/services/platform/tests/manual/reference/automation.md index aaa8dcf542..31404c5fb4 100644 --- a/services/platform/tests/manual/reference/automation.md +++ b/services/platform/tests/manual/reference/automation.md @@ -43,7 +43,8 @@ Legend: ✅ fully automated · 🔶 partially automated · ⛔ manual-only (no s | [knowledge](../suites/knowledge.md) / [settings](../suites/settings.md) | Direct embeddings refuse subscription-key and subscription-broker credentials before allocating a broker account or constructing an API client; a settings race is checked again after resolution, and the refusal is classified as non-retryable | ✅ backend | `backend/core/knowledge/embedding_credentials.test.ts`; API-key and environment credentials retain endpoint precedence | | [settings](../suites/settings.md) / [tasks](../suites/tasks.md) / [automations](../suites/automations.md) | Broker selection filters malformed metadata, provider mismatches, inactive/expired tokens and exhausted quota — with `refresh_at` mapped as the expiry and an hour's safety margin, a Tale AI gateway token inside the gateway's hand-out floor is dropped, and the empty-pool reason names both a spent quota and a due refresh; stable broker IDs keep retry identity across token refresh; round-robin atomically chooses the least recently selected eligible account across concurrent backend connections, with organization and credential isolation and durable history; HTTP 429 records a shared 60-second account cooldown before retry, and advisory retry exclusions never bypass quota or cooldown; an account the broker holds back only for its coming refresh (`hold: "refresh"`) passes every other filter as a fallback and is vended — the latest refresh first — only when every available account is cooling down or lacks OpenAI's vendor account id, never while one can serve, and a broker that names no `hold` keeps it excluded; a pool whose every account cools down refuses with the moment the first comes back (`retryAtMs`) | ✅ backend + real Postgres | `backend/core/provider_credentials/broker_pool.test.ts`, `backend/core/provider_credentials/token_hash.test.ts`, `backend/core/provider_credentials/resolve_credential.test.ts`, `backend/domains/provider_credentials/broker-selection.test.ts`, `backend/domains/tasks/agent-turn-shim.broker.test.ts`, `backend/domains/automations/shim.broker.test.ts`, `backend/domains/provider_credentials/broker-selection.integration.ts` (`checkBrokerAccountSelection` in `backend:integration`); actual vendor acceptance remains a deployment check | | [tasks](../suites/tasks.md) / [automations](../suites/automations.md) | Anthropic broker credentials preserve the configured OAuth target while clearing competing credentials; OpenAI broker credentials use Codex's ChatGPT Responses connection with a separate vendor account ID; unsupported target variables and missing OpenAI account IDs are refused; provider-prefixed model IDs are normalized and credential model allowlists are enforced; static coding-plan keys retain their transport; Codex's native 429/401 errors retain their retry classification | ✅ backend + launcher | `backend/core/chat/external_turn_shared.subscription.test.ts`, `backend/core/lib/providers/agent_serving.test.ts`, `lib/harnesses/exec-builder.test.ts`, `backend/core/tasks/agent_run_host.context_window.test.ts`, `backend/core/automations/agent_host.context_window.test.ts`, `backend/core/tasks/agent_run_host.budget_exceeded.test.ts`, `backend/core/automations/agent_host.retry_resume.test.ts`, `lib/harnesses/parsers/codex-jsonl.test.ts`; synthetic transport fixtures do not prove live OAuth approval or a vendor model response | -| [settings](../suites/settings.md) / [tasks](../suites/tasks.md) / [automations](../suites/automations.md) / [chat](../suites/chat.md) | The shipped OpenAI catalog offers `gpt-6.1-sol` through an OpenAI subscription on Codex with its exact model ID. Its Responses-only tool support excludes the direct OpenAI serving from native chat and Auto, refuses an explicit native chat turn before calling the provider, and refuses incompatible managed harness wires; Codex and raw LLM calls without tools remain eligible. | 🔶 backend | `backend/core/lib/providers/load_system_config.test.ts`, `backend/core/lib/providers/agent_serving.test.ts`, `backend/core/lib/providers/chat_catalog.test.ts`, `lib/chat/turn.test.ts`; a completed reply through the live Codex subscription remains manual | +| [settings](../suites/settings.md) / [tasks](../suites/tasks.md) / [automations](../suites/automations.md) / [chat](../suites/chat.md) | The shipped OpenAI catalog offers `gpt-6-astra`, `gpt-6-sol`, `gpt-6-luna` and `gpt-6.1-sol` with their exact model IDs; Sol and Luna declare `toolsRequireOff`, Astra and Sol 6.1 the Responses tool API. Native chat and Auto serve a Responses-only model over the Responses API (request body, streamed text, tool calls, usage, finish reasons and in-stream failures); Anthropic-format connectors never offer one. Agent serving runs it on a managed or subscription Codex harness and refuses every other wire with the Responses reason, naming Codex; the agent pickers, the project-agent check, the standard agent's chooser and the **Agent runtimes** status offer, accept or count it only for Codex; the Chat Completions model endpoints leave it out. | 🔶 backend | `backend/core/lib/providers/load_system_config.test.ts`, `backend/core/lib/providers/harness_status.test.ts`, `backend/core/automations_builder/chat_wire.test.ts`, `backend/core/chat/turn_action.responses.test.ts`, `backend/core/lib/providers/chat_catalog.test.ts`, `lib/chat/turn.test.ts`, `backend/core/lib/providers/agent_serving.test.ts`, `backend/domains/projects/agent-equipment.test.ts`, `backend/domains/projects/standard-agent.test.ts`, `app/features/projects/lib/model-options.test.ts`, `backend/domains/model_api/models.test.ts`; completed replies through a live OpenAI key (CHAT-F60) and the Codex subscription remain manual | +| [settings](../suites/settings.md) / [chat](../suites/chat.md) | A subscription credential is said to serve tasks and automations, never chat: the add form's info notice for both subscription methods, the credentials table's row line, the chat model list's note naming the providers it leaves out, and the direct-chat refusal's reason. | ✅ unit | `app/features/settings/providers/components/providers-settings.test.tsx`, `app/features/chat/components/composer.test.tsx`, `lib/shared/providers/resolve_execution.test.ts`; layout and wording per locale stay manual (SET-F74, CHAT-F59) | | [settings](../suites/settings.md) | Replacing a broker configuration with blank secret fields preserves the stored broker secret, an explicit environment reference without a new secret switches the source, and unauthenticated replacement removes the old secret | ✅ backend | `backend/domains/provider_credentials/service.validation.test.ts`; entering and replacing the configuration in the settings dialog remains manual | | [settings](../suites/settings.md) | AI gateway token handouts preserve stable broker and vendor account IDs, provider identity and quota metadata; fresh exhausted global windows or an explicit vendor limit exclude the account, resets restore eligibility, scoped limits do not disable the whole account, and stale/unknown readings remain eligible; usage-only failures preserve credential status, concurrent handouts coalesce account work, and refreshed OAuth identity survives token rotation; each account's refresh is planned on its own share of the lifetime (two accounts refreshed together fall due hours apart, a month of passes never refreshes both in one pass, one vendor's due refreshes wait ten minutes for each other unless a token reaches its skew point, a handout refreshes only the account that is due), and an account within the hand-out floor of its planned refresh is served `available: false` until `refresh_at` while another account of its vendor can take the work — a vendor's last servable account is never held back — with `hold: "refresh"`, where a spent quota reads `hold: "quota"` | ✅ backend | `services/ai-gateway/backend/accounts.test.ts`, `services/ai-gateway/backend/routes.test.ts`, `services/ai-gateway/backend/providers/oauth.test.ts`, `services/ai-gateway/backend/providers/openai.test.ts`; live authorization and current provider quota reporting remain deployment checks | | [settings](../suites/settings.md) | Config-file invalidation reports the first write after readiness, atomic replacement and subsequent edits, new organization/domain/bundle trees, deletion and recreation; dot history/temp entries stay private, subscriber errors are isolated, and close stops delivery even during initial scanning | ✅ real filesystem | `lib/config-watcher.test.ts`; macOS uses scoped polling because native registration has no readiness handshake; Linux retains native events | diff --git a/services/platform/tests/manual/suites/chat.md b/services/platform/tests/manual/suites/chat.md index 2363e0ea2d..4c2c0130f2 100644 --- a/services/platform/tests/manual/suites/chat.md +++ b/services/platform/tests/manual/suites/chat.md @@ -1,6 +1,6 @@ # Chat -> **Prefix** `CHAT-` · **Reset** none · **Cost** 99 boxes +> **Prefix** `CHAT-` · **Reset** none · **Cost** 101 boxes Exercise the AI chat surface — the welcome view, messaging and the composer (model + reasoning-effort picker, attachments, dictation, voice output), @@ -170,6 +170,24 @@ i18n keys were pruned in #2919 — so this guide carries no canvas cases. (`chat.errorDetailsSummary`) reads **The model provider ended the reply with an error: E2E induced provider error inside the stream (502)** — never a completed, empty reply with thinking dots. +- [ ] `CHAT-F59` · **Subscriptions left out of the model list** — Mode B: in + an organization whose credentials include a **Subscription broker** + (Anthropic or OpenAI) beside an **API key** for another provider, open the + composer picker (`chat.picker.ariaLabel`) → **Model** + (`chat.picker.sectionModel`) → No model that only the subscription serves is + listed; under the list `chat.modelSelector.subscriptionsTasksOnly` names its + provider (two are joined by the locale's word for *and*). With subscription + credentials alone the list reads **No models available** + (`chat.modelSelector.noModelsAvailable`) above the same note. The note wraps + inside the menu without clipping in `en`, `de` and `fr`. +- [ ] `CHAT-F60` · **GPT-6.1 Sol in direct chat** — Mode B with an OpenAI + **API key** or **Environment variable** credential: pick **GPT 6.1 Sol** + (OpenAI) and ask something the organization's knowledge answers → The reply + streams and completes with its sources, so the knowledge tool ran through + the Responses API; **Model details** (`chat.modelSelector.viewInfo`) name + `gpt-6.1-sol`. Pick **GPT 6 Sol** → **Reasoning effort** (`chat.effort.label`) + offers only **Default** with `chat.effort.toolsLockedHint`, and a message + still answers. - [ ] `CHAT-F20` · **Export** — Thread header **Conversation actions** (`chat.aria.threadActions`) → **Export** (`chat.export.button`) → The **Export chat** dialog (`chat.export.title`) opens; **Deselect all** diff --git a/services/platform/tests/manual/suites/settings.md b/services/platform/tests/manual/suites/settings.md index 9f49aac1e7..5dde4ffad0 100644 --- a/services/platform/tests/manual/suites/settings.md +++ b/services/platform/tests/manual/suites/settings.md @@ -1,6 +1,6 @@ # Settings -> **Prefix** `SET-` · **Reset** none · **Cost** 117 boxes +> **Prefix** `SET-` · **Reset** none · **Cost** 118 boxes Exercise the settings surface along its real rail — **Personal** (Account, Preferences, Notifications, Usage), **Organization** (Organization, Teams, Members, @@ -839,6 +839,17 @@ run. stays available); another row can be pinned meanwhile; the row leaves the list within a few seconds of the spawner finishing, without a reload. +- [ ] `SET-F74` · **Subscription scope where a subscription is set up** — + `/dashboard/{org}/settings/providers` → **Add credential** → Anthropic → + **Authentication method** **Subscription broker** + (`settings.providers.authMethod.subscriptionBroker`) → An info notice + **Tasks and automations only** (`settings.providers.subscriptionScope.title`) + with its reason (`settings.providers.subscriptionScope.description`) sits + above the broker fields and is not announced as an alert; with **API key** + chosen it is gone. In the table a subscription row carries + `settings.providers.credential.tasksOnly` under its name. In `en`, `de`, + `de-CH` (which spells *ausser*) and `fr`, both texts wrap without clipping + at desktop and narrow widths. ## Boundary & error tests From 4c81f9718abb1029d06715083116ae6b7aa658e3 Mon Sep 17 00:00:00 2001 From: yannickmonney Date: Sat, 3 Oct 2026 22:45:10 +0200 Subject: [PATCH 3/3] fix(platform): agree on Responses runtimes in availability and status The standard agent's availability read chose without the runtimes that speak the Responses API, so a ChatGPT subscription's Responses-only pin on Codex read as unavailable while the kick would have run it. Both now read one set, and the chooser requires it, so no call can default to none. The Agent runtimes status said "no direct credential" for a runtime that had direct models but none its wire can carry; it now says why (no-compatible-model) and points to another model or Codex, in en, de and fr. --- .../harness-status-section.test.tsx | 26 +++++++++ .../components/harness-status-section.tsx | 18 ++++++- .../platform/app/lib/backend/contract/lib.ts | 5 +- .../core/lib/providers/harness_status.test.ts | 18 +++++++ .../core/lib/providers/harness_status.ts | 13 ++++- .../domains/projects/standard-agent.test.ts | 54 ++++++++++++++++++- .../domains/projects/standard-agent.ts | 31 +++++++---- services/platform/messages/de.yml | 5 ++ services/platform/messages/en.yml | 5 ++ services/platform/messages/fr.yml | 5 ++ 10 files changed, 165 insertions(+), 15 deletions(-) diff --git a/services/platform/app/features/settings/providers/components/harness-status-section.test.tsx b/services/platform/app/features/settings/providers/components/harness-status-section.test.tsx index cc26b7ffd9..a1584df1da 100644 --- a/services/platform/app/features/settings/providers/components/harness-status-section.test.tsx +++ b/services/platform/app/features/settings/providers/components/harness-status-section.test.tsx @@ -125,6 +125,32 @@ describe('HarnessStatusSection', () => { expect(screen.getAllByText('No model yet')).toHaveLength(2); }); + it('says why a runtime has no model when models exist but need the Responses API', () => { + const [available] = ROWS; + fixtures.status = [ + ...(available ? [available] : []), + { + slug: 'opencode', + label: 'OpenCode', + managed: { available: false, reason: 'no-compatible-model' }, + subscriptions: [], + }, + ]; + fixtures.health = []; + fixtures.statusError = null; + + renderSection(); + + expect( + screen.getByText(/only Codex speaks\. Allow another model/), + ).toBeInTheDocument(); + // Adding a credential would not help, so the credential note stays away. + expect( + screen.queryByText(/No directly usable provider credential yet/), + ).not.toBeInTheDocument(); + expect(screen.getByText('No model yet')).toBeInTheDocument(); + }); + it('adds no credential note when every runtime has a model', () => { fixtures.status = ROWS.filter((row) => row.managed.available); fixtures.health = []; diff --git a/services/platform/app/features/settings/providers/components/harness-status-section.tsx b/services/platform/app/features/settings/providers/components/harness-status-section.tsx index 09cdb5a39e..a550925a8b 100644 --- a/services/platform/app/features/settings/providers/components/harness-status-section.tsx +++ b/services/platform/app/features/settings/providers/components/harness-status-section.tsx @@ -132,11 +132,27 @@ export function HarnessStatusSection({ ) : ( {!statusQuery.isPending && - statusQuery.data.some((row) => !row.managed.available) && ( + statusQuery.data.some( + (row) => + !row.managed.available && + row.managed.reason === 'no-direct-credential', + ) && ( {t('providers.harnesses.noDirectCredential')} )} + {/* Models are direct-served, but none a runtime can carry: adding + a credential would not help, another model or Codex would. */} + {!statusQuery.isPending && + statusQuery.data.some( + (row) => + !row.managed.available && + row.managed.reason === 'no-compatible-model', + ) && ( + + {t('providers.harnesses.noCompatibleModel')} + + )}
    {(statusQuery.isPending ? LOADING_HARNESSES : statusQuery.data).map( (row) => ( diff --git a/services/platform/app/lib/backend/contract/lib.ts b/services/platform/app/lib/backend/contract/lib.ts index 080c695104..b322b626e3 100644 --- a/services/platform/app/lib/backend/contract/lib.ts +++ b/services/platform/app/lib/backend/contract/lib.ts @@ -116,7 +116,10 @@ export interface LibContract { label: string; managed: | { modelCount: number; available: true; defaultModelId: string } - | { reason: 'no-direct-credential'; available: false }; + | { + reason: 'no-direct-credential' | 'no-compatible-model'; + available: false; + }; }>; }; 'lib/providers/vision_actions:getResolvedVisionModel': { diff --git a/services/platform/backend/core/lib/providers/harness_status.test.ts b/services/platform/backend/core/lib/providers/harness_status.test.ts index fa6d6f6d0d..7a63b7fb25 100644 --- a/services/platform/backend/core/lib/providers/harness_status.test.ts +++ b/services/platform/backend/core/lib/providers/harness_status.test.ts @@ -76,6 +76,24 @@ describe('deriveHarnessStatus — against the real shipped harness facts', () => }); }); + it('says a harness has no model it can carry, not no credential, when every direct model needs Responses', () => { + const rows = deriveHarnessStatus({ + harnesses: HARNESSES, + directModels: [{ id: 'gpt-6.1-sol', toolCallingApi: 'responses' }], + subscriptions: [], + }); + + expect(entryOf(rows, 'codex').managed).toEqual({ + available: true, + modelCount: 1, + defaultModelId: 'gpt-6.1-sol', + }); + expect(entryOf(rows, 'claude-code').managed).toEqual({ + available: false, + reason: 'no-compatible-model', + }); + }); + it('omits byo-only harnesses (cursor) from the status list', () => { const rows = deriveHarnessStatus({ harnesses: HARNESSES, diff --git a/services/platform/backend/core/lib/providers/harness_status.ts b/services/platform/backend/core/lib/providers/harness_status.ts index 15f72c5f77..2e7f3de3da 100644 --- a/services/platform/backend/core/lib/providers/harness_status.ts +++ b/services/platform/backend/core/lib/providers/harness_status.ts @@ -44,7 +44,10 @@ export type HarnessManagedStatus = } | { available: false; - reason: 'no-direct-credential'; + /** `no-direct-credential`: nothing is direct-served at all. + * `no-compatible-model`: models are, but none this harness's wire can + * carry (their tools need the Responses API). */ + reason: 'no-direct-credential' | 'no-compatible-model'; }; export interface HarnessStatusEntry { @@ -109,7 +112,13 @@ export function deriveHarnessStatus(inputs: { const firstDirect = pool[0]; const managed: HarnessStatusEntry['managed'] = firstDirect === undefined - ? { available: false, reason: 'no-direct-credential' } + ? { + available: false, + reason: + inputs.directModels.length === 0 + ? 'no-direct-credential' + : 'no-compatible-model', + } : { available: true, modelCount: pool.length, diff --git a/services/platform/backend/domains/projects/standard-agent.test.ts b/services/platform/backend/domains/projects/standard-agent.test.ts index aeeb8ee7b1..060febd779 100644 --- a/services/platform/backend/domains/projects/standard-agent.test.ts +++ b/services/platform/backend/domains/projects/standard-agent.test.ts @@ -57,11 +57,14 @@ import { ProjectError } from './service.ts'; import { chooseStandardAgentServing, ensureStandardAgent, + readStandardAgentAvailability, STANDARD_AGENT_DEFAULT_INSTRUCTIONS, standardAgentServingForKick, } from './standard-agent.ts'; const ELIGIBLE = ['claude-code', 'codex', 'opencode']; +// The shipped harness that speaks the Responses API. +const RESPONSES_SPEAKERS: ReadonlySet = new Set(['codex']); function option( id: string, @@ -106,6 +109,7 @@ describe('chooseStandardAgentServing — what runs the standard agent', () => { ], {}, ELIGIBLE, + RESPONSES_SPEAKERS, ); expect(serving).toEqual({ @@ -129,6 +133,7 @@ describe('chooseStandardAgentServing — what runs the standard agent', () => { ], {}, ELIGIBLE, + RESPONSES_SPEAKERS, ); expect(serving).toMatchObject({ @@ -143,6 +148,7 @@ describe('chooseStandardAgentServing — what runs the standard agent', () => { [subscription('gpt-5.5', 'openai', 'codex')], {}, ELIGIBLE, + RESPONSES_SPEAKERS, ); expect(serving).toMatchObject({ @@ -161,6 +167,7 @@ describe('chooseStandardAgentServing — what runs the standard agent', () => { ], { harness: 'codex' }, ELIGIBLE, + RESPONSES_SPEAKERS, ); expect(serving).toMatchObject({ @@ -176,6 +183,7 @@ describe('chooseStandardAgentServing — what runs the standard agent', () => { [option('gpt-5.5', 'openai'), option('claude-sonnet-5', 'anthropic')], { providerSlug: 'openai', modelId: 'gpt-5.5' }, ELIGIBLE, + RESPONSES_SPEAKERS, ), ).toEqual({ ok: true, @@ -189,6 +197,7 @@ describe('chooseStandardAgentServing — what runs the standard agent', () => { [subscription('gpt-5.5', 'openai', 'codex')], { providerSlug: 'openai', modelId: 'gpt-5.5' }, ELIGIBLE, + RESPONSES_SPEAKERS, ), ).toMatchObject({ ok: true, harness: 'codex', source: 'pinned' }); }); @@ -240,6 +249,7 @@ describe('chooseStandardAgentServing — what runs the standard agent', () => { [responsesOnly], { providerSlug: 'openai', modelId: 'gpt-6.1-sol' }, ELIGIBLE, + new Set(), ), ).toEqual({ ok: false, refusal: 'pin-unavailable' }); }); @@ -250,6 +260,7 @@ describe('chooseStandardAgentServing — what runs the standard agent', () => { [option('claude-sonnet-5', 'anthropic')], { providerSlug: 'openai', modelId: 'gpt-5.5' }, ELIGIBLE, + RESPONSES_SPEAKERS, ), ).toEqual({ ok: false, refusal: 'pin-unavailable' }); expect( @@ -261,6 +272,7 @@ describe('chooseStandardAgentServing — what runs the standard agent', () => { modelId: 'claude-sonnet-5', }, ELIGIBLE, + RESPONSES_SPEAKERS, ), ).toEqual({ ok: false, refusal: 'pin-unavailable' }); }); @@ -271,9 +283,12 @@ describe('chooseStandardAgentServing — what runs the standard agent', () => { [option('gpt-5.5', 'openai')], { harness: 'cursor' }, ELIGIBLE, + RESPONSES_SPEAKERS, ), ).toEqual({ ok: false, refusal: 'harness-invalid' }); - expect(chooseStandardAgentServing([], {}, ELIGIBLE)).toEqual({ + expect( + chooseStandardAgentServing([], {}, ELIGIBLE, RESPONSES_SPEAKERS), + ).toEqual({ ok: false, refusal: 'no-model', }); @@ -282,6 +297,7 @@ describe('chooseStandardAgentServing — what runs the standard agent', () => { [subscription('claude-sonnet-5', 'anthropic', 'claude-code')], { harness: 'codex' }, ELIGIBLE, + RESPONSES_SPEAKERS, ), ).toEqual({ ok: false, refusal: 'no-model' }); }); @@ -305,6 +321,42 @@ beforeEach(() => { ]); }); +// The availability every picker reads and the kick a start runs choose with +// the same runtimes: a ChatGPT subscription's Responses-only model, pinned, +// runs on Codex in both, never available in one and refused by the other. +describe('readStandardAgentAvailability — agrees with the kick', () => { + it('reports a Responses-only subscription pin as available on Codex', async () => { + readGovernancePolicyForOrg.mockResolvedValue({ + enabled: true, + providerSlug: 'openai', + modelId: 'gpt-6.1-sol', + }); + listGovernedChatModels.mockResolvedValue([ + option('gpt-6.1-sol', 'openai', { + toolCallingApi: 'responses', + credential: { + authMethod: 'subscription-broker', + constraints: { harness: 'codex', execution: 'sandbox' }, + }, + }), + ]); + + await expect( + readStandardAgentAvailability({} as never, { + organizationId: 'org-1', + userId: 'member-1', + }), + ).resolves.toMatchObject({ + enabled: true, + available: true, + harness: 'codex', + model: 'gpt-6.1-sol', + modelProvider: 'openai', + source: 'pinned', + }); + }); +}); + describe('standardAgentServingForKick — the policy, at every start', () => { const args = { organizationId: 'org-1', diff --git a/services/platform/backend/domains/projects/standard-agent.ts b/services/platform/backend/domains/projects/standard-agent.ts index bb9a006298..39754d3164 100644 --- a/services/platform/backend/domains/projects/standard-agent.ts +++ b/services/platform/backend/domains/projects/standard-agent.ts @@ -138,7 +138,7 @@ export function chooseStandardAgentServing( options: readonly ComposerModelOption[], config: Pick, eligibleHarnesses: readonly string[], - responsesHarnesses: ReadonlySet = new Set(), + responsesHarnesses: ReadonlySet, ): StandardAgentServing { if ( config.harness !== undefined && @@ -257,6 +257,19 @@ export function chooseStandardAgentServing( }; } +/** The shipped harnesses that speak the Responses API — the only ones a + * model whose tools need it can run on. One set for the run and for the + * availability every picker reads, so the two never disagree. */ +function responsesSpeakingHarnesses(): ReadonlySet { + return new Set( + loadHarnesses() + .filter( + (harness) => harnessToolCallingWire(harness) === 'openai-responses', + ) + .map((harness) => harness.slug), + ); +} + /** What runs the standard agent for this person, under this policy. */ async function resolveStandardAgentServing( sql: Sql | TransactionSql, @@ -277,18 +290,11 @@ async function resolveStandardAgentServing( organizationId: args.organizationId, userId: args.userId, }); - const responsesHarnesses = new Set( - loadHarnesses() - .filter( - (harness) => harnessToolCallingWire(harness) === 'openai-responses', - ) - .map((harness) => harness.slug), - ); return chooseStandardAgentServing( options, args.config, eligible, - responsesHarnesses, + responsesSpeakingHarnesses(), ); } @@ -323,7 +329,12 @@ export async function readStandardAgentAvailability( config.harness !== undefined && !eligible.includes(config.harness) ? [] : await listGovernedChatModels(sql, args); - const serving = chooseStandardAgentServing(options, config, eligible); + const serving = chooseStandardAgentServing( + options, + config, + eligible, + responsesSpeakingHarnesses(), + ); if (!serving.ok) { return { enabled: true, available: false, refusal: serving.refusal }; } diff --git a/services/platform/messages/de.yml b/services/platform/messages/de.yml index c5b3ee9e3e..af690fa55e 100644 --- a/services/platform/messages/de.yml +++ b/services/platform/messages/de.yml @@ -6375,6 +6375,11 @@ settings: noDirectCredential: Noch keine direkt nutzbaren Anbieter-Zugangsdaten — füge oben einen API-Schlüssel oder eine Umgebungsvariable hinzu. + noCompatibleModel: + Eine Laufzeit ohne Modell kann keines der direkt bereitgestellten + Modelle ausführen — diese rufen Tools nur über die Responses-API auf, + die nur Codex spricht. Erlaube für diese Laufzeiten ein anderes Modell + oder führe den Agenten auf Codex aus. noModel: Noch kein Modell degraded: Zuletzt fehlerhaft subscriptionVia: Abo · {provider} diff --git a/services/platform/messages/en.yml b/services/platform/messages/en.yml index 6fb922cb14..a87aee1bf1 100644 --- a/services/platform/messages/en.yml +++ b/services/platform/messages/en.yml @@ -6550,6 +6550,11 @@ settings: noDirectCredential: No directly usable provider credential yet — add an API key or an environment credential above. + noCompatibleModel: + A runtime without a model can run none of the directly served models + — they take tools only through the Responses API, which only Codex + speaks. Allow another model for those runtimes, or run the agent on + Codex. noModel: No model yet degraded: Recently failing subscriptionVia: Subscription · {provider} diff --git a/services/platform/messages/fr.yml b/services/platform/messages/fr.yml index 46d72fd1fb..8a1b5088e3 100644 --- a/services/platform/messages/fr.yml +++ b/services/platform/messages/fr.yml @@ -6472,6 +6472,11 @@ settings: noDirectCredential: Aucun identifiant de fournisseur directement utilisable — ajoute une clé API ou une variable d'environnement ci-dessus. + noCompatibleModel: + Un harness sans modèle ne peut exécuter aucun des modèles servis + directement — ils n'appellent des outils que via l'API Responses, que + seul Codex parle. Autorise un autre modèle pour ces harnesses, ou + exécute l'agent sur Codex. noModel: Pas encore de modèle degraded: En échec récemment subscriptionVia: Abonnement · {provider}