Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

Expose model reasoning efforts as a typed ReasoningEffort enum.

debajyoti-truefoundryb4d3ee1053ef
diff --git a/fern/openapi/openapi.json b/fern/openapi/openapi.json
index 6266ee462..33a138129 100644
--- a/fern/openapi/openapi.json
+++ b/fern/openapi/openapi.json
@@ -2026,8 +2026,7 @@
},
"reasoning_efforts": {
"items": {
- "minLength": 1,
- "type": "string"
+ "$ref": "#/components/schemas/ReasoningEffort"
},
"minItems": 1,
"type": "array"
@@ -2266,6 +2265,19 @@
}
]
},
+ "ReasoningEffort": {
+ "enum": [
+ "provider-default",
+ "none",
+ "minimal",
+ "low",
+ "medium",
+ "high",
+ "xhigh",
+ "max"
+ ],
+ "type": "string"
+ },
"RequestErrorResponse": {
"properties": {
"error": {
diff --git a/packages/harness/src/core/llm/VercelAILLM.ts b/packages/harness/src/core/llm/VercelAILLM.ts
index f390662c6..dbab2f972 100644
--- a/packages/harness/src/core/llm/VercelAILLM.ts
+++ b/packages/harness/src/core/llm/VercelAILLM.ts
@@ -219,7 +219,7 @@ export function normalizeUsage(usage: {
*/
type ReasoningLevel = NonNullable<LanguageModelCallOptions['reasoning']>;
-const REASONING_LEVELS: readonly ReasoningLevel[] = [
+const REASONING_LEVELS = [
'provider-default',
'none',
'minimal',
@@ -227,20 +227,21 @@ const REASONING_LEVELS: readonly ReasoningLevel[] = [
'medium',
'high',
'xhigh',
-];
+] as const satisfies readonly ReasoningLevel[];
function isReasoningLevel(v: string): v is ReasoningLevel {
- return (REASONING_LEVELS as readonly string[]).includes(v);
+ return REASONING_LEVELS.some(level => level === v);
}
/**
* Efforts the SDK's union cannot express. `xhigh` is its ceiling, so `max` rides in as `xhigh`;
* Anthropic's adapter raises that back, and {@link maxEffortOption} covers the rest.
+ * Keys here must also appear in {@link SUPPORTED_REASONING_EFFORTS}.
*/
const EFFORT_ALIASES: Readonly<Record<string, ReasoningLevel>> = { max: 'xhigh' };
/** What a model may advertise in `reasoning_efforts`; anything else resolves to the provider default. */
-export const SUPPORTED_REASONING_EFFORTS: readonly string[] = [...REASONING_LEVELS, ...Object.keys(EFFORT_ALIASES)];
+export const SUPPORTED_REASONING_EFFORTS = [...REASONING_LEVELS, 'max'] as const;
/**
* The effort travels on the top-level `reasoning` setting, which each adapter translates per model:
diff --git a/packages/sdk/.fern/metadata.json b/packages/sdk/.fern/metadata.json
index c3b3e74a3..4af02da79 100644
--- a/packages/sdk/.fern/metadata.json
+++ b/packages/sdk/.fern/metadata.json
@@ -27,10 +27,9 @@
"streamType": "web",
"useDefaultRequestParameterValues": true
},
- "originGitCommit": "eab25dc9e6f0b57dd676d78befe0a33b5dbda76d",
+ "originGitCommit": "a705c065ed5092ed4614fdef53f558dab3e764aa",
"originGitCommitIsDirty": true,
- "invokedBy": "ci",
+ "invokedBy": "manual",
"requestedVersion": "0.0.0",
- "ciProvider": "github",
"sdkVersion": "0.0.0"
}
diff --git a/packages/sdk/src/api/types/ModelProperties.ts b/packages/sdk/src/api/types/ModelProperties.ts
index 93bc6f02d..11f897915 100644
--- a/packages/sdk/src/api/types/ModelProperties.ts
+++ b/packages/sdk/src/api/types/ModelProperties.ts
@@ -1,7 +1,9 @@
// This file was auto-generated by Fern from our API Definition.
+import type * as TrueForge from "../index.js";
+
export interface ModelProperties {
contextLength?: number;
maxOutputTokens?: number;
- reasoningEfforts?: string[];
+ reasoningEfforts?: TrueForge.ReasoningEffort[];
}
diff --git a/packages/sdk/src/api/types/ReasoningEffort.ts b/packages/sdk/src/api/types/ReasoningEffort.ts
new file mode 100644
index 000000000..e7c2e4fa8
--- /dev/null
+++ b/packages/sdk/src/api/types/ReasoningEffort.ts
@@ -0,0 +1,13 @@
+// This file was auto-generated by Fern from our API Definition.
+
+export const ReasoningEffort = {
+ ProviderDefault: "provider-default",
+ None: "none",
+ Minimal: "minimal",
+ Low: "low",
+ Medium: "medium",
+ High: "high",
+ Xhigh: "xhigh",
+ Max: "max",
+} as const;
+export type ReasoningEffort = (typeof ReasoningEffort)[keyof typeof ReasoningEffort];
diff --git a/packages/sdk/src/api/types/index.ts b/packages/sdk/src/api/types/index.ts
index d1c07853e..e3c5ba184 100644
--- a/packages/sdk/src/api/types/index.ts
+++ b/packages/sdk/src/api/types/index.ts
@@ -108,6 +108,7 @@ export * from "./PutModelProviderResponse.js";
export * from "./PutSandboxProviderResponse.js";
export * from "./PutSkillResponse.js";
export * from "./RawToolCall.js";
+export * from "./ReasoningEffort.js";
export * from "./RequestErrorResponse.js";
export * from "./RequestErrorResponseError.js";
export * from "./ResourceName.js";
diff --git a/packages/sdk/src/serialization/types/ModelProperties.ts b/packages/sdk/src/serialization/types/ModelProperties.ts
index f48be306c..a8493dd6b 100644
--- a/packages/sdk/src/serialization/types/ModelProperties.ts
+++ b/packages/sdk/src/serialization/types/ModelProperties.ts
@@ -3,6 +3,7 @@
import type * as TrueForge from "../../api/index.js";
import * as core from "../../core/index.js";
import type * as serializers from "../index.js";
+import { ReasoningEffort } from "./ReasoningEffort.js";
export const ModelProperties: core.serialization.ObjectSchema<
serializers.ModelProperties.Raw,
@@ -12,7 +13,7 @@ export const ModelProperties: core.serialization.ObjectSchema<
maxOutputTokens: core.serialization.property("max_output_tokens", core.serialization.number().optional()),
reasoningEfforts: core.serialization.property(
"reasoning_efforts",
- core.serialization.list(core.serialization.string()).optional(),
+ core.serialization.list(ReasoningEffort).optional(),
),
});
@@ -20,6 +21,6 @@ export declare namespace ModelProperties {
export interface Raw {
context_length?: number | null;
max_output_tokens?: number | null;
- reasoning_efforts?: string[] | null;
+ reasoning_efforts?: ReasoningEffort.Raw[] | null;
}
}
diff --git a/packages/sdk/src/serialization/types/ReasoningEffort.ts b/packages/sdk/src/serialization/types/ReasoningEffort.ts
new file mode 100644
index 000000000..43f054c3c
--- /dev/null
+++ b/packages/sdk/src/serialization/types/ReasoningEffort.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as TrueForge from "../../api/index.js";
+import * as core from "../../core/index.js";
+import type * as serializers from "../index.js";
+
+export const ReasoningEffort: core.serialization.Schema<serializers.ReasoningEffort.Raw, TrueForge.ReasoningEffort> =
+ core.serialization.enum_(["provider-default", "none", "minimal", "low", "medium", "high", "xhigh", "max"]);
+
+export declare namespace ReasoningEffort {
+ export type Raw = "provider-default" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
+}
diff --git a/packages/sdk/src/serialization/types/index.ts b/packages/sdk/src/serialization/types/index.ts
index d1c07853e..e3c5ba184 100644
--- a/packages/sdk/src/serialization/types/index.ts
+++ b/packages/sdk/src/serialization/types/index.ts
@@ -108,6 +108,7 @@ export * from "./PutModelProviderResponse.js";
export * from "./PutSandboxProviderResponse.js";
export * from "./PutSkillResponse.js";
export * from "./RawToolCall.js";
+export * from "./ReasoningEffort.js";
export * from "./RequestErrorResponse.js";
export * from "./RequestErrorResponseError.js";
export * from "./ResourceName.js";
diff --git a/packages/server/src/runtime/sessionResources.ts b/packages/server/src/runtime/sessionResources.ts
index c0f30041e..ead021b36 100644
--- a/packages/server/src/runtime/sessionResources.ts
+++ b/packages/server/src/runtime/sessionResources.ts
@@ -291,7 +291,7 @@ export async function validateAgentSpec({
const reasoningEffort = spec.model.params?.reasoning_effort;
if (reasoningEffort !== undefined) {
const efforts = model.properties.reasoning_efforts;
- if (!efforts?.includes(reasoningEffort)) {
+ if (!efforts?.some(effort => effort === reasoningEffort)) {
throw new HTTPException(422, {
message: efforts
? `Reasoning effort "${reasoningEffort}" is not supported by model "${spec.model.name}"`
diff --git a/packages/server/src/schemas/modelProvider.ts b/packages/server/src/schemas/modelProvider.ts
index c0c424095..5a183585d 100644
--- a/packages/server/src/schemas/modelProvider.ts
+++ b/packages/server/src/schemas/modelProvider.ts
@@ -12,21 +12,15 @@ export const ProviderTypeSchema = z.enum(VERCEL_AI_PROVIDER_NAMES).openapi('Prov
export type ProviderType = z.infer<typeof ProviderTypeSchema>;
+export const ReasoningEffortSchema = z.enum(SUPPORTED_REASONING_EFFORTS).openapi('ReasoningEffort');
+
+export type ReasoningEffort = z.infer<typeof ReasoningEffortSchema>;
+
export const ModelPropertiesSchema = z
.object({
context_length: z.number().int().positive().optional(),
max_output_tokens: z.number().int().positive().optional(),
- reasoning_efforts: z
- .array(
- z
- .string()
- .min(1)
- .refine(effort => SUPPORTED_REASONING_EFFORTS.includes(effort), {
- message: `Reasoning effort must be one of: ${SUPPORTED_REASONING_EFFORTS.join(', ')}`,
- }),
- )
- .min(1)
- .optional(),
+ reasoning_efforts: z.array(ReasoningEffortSchema).min(1).optional(),
})
.strict()
.openapi('ModelProperties');
diff --git a/packages/server/tests/unit/runtime/sessionResources.test.ts b/packages/server/tests/unit/runtime/sessionResources.test.ts
index 3fa7f49bd..e5882e5ce 100644
--- a/packages/server/tests/unit/runtime/sessionResources.test.ts
+++ b/packages/server/tests/unit/runtime/sessionResources.test.ts
@@ -8,9 +8,10 @@ import { SqliteModelProviderStore } from '../../../src/db/sqlite/model-provider-
import { SqliteSandboxProviderStore } from '../../../src/db/sqlite/sandbox-provider-store/SqliteSandboxProviderStore';
import { SqliteSkillStore } from '../../../src/db/sqlite/skill-store/SqliteSkillStore';
import { validateAgentSpec } from '../../../src/runtime/sessionResources';
+import type { ReasoningEffort } from '../../../src/schemas/modelProvider';
describe('validateAgentSpec', () => {
- async function setup(options?: { reasoningEfforts?: string[] | undefined }) {
+ async function setup(options?: { reasoningEfforts?: ReasoningEffort[] | undefined }) {
const db = createSqliteDb(':memory:');
await migrateSqliteToLatest(db);
const modelProviderStore = new SqliteModelProviderStore(db);