From d32d46df97b81bd24706c55810f3077475106f74 Mon Sep 17 00:00:00 2001 From: yannickmonney Date: Sat, 3 Oct 2026 17:33:35 +0200 Subject: [PATCH] fix(platform): enable Sol 6.1 through OpenAI subscriptions --- .github/release-notes/v0.5.71.md | 38 +++++++++ .../platform/system/models/openai/models.yml | 20 +++++ docs/de/platform/admin/providers.md | 2 + docs/en/platform/admin/providers.md | 2 + docs/fr/platform/admin/providers.md | 2 + packages/shared/src/schemas/providers.test.ts | 15 ++++ packages/shared/src/schemas/providers.ts | 4 + .../backend/core/automations/llm_call.ts | 20 ++++- .../external_turn_shared.subscription.test.ts | 19 ++++- .../core/lib/providers/agent_serving.test.ts | 81 ++++++++++++++++++- .../core/lib/providers/agent_serving.ts | 45 ++++++++--- .../core/lib/providers/chat_catalog.test.ts | 33 ++++++++ .../core/lib/providers/chat_catalog.ts | 11 +++ .../lib/providers/load_system_config.test.ts | 25 ++++++ .../backend/core/tasks/task_serving.test.ts | 1 + .../backend/core/tasks/task_serving.ts | 6 +- services/platform/lib/chat/turn.test.ts | 24 ++++++ .../providers/resolve_execution.test.ts | 43 ++++++++++ .../lib/shared/providers/resolve_execution.ts | 46 ++++++++++- .../tests/manual/reference/automation.md | 1 + 20 files changed, 416 insertions(+), 22 deletions(-) create mode 100644 .github/release-notes/v0.5.71.md diff --git a/.github/release-notes/v0.5.71.md b/.github/release-notes/v0.5.71.md new file mode 100644 index 0000000000..781447fbca --- /dev/null +++ b/.github/release-notes/v0.5.71.md @@ -0,0 +1,38 @@ +## Highlights + +- Codex agents can select GPT-6.1 Sol through an OpenAI subscription credential. The model + catalog now records its Responses API requirement, so incompatible native chat and agent + runtimes refuse it before sending a tool request. + [Provider setup](https://docs.tale.dev/platform/admin/providers) +- Subscription broker cooldowns immediately following the same agent's rate-limit failure + no longer consume an extra automated-start allowance. Manager agents can read whether a + failed task run still has a pending automatic retry. + [#4143](https://github.com/tale-project/tale/pull/4143) +- Self-hosted setup gains read-only `tale doctor` diagnostics, more reliable startup and + local host/port handling, and `tale dev --stop` to stop development containers while + preserving their data. Unix and Windows installation guidance includes recovery steps. + [#4142](https://github.com/tale-project/tale/pull/4142) +- Home names a failed chat or task read and offers a retry instead of presenting an empty + result. [#4136](https://github.com/tale-project/tale/pull/4136) +- Cleanup retains file bytes while another live reference still needs them. + [#4129](https://github.com/tale-project/tale/pull/4129) +- Project owners can see why the agent review setting is unavailable and which organization + grant enables it. [#4132](https://github.com/tale-project/tale/pull/4132) +- GitHub and package discovery now point readers to the published guides, and full releases + require authored highlights and upgrade notes before publication. + [#4134](https://github.com/tale-project/tale/pull/4134) + +## Upgrade notes + +- The changes from v0.5.70 add no database migration or required environment variable. Follow + the [self-hosted upgrade guide](https://docs.tale.dev/self-hosted/operate/upgrades) to install + the updated model catalog. +- To use GPT-6.1 Sol with a subscription, configure an OpenAI subscription credential and + choose Codex for the agent. The subscription must include access to this model. Direct chat + uses Chat Completions and does not support this model's tool calls. +- Native task tools use contract 3.15.0. Managers must preserve an armed automatic retry + when `task_get.agentRuns[].retryPending` is `true`; `false` does not authorize a restart, + and a missing field on an older deployment means unknown. Reconcile current task state + and respect provider waits before starting work. +- Release operators must merge the intended version's authored notes before selecting its + candidate. See [the release runbook](https://github.com/tale-project/tale/blob/main/.github/RELEASING.md). diff --git a/configs/platform/system/models/openai/models.yml b/configs/platform/system/models/openai/models.yml index 4f9b4f335f..d6e2f43a53 100644 --- a/configs/platform/system/models/openai/models.yml +++ b/configs/platform/system/models/openai/models.yml @@ -6,6 +6,26 @@ # on 2026-09-20 (Standard, short context). gpt-5.5's cached-input figure is the # OpenRouter listing's (the vendor page no longer lists the model); # gpt-5.5-pro and gpt-5.3-chat-latest publish no cache price. +# Sol 6.1: https://developers.openai.com/api/docs/models/gpt-6.1-sol +# (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 +- id: gpt-6.1-sol + provider: openai + tags: + - chat + supportsTools: true + toolCallingApi: responses + supportsVision: true + reasoning: + knob: effort + contextWindow: 1050000 + maxOutputTokens: 128000 + pricing: + inputCentsPerMillion: 200 + outputCentsPerMillion: 1000 + cacheReadCentsPerMillion: 10 + cacheWriteCentsPerMillion: 250 - id: gpt-5.5 provider: openai tags: diff --git a/docs/de/platform/admin/providers.md b/docs/de/platform/admin/providers.md index 359d09ef85..cf6ca6bd0a 100644 --- a/docs/de/platform/admin/providers.md +++ b/docs/de/platform/admin/providers.md @@ -47,6 +47,8 @@ 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. + Mit **Token-Auswahl** bestimmst du, wie neue Agentendurchläufe verteilt werden: - **Zufällig** ist vorausgewählt. Bei jeder Auswahl haben alle nutzbaren Konten die gleiche Wahrscheinlichkeit. diff --git a/docs/en/platform/admin/providers.md b/docs/en/platform/admin/providers.md index 6f028760af..b7e4227952 100644 --- a/docs/en/platform/admin/providers.md +++ b/docs/en/platform/admin/providers.md @@ -47,6 +47,8 @@ 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. + Choose **Token selection** according to how you want to distribute new agent turns: - **Random**, the initial choice, picks uniformly from the usable accounts for each selection. diff --git a/docs/fr/platform/admin/providers.md b/docs/fr/platform/admin/providers.md index 6e9cb3d17d..01d8b0ec7f 100644 --- a/docs/fr/platform/admin/providers.md +++ b/docs/fr/platform/admin/providers.md @@ -47,6 +47,8 @@ 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. + Choisis **Sélection du jeton** selon la répartition souhaitée pour les nouveaux tours d’agent : - **Aléatoire**, le choix initial, donne à chaque compte utilisable la même probabilité à chaque sélection. diff --git a/packages/shared/src/schemas/providers.test.ts b/packages/shared/src/schemas/providers.test.ts index 3d4bb4870b..5016299af8 100644 --- a/packages/shared/src/schemas/providers.test.ts +++ b/packages/shared/src/schemas/providers.test.ts @@ -311,6 +311,21 @@ describe('providerDefinitionSchema', () => { }); describe('modelCatalogEntrySchema', () => { + it('declares a Responses-only tool API and refuses an unknown wire', () => { + expect( + modelCatalogEntrySchema.safeParse({ + ...VALID_MODEL, + toolCallingApi: 'responses', + }).success, + ).toBe(true); + expect( + modelCatalogEntrySchema.safeParse({ + ...VALID_MODEL, + toolCallingApi: 'unknown', + }).success, + ).toBe(false); + }); + it('accepts a full entry', () => { expect(modelCatalogEntrySchema.safeParse(VALID_MODEL).success).toBe(true); }); diff --git a/packages/shared/src/schemas/providers.ts b/packages/shared/src/schemas/providers.ts index 71041d55cb..eb4d74f137 100644 --- a/packages/shared/src/schemas/providers.ts +++ b/packages/shared/src/schemas/providers.ts @@ -478,6 +478,10 @@ export const modelCatalogEntrySchema = z * `embedding`, `text-to-speech`, …) — open vocabulary, additive. */ tags: z.array(z.string().min(1).max(64)), 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. */ + toolCallingApi: z.literal('responses').optional(), supportsVision: z.boolean(), /** The model GENERATES media (its output modalities include audio, image, * or video — e.g. music or image generators). Such listings often carry a diff --git a/services/platform/backend/core/automations/llm_call.ts b/services/platform/backend/core/automations/llm_call.ts index 153e24928c..e8eccd1569 100644 --- a/services/platform/backend/core/automations/llm_call.ts +++ b/services/platform/backend/core/automations/llm_call.ts @@ -20,6 +20,8 @@ * one wire for thread titles and llm nodes. */ +import type { HarnessGatewayWire } from '@tale/shared/schemas/providers'; + import { compileSchema } from '../../../lib/engine/core/validate/schema'; import { createBuilderModel, @@ -81,8 +83,15 @@ export async function resolveServingTarget( ctx: ActionCtx, organizationId: string, modelId: string, + /** Legacy task agents share this direct-only walk but carry tools. */ + toolCallingWire?: HarnessGatewayWire, ): Promise { - const walk = await walkLlmServing(ctx, organizationId, modelId); + const walk = await walkLlmServing( + ctx, + organizationId, + modelId, + toolCallingWire, + ); if (walk.target !== null) return walk.target; const detail = walk.unreachable.length > 0 @@ -103,9 +112,16 @@ export async function walkLlmServing( ctx: ActionCtx, organizationId: string, modelId: string, + toolCallingWire?: HarnessGatewayWire, ): Promise { const connectors = await resolveProvidersForOrgId(ctx, organizationId); - return walkDirectServing(ctx, organizationId, modelId, connectors); + return walkDirectServing( + ctx, + organizationId, + modelId, + connectors, + toolCallingWire, + ); } const MISS = Symbol('not json'); diff --git a/services/platform/backend/core/chat/external_turn_shared.subscription.test.ts b/services/platform/backend/core/chat/external_turn_shared.subscription.test.ts index 199009e857..261664ce7f 100644 --- a/services/platform/backend/core/chat/external_turn_shared.subscription.test.ts +++ b/services/platform/backend/core/chat/external_turn_shared.subscription.test.ts @@ -6,7 +6,10 @@ import { sanctionSubscriptionHarnessTurn, subscriptionApiBaseUrl, } from '../lib/providers/agent_serving'; -import { loadProviderDefinitions } from '../lib/providers/load_system_config'; +import { + loadProviderDefinitions, + loadStaticCatalogs, +} from '../lib/providers/load_system_config'; import { buildExternalTurnExec } from './external_turn_shared'; const TURN = { @@ -47,11 +50,16 @@ describe('subscription broker delivery through the real external turn builder', ); expect(provider).toBeDefined(); if (provider === undefined) return; + const model = loadStaticCatalogs() + .get('openai') + ?.find((entry) => entry.id === 'gpt-6.1-sol'); + expect(model).toBeDefined(); + if (model === undefined) return; expect( sanctionSubscriptionHarnessTurn({ provider, authMethod: 'subscription-broker', - model: 'gpt-5.4', + model: model.id, harness: 'codex', }), ).toEqual({ ok: true }); @@ -60,7 +68,7 @@ describe('subscription broker delivery through the real external turn builder', const exec = buildExternalTurnExec({ ...TURN, harness: 'codex', - gatewayModel: 'gpt-5.4', + gatewayModel: model.id, serving: { kind: 'subscription', secret: 'synthetic-openai-oauth', @@ -76,6 +84,11 @@ describe('subscription broker delivery through the real external turn builder', ); expect(exec.env.TALE_CONNECTORS_TOKEN).toBe('synthetic-session-bridge'); expect(exec.argv).toContain('model_provider="tale-subscription"'); + expect(exec.argv).toContain( + 'model_providers.tale-subscription.wire_api="responses"', + ); + expect(exec.argv).toContain('gpt-6.1-sol'); + expect(exec.env.OPENAI_API_KEY).toBe(''); expect(exec.argv.join(' ')).not.toContain('synthetic-openai-oauth'); }); }); 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 c50e482ed7..ad11af5201 100644 --- a/services/platform/backend/core/lib/providers/agent_serving.test.ts +++ b/services/platform/backend/core/lib/providers/agent_serving.test.ts @@ -34,7 +34,10 @@ vi.mock('./org_providers', () => ({ })); vi.mock('./load_system_config', () => ({ loadHarnesses })); -import { resolveWorkflowAgentServing } from './agent_serving'; +import { + resolveWorkflowAgentServing, + walkDirectServing, +} from './agent_serving'; const ORG = 'org_agent_serving'; @@ -167,6 +170,23 @@ const ctx = { runQuery } as unknown as ActionCtx; const BROKER = { status: 'active', authMethod: 'subscription-broker' }; const DIRECT = { status: 'active', authMethod: 'api-key' }; +async function shippedOpenAi() { + const actual = await vi.importActual( + './load_system_config', + ); + const provider = actual + .loadProviderDefinitions() + .find((item) => item.name === 'openai'); + if (provider === undefined) + throw new Error('missing shipped OpenAI provider'); + resolveConnectors.mockResolvedValue([provider]); + getProviderCatalog.mockResolvedValue( + actual.loadStaticCatalogs().get('openai'), + ); + loadHarnesses.mockReturnValue(actual.loadHarnesses()); + return provider; +} + beforeEach(() => { vi.clearAllMocks(); credentials = {}; @@ -182,6 +202,65 @@ beforeEach(() => { ]); }); +describe('shipped Sol 6.1 serving', () => { + it('resolves the OpenAI pin through its Codex subscription with the exact vendor model id', async () => { + await shippedOpenAi(); + credentials = { openai: BROKER }; + await expect( + resolveWorkflowAgentServing(ctx, { + organizationId: ORG, + model: 'gpt-6.1-sol', + modelProvider: 'openai', + harness: 'codex', + }), + ).resolves.toMatchObject({ + lane: 'subscription', + providerSlug: 'openai', + modelId: 'gpt-6.1-sol', + apiBaseUrl: 'https://chatgpt.com/backend-api/codex', + vision: { readable: true }, + }); + }); + + it('permits a managed Responses harness and a raw no-tools LLM call', async () => { + const provider = await shippedOpenAi(); + credentials = { openai: DIRECT }; + await expect( + resolveWorkflowAgentServing(ctx, { + organizationId: ORG, + model: 'gpt-6.1-sol', + modelProvider: 'openai', + harness: 'codex', + }), + ).resolves.toMatchObject({ + lane: 'gateway', + providerSlug: 'openai', + modelId: 'gpt-6.1-sol', + }); + await expect( + walkDirectServing(ctx, ORG, 'gpt-6.1-sol', [provider]), + ).resolves.toMatchObject({ + target: { providerSlug: 'openai', modelId: 'gpt-6.1-sol' }, + }); + }); + + it.each([undefined, 'openai'])( + 'refuses a managed chat-wire harness with provider pin %s', + async (modelProvider) => { + await shippedOpenAi(); + credentials = { openai: DIRECT }; + await expect( + resolveWorkflowAgentServing(ctx, { + organizationId: ORG, + model: 'gpt-6.1-sol', + modelProvider, + harness: 'opencode', + }), + ).rejects.toThrow(/cannot serve|no configured provider serves/); + }, + ); +}); + describe('resolveWorkflowAgentServing — direct pass', () => { it('serves a directly-served model on the gateway lane', async () => { credentials = { openrouter: DIRECT }; diff --git a/services/platform/backend/core/lib/providers/agent_serving.ts b/services/platform/backend/core/lib/providers/agent_serving.ts index 77e7973989..cfdd05b761 100644 --- a/services/platform/backend/core/lib/providers/agent_serving.ts +++ b/services/platform/backend/core/lib/providers/agent_serving.ts @@ -41,7 +41,9 @@ import { import { isStandardGatewayProvider } from '../../../../lib/shared/providers/gateway_standard_providers'; import { buildHarnessTable, + harnessToolCallingWire, resolveExecution, + supportsToolCallingWire, } from '../../../../lib/shared/providers/resolve_execution'; import { isRecord } from '../../../../lib/utils/type-utils'; import type { ActionCtx } from '../ctx'; @@ -135,9 +137,9 @@ function readAgentDefaultCredentialRow( return shaped; } -/** The resolver only reads a model's identity; neutral values fill the - * catalog fields it ignores (same convention as the composer's affordance - * probe and the harness status derivation). */ +/** The subscription policy probe tests identity and credential constraints. + * Model tool-wire compatibility is checked against the actual catalog entry + * once that policy has admitted the harness. */ function neutralModelEntry(id: string, provider: string): ModelCatalogEntry { return { id, @@ -271,6 +273,8 @@ export async function walkDirectServing( organizationId: string, modelId: string, connectors: readonly ProviderDefinition[], + /** Absent for a plain no-tools LLM call; agent turns pass their harness wire. */ + toolCallingWire?: HarnessGatewayWire, ): Promise { const unreachable: string[] = []; const rows = new Map(); @@ -297,7 +301,11 @@ export async function walkDirectServing( continue; } const entry = findChatModel(catalog, modelId); - if (entry !== undefined) { + if ( + entry !== undefined && + (toolCallingWire === undefined || + supportsToolCallingWire(entry, toolCallingWire)) + ) { return { target: { providerSlug: connector.name, modelId: entry.id }, unreachable, @@ -322,12 +330,9 @@ export async function walkDirectServing( /** The wire a harness speaks to the sandbox gateway on the managed lane: its * declaration, else derived — a harness that points ANTHROPIC_BASE_URL at the * gateway's `/anthropic` path speaks Anthropic, every other one chat. */ -function harnessGatewayWire(harness: string): HarnessGatewayWire { +export function harnessGatewayWire(harness: string): HarnessGatewayWire { const def = loadHarnesses().find((entry) => entry.slug === harness); - if (def?.gatewayWire !== undefined) return def.gatewayWire; - return def?.credentialEnvKeys.includes('ANTHROPIC_BASE_URL') === true - ? 'anthropic' - : 'openai-chat'; + return harnessToolCallingWire(def); } /** The gateway serving of a client speaking `wire` should ride the @@ -400,9 +405,13 @@ export async function resolvePinnedAgentServing( } if (row.authMethod === 'api-key' || row.authMethod === 'env') { - const walk = await walkDirectServing(ctx, args.organizationId, args.model, [ - connector, - ]); + const walk = await walkDirectServing( + ctx, + args.organizationId, + args.model, + [connector], + harnessGatewayWire(args.harness), + ); if (walk.target !== null) { return { lane: 'gateway', @@ -445,6 +454,11 @@ export async function resolvePinnedAgentServing( `provider "${pinned}" does not list model "${args.model}" in its catalog — edit the agent's model`, ); } + if (!supportsToolCallingWire(entry, harnessGatewayWire(args.harness))) { + throw new Error( + `model "${entry.id}" requires the Responses API for tools; harness "${args.harness}" cannot serve it`, + ); + } // The lane mints no gateway key, so there is no vision polyfill: images // reach the model only if the vendor endpoint forwards them AND the model // reads them. The hosts act on this fact — refusing an image-bearing turn @@ -509,6 +523,7 @@ export async function resolveWorkflowAgentServing( args.organizationId, args.model, connectors, + harnessGatewayWire(args.harness), ); if (direct.target !== null) { const chosen = connectors.find( @@ -561,6 +576,12 @@ export async function resolveWorkflowAgentServing( } const entry = findChatModel(catalog, args.model); if (entry === undefined) continue; + if (!supportsToolCallingWire(entry, harnessGatewayWire(args.harness))) { + refusals.push( + `"${connector.name}": model "${entry.id}" requires the Responses API for tools; harness "${args.harness}" cannot serve it`, + ); + continue; + } const apiBaseUrl = subscriptionApiBaseUrl(connector, row.authMethod); if (apiBaseUrl === undefined) { refusals.push( 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 eaa921f58f..f1405be1b7 100644 --- a/services/platform/backend/core/lib/providers/chat_catalog.test.ts +++ b/services/platform/backend/core/lib/providers/chat_catalog.test.ts @@ -53,6 +53,39 @@ beforeEach(() => { }); describe('walkChatCatalog — model allowlist', () => { + it('offers Responses-only tools through the subscription without enabling native chat or Auto', async () => { + resolveProvidersMock.mockResolvedValue([ + providerDefinitionSchema.parse({ + ...OPENAI, + auth: [ + { method: 'api-key' }, + { method: 'env' }, + { + method: 'subscription-broker', + constraints: { execution: 'sandbox', harness: 'codex' }, + }, + ], + }), + ]); + catalogMock.mockResolvedValue([ + { ...entry('gpt-6.1-sol'), toolCallingApi: 'responses' }, + entry('gpt-5.6-sol'), + ]); + const hits = await walkChatCatalog(ctx, ORG, [ + credential(), + { providerSlug: 'openai', authMethod: 'env' }, + { providerSlug: 'openai', authMethod: 'subscription-broker' }, + ]); + expect( + hits.map((hit) => [hit.credential.authMethod, hit.entry.id]), + ).toEqual([ + ['api-key', 'gpt-5.6-sol'], + ['env', 'gpt-5.6-sol'], + ['subscription-broker', 'gpt-6.1-sol'], + ['subscription-broker', 'gpt-5.6-sol'], + ]); + }); + 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 05b5ad8c62..cd51db6f25 100644 --- a/services/platform/backend/core/lib/providers/chat_catalog.ts +++ b/services/platform/backend/core/lib/providers/chat_catalog.ts @@ -24,6 +24,7 @@ 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'; @@ -108,6 +109,16 @@ 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. + if ( + (credential.authMethod === 'api-key' || + credential.authMethod === 'env') && + !supportsToolCallingWire(entry, 'openai-chat') + ) + continue; hits.push({ connector, credential, credentialAuth, entry }); } } 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 189873ec87..dcbe92c49f 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 @@ -128,6 +128,31 @@ describe('shipped providers', () => { }); describe('shipped static model catalogs', () => { + it('ships Sol 6.1 for Responses tool calls without an unsupported reasoning off value', () => { + const model = loadStaticCatalogs() + .get('openai') + ?.find((entry) => entry.id === 'gpt-6.1-sol'); + expect(model).toMatchObject({ + id: 'gpt-6.1-sol', + provider: 'openai', + tags: ['chat'], + supportsTools: true, + supportsVision: true, + toolCallingApi: 'responses', + contextWindow: 1_050_000, + maxOutputTokens: 128_000, + reasoning: { knob: 'effort' }, + pricing: { + inputCentsPerMillion: 200, + outputCentsPerMillion: 1000, + cacheReadCentsPerMillion: 10, + cacheWriteCentsPerMillion: 250, + }, + }); + expect(model?.reasoning?.off).toBeUndefined(); + expect(model?.reasoning?.toolsRequireOff).toBeUndefined(); + }); + it('every catalog entry validates and carries its file provider', () => { const catalogs = loadStaticCatalogs(); expect(catalogs.size).toBeGreaterThan(0); diff --git a/services/platform/backend/core/tasks/task_serving.test.ts b/services/platform/backend/core/tasks/task_serving.test.ts index 25c5a68339..e40d921107 100644 --- a/services/platform/backend/core/tasks/task_serving.test.ts +++ b/services/platform/backend/core/tasks/task_serving.test.ts @@ -166,6 +166,7 @@ describe('resolveTaskServing — gateway lane', () => { ctx, ORG, 'anthropic/claude-sonnet-4.6', + 'openai-chat', ); }); diff --git a/services/platform/backend/core/tasks/task_serving.ts b/services/platform/backend/core/tasks/task_serving.ts index f2e9fac4c0..4c2cfae035 100644 --- a/services/platform/backend/core/tasks/task_serving.ts +++ b/services/platform/backend/core/tasks/task_serving.ts @@ -17,13 +17,14 @@ * close). * * Unpinned agents (rows saved before the picker carried providers) keep the - * legacy direct-only connector walk byte-for-byte via - * {@link resolveServingTarget}. + * legacy direct-only connector walk via {@link resolveServingTarget}, with + * their harness's tool wire checked just as for a pinned agent. */ import { resolveServingTarget } from '../automations/llm_call'; import type { ActionCtx } from '../lib/ctx'; import { + harnessGatewayWire, resolvePinnedAgentServing, type AgentTurnServing, } from '../lib/providers/agent_serving'; @@ -49,6 +50,7 @@ export async function resolveTaskServing( ctx, args.organizationId, args.model, + harnessGatewayWire(args.harness), ); return { lane: 'gateway', ...target }; } diff --git a/services/platform/lib/chat/turn.test.ts b/services/platform/lib/chat/turn.test.ts index 823887811b..9995c68e97 100644 --- a/services/platform/lib/chat/turn.test.ts +++ b/services/platform/lib/chat/turn.test.ts @@ -888,6 +888,30 @@ 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 }); + const outcome = await runTurn( + request({ + model: { ...MODEL, toolCallingApi: 'responses' }, + executionMode: 'direct', + }), + d.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([]); + }); + it('refuses before the model call when the credential forbids the mode', async () => { const model = vi.fn(); const d = deps({ model: model as unknown as ModelCall }); diff --git a/services/platform/lib/shared/providers/resolve_execution.test.ts b/services/platform/lib/shared/providers/resolve_execution.test.ts index 708cd304f6..067ead0c45 100644 --- a/services/platform/lib/shared/providers/resolve_execution.test.ts +++ b/services/platform/lib/shared/providers/resolve_execution.test.ts @@ -99,6 +99,49 @@ describe('resolveExecution — direct mode', () => { }); }); +describe('resolveExecution — tool API compatibility', () => { + const model = { ...MODEL, toolCallingApi: 'responses' as const }; + const codex = { + ...harness('codex', { managed: true, byo: true }), + gatewayWire: 'openai-responses' as const, + }; + const table = buildHarnessTable([...HARNESSES.values(), codex]); + + it('allows Responses tools on a managed or subscription Codex harness', () => { + for (const credential of [ + API_KEY, + { + authMethod: 'subscription-broker' as const, + constraints: { execution: 'sandbox' as const, harness: 'codex' }, + }, + ]) { + expect( + resolveExecution( + { model, credential, mode: 'sandbox', harness: 'codex' }, + table, + ), + ).toMatchObject({ mode: 'sandbox', harness: { slug: 'codex' } }); + } + }); + + it('refuses Responses tools on a managed Chat Completions harness', () => { + expect( + resolveExecution( + { + model, + credential: API_KEY, + mode: 'sandbox', + harness: 'opencode', + }, + table, + ), + ).toMatchObject({ + mode: 'refused', + reason: expect.stringContaining('Responses'), + }); + }); +}); + describe('resolveExecution — subscription-key (static plan/portal keys)', () => { it('refuses direct exactly like the broker flavor', () => { const result = resolve({ credential: SUBSCRIPTION_KEY, mode: 'direct' }); diff --git a/services/platform/lib/shared/providers/resolve_execution.ts b/services/platform/lib/shared/providers/resolve_execution.ts index e63efaf460..38625a1479 100644 --- a/services/platform/lib/shared/providers/resolve_execution.ts +++ b/services/platform/lib/shared/providers/resolve_execution.ts @@ -25,6 +25,8 @@ * 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. * * Refusal reasons are user-facing API — actionable one-liners naming the * offending piece and the way out. @@ -35,6 +37,7 @@ import type { ExecutionConstraints, HarnessDefinition, + HarnessGatewayWire, ModelCatalogEntry, } from '@tale/shared/schemas/providers'; @@ -78,6 +81,29 @@ export function buildHarnessTable( return new Map(harnesses.map((harness) => [harness.slug, harness])); } +/** 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. */ +export function supportsToolCallingWire( + model: Pick, + wire: HarnessGatewayWire, +): boolean { + return model.toolCallingApi !== 'responses' || wire === 'openai-responses'; +} + +/** Harness declarations predate the explicit wire field. Keep their one + * fallback rule beside the capability check, shared with gateway routing. */ +export function harnessToolCallingWire( + harness: HarnessDefinition | undefined, +): HarnessGatewayWire { + return ( + harness?.gatewayWire ?? + (harness?.credentialEnvKeys.includes('ANTHROPIC_BASE_URL') === true + ? 'anthropic' + : 'openai-chat') + ); +} + export type ExecutionResolution = | { readonly mode: 'direct' } | { readonly mode: 'sandbox'; readonly harness: HarnessDefinition } @@ -102,6 +128,7 @@ function acceptSandboxHarness( slug: string, posture: SandboxPosture, harnesses: HarnessTable, + model: ModelCatalogEntry, ): ExecutionResolution { const harness = harnesses.get(slug); if (!harness) { @@ -109,6 +136,11 @@ function acceptSandboxHarness( `Unknown harness "${slug}" — available harnesses: ${knownHarnessList(harnesses)}.`, ); } + if (!supportsToolCallingWire(model, harnessToolCallingWire(harness))) { + return refused( + `Model "${model.id}" requires the Responses API for tools; harness "${slug}" does not use it. Select a Responses-capable harness.`, + ); + } switch (posture) { case 'managed': if (!harness.credentialPolicy.managed) { @@ -149,6 +181,11 @@ export function resolveExecution( // gateway key, so both modes are open; sandbox runs managed. 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) { @@ -156,7 +193,12 @@ export function resolveExecution( `Sandbox execution needs a harness for model "${model.id}" — select one of: ${knownHarnessList(harnesses)}.`, ); } - return acceptSandboxHarness(selection.harness, 'managed', harnesses); + return acceptSandboxHarness( + selection.harness, + 'managed', + harnesses, + model, + ); } default: { const _exhaustive: never = mode; @@ -182,7 +224,7 @@ export function resolveExecution( `This subscription credential only runs on the "${forced}" harness; "${selection.harness}" cannot use it. Select "${forced}", or pick an api-key or env credential.`, ); } - return acceptSandboxHarness(forced, 'byo', harnesses); + return acceptSandboxHarness(forced, 'byo', harnesses, model); } default: { const _exhaustive: never = mode; diff --git a/services/platform/tests/manual/reference/automation.md b/services/platform/tests/manual/reference/automation.md index c12f3010f9..cf20f43ec7 100644 --- a/services/platform/tests/manual/reference/automation.md +++ b/services/platform/tests/manual/reference/automation.md @@ -42,6 +42,7 @@ 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) | 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 |