Repository navigation
Route a thread's first turn to a provider/model by task tier - #1592
Conversation
A thread can carry a pending route ("auto" or fast/balanced/strong) that
its first turn consumes. Auto classifies the prompt with a keyword and
length heuristic. The tier maps to an agent profile through the project's
new modelRouting setting. The profile's provider, model and effort are
applied, but never its permission mode. The transcript gets an event that
says what was picked and why, or why nothing changed.
Entry points:
- Composer: an Auto row in the model picker before the first turn. A
manual pick clears it.
- Projects: per-tier profile selects plus "Start new threads on Auto".
- Automations: an optional tier; provider/model stays as the fallback.
- thread_fork: an optional tier for orchestrators. A pinned pool still
wins.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 13ac8821e7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| provider: profile.provider, | ||
| model: profile.model, | ||
| }); | ||
| if (profile.reasoningEffort) { |
There was a problem hiding this comment.
Reset effort when the routed profile requests default
When a project also supplies a non-null threadDefaults.reasoningEffort, a routed profile whose reasoningEffort is null never applies its documented provider-default setting because this conditional skips the setter. setProvider preserves the old effort whenever the routed provider/model supports it, so a fast profile can unexpectedly run at high effort and cost, or a strong profile can retain a lower effort. Call setReasoningEffort with null as well.
Useful? React with 👍 / 👎.
| if (thread.route != null) { | ||
| const routed = applyRoute(store, threadId, prompt); |
There was a problem hiding this comment.
Consume pending routes when a workflow starts
This applies routing only through startRun, but a fresh thread can take its first turn through startWorkflowRun (electron/runner.js:2243). Workflow sessions are stored on phase agents rather than thread.sessionId, so after the workflow finishes the route remains pending and the composer still shows Auto; the next ordinary message is then incorrectly classified and routed even though it is not the thread's first turn. The workflow entry point should consume or explicitly clear the pending route.
Useful? React with 👍 / 👎.
| const { parseProviderRef } = require("./providerInstances.js"); | ||
| const base = parseProviderRef(profile.provider).provider; | ||
| if (!services.providerInstalledFor(project, base)) { |
There was a problem hiding this comment.
Reject named provider instances for remote routes
When a remote project maps a tier to a named-instance profile such as claude:work, providerInstalledFor deliberately returns true for every remote provider and setProvider accepts the local instance, so routing reports success and consumes the route. The same startRun then rejects any providerInstance when crossesBoundary(projectForGate) is true, causing every routed first turn to fail instead of retaining the fallback model as promised. Detect the parsed instance for remote/WSL projects before applying the profile.
Useful? React with 👍 / 👎.
…ick-provider-model-per-ta-16ce1e # Conflicts: # electron/services-settings.js # src/components/AutomationsView.tsx # src/shared/ipc.ts
What
A thread can now hold a pending route that its first turn uses up:
auto, or one of the tiersfast/balanced/strong. The route chooses the thread's provider, model and reasoning effort from an agent profile before anything readsthread.provider. It never changes the permission mode. A tier is about cost and capability, not about how much the agent may do unattended.electron/routing.js(new):classifyPrompt:autopicks a tier using keywords plus prompt length. It makes no model call.strong: prompts that mention things like refactor, debug, security or performance, or are ≥1500 chars.fast: short chores like typo, rename, lint or bump, ≤400 chars.balanced: everything else.applyRoute: maps the tier to an agent profile through the project's newmodelRoutingsetting and applies it.runner.js: callsapplyRoutebefore the first turn runs.services-threads.js:setRouteservice. It refuses to route a thread that already has a session.createThreadusesroute: "auto"when the project has opted into Auto. It skips this for automations, memory consolidation and ask threads, threads with an explicit provider, and threads that opt out of project defaults.Entry points
modelRoutingon the project).thread_fork(orchestrator MCP): an optionaltierargument (auto|fast|balanced|strong). A pinned (force) worker pool still takes priority.Tests
electron/test/model-routing-tiers.test.js: covers classification and route application.test/modelPicker.test.ts: covers the Auto row.🤖 Generated with Claude Code