Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore
  • Loading branch information
sanchitrk committed Sep 1, 2026
commit 8aec00e380a6c1b6ec011df7f7d1b76a251169f9
4 changes: 4 additions & 0 deletions packages/aikit/src/model/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const ActiveThinkingLevel = Type.Union([
]);
export type ActiveThinkingLevel = Static<typeof ActiveThinkingLevel>;

// Note: order of entries matters!
const ACTIVE_THINKING_LEVELS = [
ThinkingLevelEnum.minimal,
ThinkingLevelEnum.low,
Expand Down Expand Up @@ -311,10 +312,13 @@ export function clampThinkingLevel<TProtocol extends KnownProviderEnum>(
const requestedIndex = MODEL_THINKING_LEVELS.indexOf(level);
if (requestedIndex === -1) return availableLevels[0] ?? "off";

// walk up the ladder from the point and pick first supported
// biased to avail more thinking, then less not round to nearest.
for (let i = requestedIndex; i < MODEL_THINKING_LEVELS.length; i++) {
const candidate = MODEL_THINKING_LEVELS[i]!;
if (availableLevels.includes(candidate)) return candidate;
}
// otherwise walk down from the point
for (let i = requestedIndex - 1; i >= 0; i--) {
const candidate = MODEL_THINKING_LEVELS[i]!;
if (availableLevels.includes(candidate)) return candidate;
Expand Down
1 change: 1 addition & 0 deletions packages/aikit/test/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe("Model.normalizeInput", () => {
expect(Model.normalizeInput(["text", "text", "image", "image"])).toEqual(["text", "image"]);
});

// FIXME: no fallback to known modalities; keep what's only supported.
it("falls back to text when only unknown modalities are given", () => {
expect(Model.normalizeInput(["audio"])).toEqual(["text"]);
});
Expand Down
8 changes: 4 additions & 4 deletions packages/aikit/test/modelgen.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { describe, expect, it } from "vite-plus/test";
import Value from "typebox/value";
import { describe, expect, it } from "vite-plus/test";
import { generateModels as generateModelsImplementation, openAICodexBuiltInModels } from "../src/cli/modelgen.ts";
import { generateModels } from "../src/modelgen.ts";
import * as Model from "../src/model/model.ts";
import { generateModels } from "../src/modelgen.ts";

describe("openAICodexBuiltInModels", () => {
it("exposes catalog generation through the public modelgen entry", () => {
expect(generateModels).toBe(generateModelsImplementation);
});

it("includes Pi's current explicit Codex model list", () => {
it("includes explicit Codex model list", () => {
const models = openAICodexBuiltInModels();

expect(Object.keys(models)).toEqual([
Expand Down Expand Up @@ -41,7 +41,7 @@ describe("openAICodexBuiltInModels", () => {
}
});

it("maps Pi's Codex deferred-tool capability flags", () => {
it("maps Codex deferred-tool capability flags", () => {
const models = openAICodexBuiltInModels();

expect(models["gpt-5.3-codex-spark"]?.compat).toEqual({ supportsOpenAIGrammarTools: true });
Expand Down