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
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,17 @@ async function fetchGatewayModels(gateway: Provider) {
);
}
const endpoints = EndpointsSchema.parse(await endpointsResponse.json());
const { reasoning, ...modelMetadata } = model;
result[model.id] = {
...model,
...modelMetadata,
...(reasoning && {
reasoning: {
mandatory: reasoning.mandatory,
...(reasoning.supported_efforts && {
supported_efforts: reasoning.supported_efforts,
}),
},
}),
endpoints: endpoints.data.endpoints,
};
})
Expand Down
79 changes: 78 additions & 1 deletion packages/db/src/schema-types.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { describe, expect, it } from '@jest/globals';
import { CodeReviewCouncilConfigSchema, OrganizationSettingsSchema } from './schema-types';
import {
CodeReviewCouncilConfigSchema,
ModelsSchema,
OrganizationSettingsSchema,
StoredModelSchema,
} from './schema-types';
import type { StoredModel } from './schema-types';

describe('CodeReviewCouncilConfigSchema', () => {
const specialist = (id: string) => ({
Expand Down Expand Up @@ -66,3 +72,74 @@ describe('OrganizationSettingsSchema org_auto_model', () => {
expect(result.success).toBe(false);
});
});

describe('ModelsSchema', () => {
it('preserves only supported reasoning metadata', () => {
const result = ModelsSchema.parse({
data: [
{
id: 'openai/gpt-5.2',
name: 'OpenAI: GPT-5.2',
reasoning: {
mandatory: false,
supported_efforts: ['high', 'medium', 'low', 'none'],
default_enabled: true,
default_effort: 'medium',
},
},
],
});

expect(result.data[0].reasoning).toEqual({
mandatory: false,
supported_efforts: ['high', 'medium', 'low', 'none'],
});
});

it('allows reasoning metadata without supported efforts', () => {
const result = ModelsSchema.parse({
data: [
{
id: 'google/gemini-2.5-pro',
name: 'Google: Gemini 2.5 Pro',
reasoning: { mandatory: true },
},
],
});

expect(result.data[0].reasoning).toEqual({ mandatory: true });
});

it('drops invalid reasoning metadata', () => {
const result = ModelsSchema.parse({
data: [
{
id: 'example/future-effort',
name: 'Future Effort',
reasoning: {
mandatory: false,
supported_efforts: ['future'],
},
},
],
});

expect(result.data[0].reasoning).toBeUndefined();
});
});

describe('StoredModelSchema', () => {
it('includes model reasoning metadata', () => {
const storedModel: StoredModel = {
id: 'openai/gpt-5.2',
name: 'OpenAI: GPT-5.2',
reasoning: {
mandatory: false,
supported_efforts: ['high', 'medium', 'low', 'none'],
},
endpoints: [],
};

expect(StoredModelSchema.parse(storedModel).reasoning).toEqual(storedModel.reasoning);
});
});
7 changes: 7 additions & 0 deletions packages/db/src/schema-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2025,6 +2025,13 @@ export const ModelSchema = z.object({
id: z.string(),
name: z.string(),
type: z.enum(['language', 'embedding', 'image']).optional().catch(undefined),
reasoning: z
.object({
mandatory: z.boolean(),
supported_efforts: z.array(ReasoningEffortSchema).optional(),
})
.optional()
.catch(undefined),
});

export const ModelsSchema = z.object({ data: z.array(ModelSchema) });
Expand Down