Skip to content

Auto model selection for the root thread - #1443

Draft
hary73 wants to merge 3 commits into
test/routing-plus-age-2841from
hary/root-auto
Draft

hary73 wants to merge 3 commits into
test/routing-plus-age-2841from
hary/root-auto

Conversation

@hary73

@hary73 hary73 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes AGE-2853

Part of AGE-2873 (spec) and AGE-2875 (default policy)

Stacked on #1390 (subagent routing) and #1426 (persist each thread's model), through the combined branch test/routing-plus-age-2841, so this diff shows only root auto mode.

Changes

  • An agent spec can set its model to auto. The root is routed on every turn: the decision model sees the conversation's user and assistant text (attachment names and types instead of contents) and classifies the new user message.
  • The root runs on the cheapest model and effort in the chosen category. If routing cannot choose a model, the turn fails. A rebuilt turn resumes on the root's saved model.
  • The conversation is trimmed to fit the decision model's context length, using the existing token estimators.
  • auto is accepted only when model routing is enabled for the tenant (checked when an agent or session spec is validated).
  • TRUEFOUNDRY_MODEL_ROUTING now covers subagents and auto roots: the per-tenant subagent key is renamed to enabled, so existing configs need updating.

How was this tested?

  • Unit tests: autoModel.test.ts (root and subagent routing), router, UserInputMessage, config and sessionResources tests.
  • Manually against devtest: an auto session routed each turn to a different model as the conversation changed.

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, python/trueforge_sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

hary73 and others added 2 commits November 20, 2026 09:55
An auto spec classifies the conversation on each new turn and runs on the chosen model's defaults at the routed effort. A failed classification fails the turn, and a rebuilt turn resumes on the saved model.

Co-authored-by: Cursor <cursoragent@cursor.com>
…nd test the root and subagent routing paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
}

/** The tenant's routing entry when that tenant has model routing on. */
export function enabledTenantModelRouting(routing: TrueFoundryModelRouting | undefined, tenant_id: string) {

@datadog-official datadog-official Bot Nov 20, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Low: Code Quality Violation

Suggested change
export function enabledTenantModelRouting(routing: TrueFoundryModelRouting | undefined, tenant_id: string) {
export function enabledTenantModelRouting(routing: TrueFoundryModelRouting | undefined, tenantId: string) {
Use 'camelCase' and not 'snake_case' or 'PascalCase' (...read more)

Ensure that parameter names use camelCase and not snake_case or PascalCase.

Helpful? 👍/👎 View in Datadog  Leave us feedback  Documentation
🚩 Report as false positive. Flags the rule for review to improve detection accuracy.

@datadog-official

datadog-official Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Code Quality  Code Vulnerabilities  IaC  Library Vulnerabilities  Secrets

⚠️ Warnings

🛠️ 1 Code quality issue detected

Low: typescript-code-style/parameter-name Parameter name should use camelCase View rule
packages/trueforge/src/config.ts:1569

ℹ️ Info

No other issues found (see more)

🛡️ No new code vulnerabilities
📚 No new vulnerable libraries detected
🧱 No new Infrastructure as Code (IaC) issues
🔑 No new secrets detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: adbd248 | Docs | Give us feedback!

…licitly.

Co-authored-by: Cursor <cursoragent@cursor.com>
/** Reasoning effort the thread should run at. */
effort: ReasoningEffort;
/** Reasoning effort the thread should run at; undefined keeps the model's default. */
effort: ReasoningEffort | undefined;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we store effort as well for rebuilds

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant