Skip to content

Commit 6613762

Browse files
hary73cursoragent
andcommitted
Reject model params on an auto spec, and stop documenting a configurable routing question.
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent d6b6dae commit 6613762

5 files changed

Lines changed: 34 additions & 7 deletions

File tree

‎.changeset/root-auto-model.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
'@truefoundry/trueforge': patch
44
---
55

6-
Add auto model selection for the root thread. An agent whose spec model is `auto` is accepted only when model routing is enabled for the tenant, and its root is routed on every turn: the classifier sees the conversation's user and assistant text, with attachment names and content types instead of file contents, and the new user message. The root runs on the cheapest model and effort in the chosen cluster. If routing cannot choose a model, the turn fails. A rebuilt turn resumes on the root's saved model.
6+
Add auto model selection for the root thread. An agent whose spec model is `auto` is accepted only when model routing is enabled for the tenant, and it cannot carry model params. Its root is routed on every turn: the classifier sees the conversation's user and assistant text, with attachment names and content types instead of file contents, and the new user message. The root runs on the cheapest model and effort in the chosen cluster. If routing cannot choose a model, the turn fails. A rebuilt turn resumes on the root's saved model.

‎packages/trueforge/.env.example‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ POSTGRES_PORT=5432
309309

310310
## Optional model routing for subagents and `auto` root agents (JSON object). A decision model classifies each
311311
## task or conversation, and the category picks the model it runs on. Per tenant: enabled off (default) | on, and
312-
## the tenant's own decision model on its gateway (account/model). Optional "instructions" and "categories"
313-
## ({"direct","fixed_steps","adaptive"}: all three) override the decision model's question; unset uses the tested defaults.
312+
## the tenant's own decision model on its gateway (account/model). Optional "categories"
313+
## ({"direct","fixed_steps","adaptive"}: all three) override what each category means; unset uses the tested defaults.
314314
# TRUEFOUNDRY_MODEL_ROUTING={"tenants":{"internal":{"enabled":"on","decision_model":"typesafe/jev-1.13.0"}}}
315315

316316
## Internal mutual TLS for calls to the ServiceFoundry server. When true, trueforge presents its client

‎packages/trueforge/src/config.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,8 +1140,8 @@ export type DistributedServerConfiguration = SharedServerConfiguration & {
11401140
TRUEFOUNDRY_TENANT_ID_TO_ALLOWED_MODEL_PROVIDER_ACCOUNTS: Record<string, string[]>;
11411141
/**
11421142
* Optional model routing for subagents and `auto` root agents (TrueFoundry mode only). JSON object with optional
1143-
* `instructions` and `categories` overriding the decision model's question, and per-tenant entries:
1144-
* `enabled` (`off` | `on`) and the tenant's decision model. Unset, or a tenant not listed → off.
1143+
* `categories` overriding what each routing category means, and per-tenant entries: `enabled` (`off` | `on`) and
1144+
* the tenant's decision model. Unset, or a tenant not listed → off.
11451145
* Env: `TRUEFOUNDRY_MODEL_ROUTING`.
11461146
*/
11471147
TRUEFOUNDRY_MODEL_ROUTING: TrueFoundryModelRouting | undefined;
@@ -1564,8 +1564,8 @@ export function trueFoundryModelRouting(
15641564
}
15651565

15661566
/** The tenant's routing entry when that tenant has model routing on. */
1567-
export function enabledTenantModelRouting(routing: TrueFoundryModelRouting | undefined, tenant_id: string) {
1568-
const tenant = routing?.tenants[tenant_id];
1567+
export function enabledTenantModelRouting(routing: TrueFoundryModelRouting | undefined, tenantId: string) {
1568+
const tenant = routing?.tenants[tenantId];
15691569
if (tenant?.enabled !== 'on') {
15701570
return undefined;
15711571
}

‎packages/trueforge/src/runtime/sessionResources.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ export async function validateAgentSpec({
313313
message: 'Model "auto" requires model routing to be enabled for this tenant',
314314
});
315315
}
316+
if (spec.model.params !== undefined && Object.keys(spec.model.params).length > 0) {
317+
throw new HTTPException(422, {
318+
message: 'Model "auto" does not accept model params',
319+
});
320+
}
316321
} else {
317322
const resolved = await getModelDetails({
318323
tenant_id,

‎packages/trueforge/tests/unit/runtime/sessionResources.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,28 @@ describe('validateAgentSpec', () => {
189189
).resolves.toBeUndefined();
190190
});
191191

192+
it('rejects params on an auto model', async () => {
193+
const stores = await setup();
194+
const modelRouting = parseTrueFoundryModelRouting(
195+
JSON.stringify({ tenants: { default: { enabled: 'on', decision_model: 'typesafe/jev-1.13.0' } } }),
196+
);
197+
await expect(
198+
validateAgentSpec({
199+
spec: AgentSpecSchema.parse({
200+
model: { name: 'auto', params: { temperature: 0.2, reasoning_effort: 'high' } },
201+
instructions: 'test',
202+
}),
203+
tenant_id: 'default',
204+
created_by_subject_id: 'test-subject',
205+
...stores,
206+
modelRouting,
207+
}),
208+
).rejects.toMatchObject({
209+
status: 422,
210+
message: 'Model "auto" does not accept model params',
211+
} satisfies Partial<HTTPException>);
212+
});
213+
192214
it('rejects malformed model FQN with 422', async () => {
193215
const stores = await setup();
194216
await expect(

0 commit comments

Comments
 (0)