Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions containers/api-proxy/management.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const {
} = require('./model-api-mapping');
const { isModelPermittedByPolicy } = require('./guards/model-policy-guard');
const { normalizeModel } = require('./routing-catalogue');
const { getReasoningScope } = require('./model-reasoning');
const { getModelRoutingChoices } = require('./routing-candidates');
const { reflectScopedAuto } = require('./scoped-auto-model');
const { projectModelDecisionDiagnostics } = require('./model-decision-diagnostics');
Expand All @@ -43,7 +44,7 @@ function filterModelCatalogue(entries, provider, modelPolicy, getModel) {
});
}

function buildRoutingModelMetadata(provider, modelIds, runtimeRecords) {
function buildRoutingModelMetadata(provider, modelIds, runtimeRecords, scope) {
if (!Array.isArray(modelIds)) return null;
const runtimeById = new Map(
(Array.isArray(runtimeRecords) ? runtimeRecords : [])
Expand All @@ -52,9 +53,12 @@ function buildRoutingModelMetadata(provider, modelIds, runtimeRecords) {
);
return modelIds.map(id => {
const runtime = runtimeById.get(id.toLowerCase());
const maintained = lookupModelRoutingMetadata(id, provider);
const maintained = scope?.deployment === undefined &&
(scope?.channel === undefined || scope.channel === 'native-api')
? lookupModelRoutingMetadata(id, provider)
: null;
const endpointMapping = lookupModelEndpoints(id, provider);
const normalized = normalizeModel(id, runtime, provider);
const normalized = normalizeModel(id, runtime, provider, scope);
const efforts = Array.isArray(normalized.efforts) ? normalized.efforts : null;
const endpoints = Array.isArray(runtime?.supportedEndpoints)
? runtime.supportedEndpoints
Expand Down Expand Up @@ -182,6 +186,11 @@ function createManagementHandlers(deps) {
const reflection = {
endpoints: getAdapters().map(adapter => {
const info = adapter.getReflectionInfo();
const scope = getReasoningScope(
adapter.name,
adapter.getTargetHost?.(),
adapter.getTargetScheme?.(),
);
const providerModels = info.models_cache_key !== null
? (cachedModels[info.models_cache_key] || null)
: null;
Expand Down Expand Up @@ -221,6 +230,7 @@ function createManagementHandlers(deps) {
adapter.name,
models,
privateRoutingModelMetadata,
scope,
),
models_url: info.models_url,
...(info.credential_kind !== undefined && { credential_kind: info.credential_kind }),
Expand Down
32 changes: 32 additions & 0 deletions containers/api-proxy/management.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,38 @@ describe('routing metadata in /reflect', () => {
},
]);
});

it('does not expose maintained reasoning or context metadata for a custom target', () => {
const adapter = {
name: 'openai',
getTargetHost: () => 'router.example.com',
getTargetScheme: () => 'https',
getReflectionInfo: () => ({
provider: 'openai', port: 10000, configured: true, models_cache_key: 'openai',
}),
};
const result = createManagementHandlers({
getAdapters: () => [adapter],
getCachedModels: () => ({ openai: ['gpt-5.4-mini'] }),
getRuntimeModelMetadata: () => ({ openai: [] }),
getRoutingModelMetadata: () => ({ openai: [] }),
isModelFetchComplete: () => true,
getModelAliases: () => null,
getModelFallback: () => null,
getEffectiveModelFallback: () => ({}),
getAiCreditsUsage: () => ({}),
getMaxRunsUsage: () => ({}),
getMaxCacheMissesUsage: () => ({}),
getPermissionDeniedUsage: () => ({}),
}).reflectEndpoints();

expect(result.endpoints[0].routing_models[0]).toMatchObject({
model_id: 'gpt-5.4-mini',
source: 'incomplete',
supported_reasoning_efforts: null,
context_window_tokens: null,
});
});
});

describe('model policy filtering in /reflect', () => {
Expand Down
2 changes: 2 additions & 0 deletions containers/api-proxy/model-api-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ function lookupModelRoutingMetadata(model, provider) {
endpoints: [...entry.endpoints],
reasoningEfforts: [...routing.reasoningEfforts],
contextWindowTokens: routing.contextWindowTokens,
...(routing.reasoningMode === undefined ? {} : { reasoningMode: routing.reasoningMode }),
...(routing.defaultEffort === undefined ? {} : { defaultEffort: routing.defaultEffort }),
};
}

Expand Down
113 changes: 107 additions & 6 deletions containers/api-proxy/model-api-mapping.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Model-to-API Endpoint Mapping",
"description": "Maps AI model families to supported API endpoints and includes maintained task-routing effort/context metadata for selected model IDs.",
"lastUpdated": "2026-11-08T22:25:19Z",
"lastUpdated": "2026-11-09T00:10:26Z",
"sources": {
"openai": "https://developers.openai.com/api/docs/models",
"openai_routing": "https://developers.openai.com/api/docs/models/gpt-5.4",
Expand Down Expand Up @@ -140,6 +140,48 @@
],
"notes": "Supports both endpoints. Listed on the official GPT-5.5 model page. gpt-5.5-pro is responses-only (see separate entry above)."
},
{
"family": "gpt-5.4-mini",
"patterns": [
"gpt-5.4-mini*"
],
"routingPatterns": [
"gpt-5.4-mini",
"gpt-5.4-mini-2026-03-17"
],
"endpoints": [
"chat_completions",
"responses"
],
"routing": {
"reasoningEfforts": [
"none",
"low",
"medium",
"high",
"xhigh"
],
"contextWindowTokens": 400000,
"reasoningMode": "optional",
"defaultEffort": "none"
},
"routingEvidence": {
"at": "2026-11-09T00:09:52.371Z",
"scope": {
"provider": "openai",
"channel": "native-api"
},
"sources": [
"https://developers.openai.com/api/docs/models/gpt-5.4-mini"
],
"modelIds": [
"gpt-5.4-mini",
"gpt-5.4-mini-2026-03-17"
],
"conditions": "Native OpenAI API model-page window, not a guaranteed remaining input budget or a Copilot/Codex/custom-deployment limit. The page lists none (default), low, medium, high and xhigh and the recorded snapshot."
},
"notes": "Independently reviewed GPT-5.4 mini effort/context facts; exact routing IDs only. No pro/cyber/research/preview/nano or future dated variants inherit them. Default is metadata, not request insertion."
},
{
"family": "gpt-5.4",
"patterns": [
Expand All @@ -163,7 +205,7 @@
],
"contextWindowTokens": 1050000
},
"notes": "Supports both endpoints on OpenAI. GPT-5.4 routing metadata is exact-model only; mini/nano variants need separately verified data. The model page lists none, low, medium, high, and xhigh reasoning effort and a 1,050,000-token context window."
"notes": "Supports both endpoints on OpenAI. GPT-5.4 routing metadata is exact-model only; mini has separately reviewed data and nano remains unverified. The model page lists none, low, medium, high, and xhigh reasoning effort and a 1,050,000-token context window."
},
{
"family": "gpt-5.3-codex",
Expand Down Expand Up @@ -637,15 +679,54 @@
},
"notes": "Best combination of speed and intelligence with verified 1M-token context windows and the Anthropic effort parameter."
},
{
"family": "claude-opus-4-6",
"patterns": [
"claude-opus-4-6"
],
"routingPatterns": [
"claude-opus-4-6"
],
"endpoints": [
"messages"
],
"routing": {
"reasoningEfforts": [
"low",
"medium",
"high",
"max"
],
"contextWindowTokens": 1000000,
"reasoningMode": "optional",
"defaultEffort": "high"
},
"routingEvidence": {
"at": "2026-11-09T00:10:26.467Z",
"scope": {
"provider": "anthropic",
"channel": "native-api"
},
"sources": [
"https://platform.claude.com/docs/en/build-with-claude/effort",
"https://platform.claude.com/docs/en/build-with-claude/context-windows",
"https://github.com/anthropics/ClaudeForFoundationModels/blob/0262e1a766c461a4268dcec656eca95dd74cebf8/Sources/ClaudeForFoundationModels/ClaudeModel.swift"
],
"modelIds": [
"claude-opus-4-6"
],
"conditions": "Top-level output_config.effort on the native Messages API; high is equivalent to omission. Opus 4.6 supports max but not xhigh. Native 1M total context is default without a beta header; request-size and output/thinking tokens still constrain usable input."
},
"notes": "Reviewed Opus 4.6 separately from 4.7/4.8. No xhigh support; no inferred dated IDs or specialized variants. Default is metadata, not request insertion."
},
{
"family": "claude-opus-4",
"patterns": [
"claude-opus-4*"
],
"routingPatterns": [
"claude-opus-4-8",
"claude-opus-4-7",
"claude-opus-4-6"
"claude-opus-4-7"
],
"endpoints": [
"messages"
Expand All @@ -655,11 +736,31 @@
"low",
"medium",
"high",
"xhigh",
"max"
],
"contextWindowTokens": 1000000
"contextWindowTokens": 1000000,
"reasoningMode": "optional",
"defaultEffort": "high"
},
"routingEvidence": {
"at": "2026-11-09T00:10:26.467Z",
"scope": {
"provider": "anthropic",
"channel": "native-api"
},
"sources": [
"https://platform.claude.com/docs/en/build-with-claude/effort",
"https://platform.claude.com/docs/en/build-with-claude/context-windows",
"https://github.com/anthropics/ClaudeForFoundationModels/blob/0262e1a766c461a4268dcec656eca95dd74cebf8/Sources/ClaudeForFoundationModels/ClaudeModel.swift"
],
"modelIds": [
"claude-opus-4-7",
"claude-opus-4-8"
],
"conditions": "Top-level output_config.effort on the native Messages API; high is equivalent to omission, while xhigh is a coding recommendation, not the default. Native 1M total context is default without a beta header; request-size and output/thinking tokens still constrain usable input."
},
"notes": "Opus 4.6 and newer models have verified 1M-token context windows and support the Anthropic effort parameter."
"notes": "Reviewed exact Opus 4.7/4.8 effort/context facts. Opus 4.6 has a separate negative-xhigh record; broad endpoint patterns do not grant routing support to other revisions."
},
{
"family": "claude-sonnet-4",
Expand Down
5 changes: 4 additions & 1 deletion containers/api-proxy/model-api-mapping.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ describe('model-api-mapping', () => {
reasoningEfforts: ['none', 'low', 'medium', 'high', 'xhigh'],
contextWindowTokens: 1_050_000,
});
expect(lookupModelRoutingMetadata('gpt-5.4-mini', 'openai')).toBeNull();
expect(lookupModelRoutingMetadata('gpt-5.4-mini', 'openai')).toMatchObject({
reasoningEfforts: ['none', 'low', 'medium', 'high', 'xhigh'],
contextWindowTokens: 400_000, reasoningMode: 'optional', defaultEffort: 'none',
});
expect(lookupModelRoutingMetadata('o3', 'openai')).toBeNull();
expect(lookupModelRoutingMetadata('gpt-5.4-2026-03-05', 'openai'))
.toMatchObject({ contextWindowTokens: 1_050_000 });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"catalogRevision": "c00be1b161139479fc9ce4e6f7dc9786cc864588261cb4152a812a82a62a5829",
"catalogRevision": "8b85e0ae761c3e9c971f3c3018349cb5ae6aec731ae7aefb94ebe9255826799a",
"compatibility": {
"policy": "legacy_native_compatibility",
"channel": "native-api",
Expand Down
19 changes: 12 additions & 7 deletions containers/api-proxy/model-metadata-characterization.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe('model identity is intentionally different between consumers', () => {
});

it.each([
['gpt-5.4-mini', 'openai'],
['gpt-5.4-mini', 'openai', true],
['gpt-5.5', 'openai'],
['gpt-5.6', 'openai'],
['gpt-5.6-sol', 'openai'],
Expand All @@ -162,21 +162,26 @@ describe('model identity is intentionally different between consumers', () => {
['gpt-6-astra', 'openai'],
['gpt-6-luna', 'openai'],
['claude-haiku-5-5', 'anthropic'],
])('#10030: %s currently has no maintained routing choices', (model, provider) => {
expect(lookupModelRoutingMetadata(model, provider)).toBeNull();
])('#10030: %s has only explicitly activated routing facts', (model, provider, active = false) => {
if (active) {
expect(lookupModelRoutingMetadata(model, provider)).toMatchObject({
reasoningEfforts: ['none', 'low', 'medium', 'high', 'xhigh'], contextWindowTokens: 400_000,
});
} else expect(lookupModelRoutingMetadata(model, provider)).toBeNull();
});

it.each([
['claude-opus-5', 'anthropic'],
['claude-opus-5-5', 'anthropic'],
['claude-sonnet-5', 'anthropic'],
['claude-sonnet-5-5', 'anthropic'],
['claude-opus-4-7', 'anthropic'],
['claude-opus-4-8', 'anthropic'],
])('#10030: %s routing metadata currently omits xhigh', (model, provider) => {
['claude-opus-4-7', 'anthropic', true],
['claude-opus-4-8', 'anthropic', true],
['claude-opus-4-6', 'anthropic'],
])('#10030: %s has revision-specific xhigh coverage', (model, provider, xhigh = false) => {
const routing = lookupModelRoutingMetadata(model, provider);
expect(routing).not.toBeNull();
expect(routing.reasoningEfforts).not.toContain('xhigh');
expect(routing.reasoningEfforts.includes('xhigh')).toBe(xhigh);
});
});

Expand Down
2 changes: 2 additions & 0 deletions containers/api-proxy/model-reasoning.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ function resolveModelReasoning(model, provider, { records = getRuntimeModels(pro
identity: resolution.identity, scope, active: true, authority: 'maintained',
support: mapped.reasoningEfforts.length ? 'supported' : 'unsupported',
rawEfforts: mapped.reasoningEfforts,
mode: mapped.reasoningMode,
default: mapped.defaultEffort,
provenance: { authority: 'maintained', source: 'model-api-mapping',
at: getModelApiMapping()?.lastUpdated, field: 'routing.reasoningEfforts' },
});
Expand Down
19 changes: 12 additions & 7 deletions containers/api-proxy/model-reasoning.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('shared direct and routing reasoning adapters', () => {

it.each([
['gpt-5.4', 'openai', 'supported'],
['gpt-5.4-mini', 'openai', 'absent'],
['gpt-5.4-mini', 'openai', 'supported'],
['gpt-5.5-pro', 'openai', 'absent'],
['gpt-5.6-sol', 'openai', 'absent'],
['claude-opus-4-6', 'anthropic', 'supported'],
Expand All @@ -146,9 +146,14 @@ describe('shared direct and routing reasoning adapters', () => {
])('uses only reviewed active evidence for specialized %s on %s', (model, provider, support) => {
const decision = resolveModelReasoning(model, provider, { records: [] });
expect(decision.support).toBe(support);
expect(decision.mode).toBe('unknown');
expect(decision).not.toHaveProperty('default');
if (provider === 'anthropic') expect(decision.supportedEfforts).not.toContain('xhigh');
const reviewed = (provider === 'openai' && model === 'gpt-5.4-mini') ||
(provider === 'anthropic' && /^claude-opus-4-[678]$/.test(model));
expect(decision.mode).toBe(reviewed ? 'optional' : 'unknown');
if (reviewed) expect(decision.default).toBe(provider === 'openai' ? 'none' : 'high');
else expect(decision).not.toHaveProperty('default');
if (provider === 'anthropic') {
expect(decision.supportedEfforts.includes('xhigh')).toBe(/^claude-opus-4-[78]$/.test(model));
}
});

it('does not apply native maintained evidence to custom deployments or targets', () => {
Expand All @@ -167,14 +172,14 @@ describe('shared direct and routing reasoning adapters', () => {
}).support).toBe('absent');
});

it('does not reject direct efforts omitted from maintained native routing lists', () => {
it('now selects reviewed xhigh for Opus 4.7/4.8 while rejecting it for 4.6', () => {
for (const model of ['claude-opus-4-7', 'claude-opus-4-8']) {
const decision = getRequestReasoning(model, 'anthropic', { anthropic: [] }, {}, {
targetHost: 'api.anthropic.com',
});
expect(decision.support).toBe('supported');
expect(decision.supportedEfforts).not.toContain('xhigh');
expect(assessReasoningEffort(decision, 'xhigh', { automatic: true }).admitted).toBe(false);
expect(decision.supportedEfforts).toContain('xhigh');
expect(assessReasoningEffort(decision, 'xhigh', { automatic: true }).admitted).toBe(true);
expect(assessReasoningEffort(decision, 'xhigh', {
directMaintainedEfforts: ['xhigh'],
}).admitted).toBe(true);
Expand Down
Loading
Loading