fix(gateway): use default agent model for session defaults#50210
Conversation
Greptile SummaryThis PR fixes a bug in The fix is a focused one-liner: Key changes:
Confidence Score: 4/5
Last reviewed commit: "Gateway: use default..." |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3799485f90
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2d0e254a91
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const contextTokens = | ||
| cfg.agents?.defaults?.contextTokens ?? |
There was a problem hiding this comment.
Resolve session default contextTokens from the selected agent
This now resolves defaults.model from the requested/default agent, but defaults.contextTokens still comes from cfg.agents?.defaults?.contextTokens. In configs where the selected agent overrides model.primary (or has its own context cap), sessions.list will return a mixed pair: agent B's model with the global/default-agent context window. src/tui/tui-status-summary.ts:54-59 renders these fields together as the “Default model” line, so filtered views and single-agent installs can advertise the wrong context size. The runtime path already resolves caps as agentCfg?.contextTokens ?? lookupContextTokens(model) in src/auto-reply/reply/model-selection.ts:603-609, so getSessionDefaults() should derive the cap from the same effective agent config.
Useful? React with 👍 / 👎.
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open: this targets a real gateway/UI default-model bug, but the branch is stale, conflicted, lacks real behavior proof, and now misses current-main sessions.list paths and default metadata behavior. Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Yes, source-level. Current main still builds sessions.list defaults from global configured defaults while Control UI uses those defaults for its Default (...) model label and option list; I did not run a live Control UI repro in this read-only review. Is this the best way to solve the issue? No. The main direction is right, but the branch needs a current-main rebase, complete default metadata handling, async sessions.list coverage, hook-scope split, and real behavior proof before it is the best fix. Security review: Security review needs attention: The gateway fix itself is not security-sensitive, but the PR also changes hook handler path selection in a command-execution boundary.
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against ff79299d68e3. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
ClawSweeper applied the proposed close for this PR.
|
Summary
Fixes #50156.
sessions.list.defaultswas resolving the fallback model from the global hardcoded default path, which ignored the default agent's effectivemodel.primary. In Control UI this surfaced as a misleading extra "Default (...)" choice when a single configured agent had its own primary model.This changes
getSessionDefaults()to resolve throughresolveDefaultModelForAgent()using the repo's default agent id, so the gateway reports the same primary model the default agent will actually run.Changes
src/gateway/session-utils.ts: resolve session defaults from the default agent's effective model instead of the hardcoded global fallback path.src/gateway/session-utils.test.ts: add a regression test covering a default agent withmodel.primary = minimax/MiniMax-M2.5and no globalagents.defaults.model.primary.Test plan
pnpm exec oxfmt --check src/gateway/session-utils.ts src/gateway/session-utils.test.tspnpm test -- src/gateway/session-utils.test.ts -t "getSessionDefaults prefers the default agent primary model over the hardcoded fallback"node_modules/@mariozechner/pi-aiis still linked to0.54.1, so the suite fails during import on@mariozechner/pi-ai/oauthbefore the test runs.AI-assisted
This PR was authored with AI assistance. I reviewed the change and verified the root cause in code before submitting.