Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 3adbb05 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: Cursor <cursoragent@cursor.com>
…ing, routing trace keys) Co-authored-by: Cursor <cursoragent@cursor.com>
…ad_id Co-authored-by: Cursor <cursoragent@cursor.com>
…hreshold Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
42ed3b4 to
88b3379
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
| models: mapEnabledModels({ | ||
| integrations, | ||
| ...(input.filter !== undefined ? { modelTypes: ['chat', 'decision'] } : {}), | ||
| }), |
There was a problem hiding this comment.
Decision model blocked by allowlist
Medium Severity
Jev is resolved through getProvider, which runs filterEnvModels. A tenant with TRUEFOUNDRY_TENANT_ID_TO_ALLOWED_MODEL_PROVIDER_ACCOUNTS that omits Jev's account (typesafe in the example) will fail every decision lookup. Routing then always falls back to the parent's model with no distinct signal that the decision model was filtered out.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 97a4952. Configure here.
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2766586. Configure here.
| return input.mode === 'on' ? { model: picked.candidate.model } : {}; | ||
| } catch (error) { | ||
| return fallback(timeout.aborted ? 'decision_timeout' : 'decision_error', { err: error }); | ||
| } |
There was a problem hiding this comment.
Cancel during routing still spawns
Medium Severity
When the turn abort signal fires during routing, the router catches it and returns a fallback instead of propagating cancellation. makeCreateDynamicSubAgentThread then always continues into resolveAgentDefinition and builds the child thread, so a cancelled turn can still spawn a subagent.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 2766586. Configure here.
…bilities Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>


Summary
When a subagent is spawned, one call to Jev (the TrueFoundry decision model) rates each of the caller's scored models for the task. The subagent runs on the highest-rated one. It's off by default and configured per tenant:
shadowlogs the pick and keeps the parent's model, andonruns the pick. This is a PoC for internal tenants in TrueFoundry mode.Design: the LLD was reviewed on this branch and isn't merged. Last version: lld.md at 7c2a7d2.
Related:
tfg.thread_idon model calls, which routing analysis joins on.THREAD_CREATEDrecord and the inherited params are AGE-2841. It's needed beforeonmode, not forshadow.Changes
Core (
trueforge-core)routeModelhook onITurnResourceResolver, accepted byTurnResourceResolver.makeCreateDynamicSubAgentThreadcalls it when thecreate_sub_agentrequest has no model, and continues with the returned model through the existingrequest.modelpath.Server: provider-neutral routing (
src/modelRouting/)types.ts:RoutingCandidate,DecisionClientand the modes.modelRoutingScores.ts+scores.ts: the Artificial Analysis Intelligence Index v5 per slug, and the lookup by slug and effort. Variants match exactly: the exact effort, else the plain slug, else the nearest effort.pick.ts: highest yes-probability, with the cheaper model winning a tie.benchmarks.ts: the nine Intelligence Index evaluations Jev is asked about for resemblance (logged only), with descriptions quoted from their official pages.router.ts: builds the questions, calls the decision client, picks and logs one line. It never throws, and on any failure the subagent runs on the parent's model.Server: TrueFoundry mode
listRoutingCandidates()onIModelProviderStore, implemented by the TrueFoundry store and forwarded by the inline store.mapEnabledModelsreads the slug, default effort, price and image input. Each new field falls back to undefined on an unexpected shape, so model listing can't break.jevDecisionClient.ts:POST {gateway}/v1/systemonewith Jev's own gateway config (the store's by-name lookup now resolves decision-type models; listings stay chat-only) and the turn metadata, plustfg.thread_id.TRUEFOUNDRY_MODEL_ROUTINGconfig (timeout, candidate cap, and per tenant: mode and decision model), wired inapis/turns.ts.Invariants to check
SessionHandle.makeCreateDynamicSubAgentThreadmodelRouting/router.ts(questions,state)modelRouting/pick.tsmodelRouting/router.tsrouter.ts(scoredCandidates),TrueFoundryModelProviderStore.listRoutingCandidatesmodelRouting/modelRoutingScores.ts,scores.tsscores.ts(lookupScore),mapEnabledModels.tsrouter.ts(thetry/catch); router testrouter.ts; router testrequest.modelpath. Saving it onTHREAD_CREATEDfor resume is AGE-2841, not this PR.SessionHandle.tsrouteModel. Routing logic lives in the server, split into provider-neutral code (modelRouting/) and TrueFoundry-specific code (truefoundry/).ITurnResourceResolver.tsTrueFoundryModelProviderStore.#records; store testmapEnabledModels.ts(.catch(undefined))TRUEFOUNDRY_MODEL_ROUTINGwith modeshadoworon, in TrueFoundry mode.apis/turns.ts(subagentModelRouter),config.tstfg.thread_id, plus one info log line per decision. No new tables, schema or public API.jevDecisionClient.ts,router.tsHow was this tested?
Unit tests:
One existing assertion was relaxed to
objectContaining.trueforge-coreandtrueforgetypecheck and the full unit suites pass. ESLint and Prettier are clean on the changed files.A live check against internal, with a throwaway script that isn't committed:
Checklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locally (rantrueforge-coreandtrueforgetypecheck and unit tests, plus lint and format on the changed files).env.exampleupdated for the new configurationNote
Medium Risk
Touches turn execution and subagent LLM selection with external gateway calls; mitigated by default-off config, shadow mode, timeouts, and fail-open fallback to the parent model.
Overview
Adds optional per-tenant subagent model routing in TrueFoundry mode. Before a dynamic subagent starts (when no model is set on the request), an optional
routeModelhook onITurnResourceResolvercan choose a model; core wires this inSessionHandle.makeCreateDynamicSubAgentThreadand passes the result through the existingrequest.modelpath.On the server,
TRUEFOUNDRY_MODEL_ROUTINGconfigures routing per tenant (off/shadow/on), timeout, candidate cap, and a gateway decision model (Jev). The router scores the caller’s models using bundled Artificial Analysis index data, asks Jev yes/no questions per candidate, picks the highest probability (cheaper on ties), and never throws—failures keep the parent’s model.shadowlogs the pick without changing the model;onruns the pick.Supporting pieces include
listRoutingCandidateson the model provider store, TrueFoundry catalog metadata (slug, effort, price), a Jev client to/v1/systemone, and unit tests for the router and decision-model listing behavior.Reviewed by Cursor Bugbot for commit 3adbb05. Bugbot is set up for automated code reviews on this repo. Configure here.