← Back to PRs

#10608: fix(agents): honor spawn model override in gateway and session spawn tool

by 1kuna open 2026-02-06 18:35 View on GitHub →
app: web-ui gateway commands agents stale
## Summary - Accept optional model override on the gateway agent method and apply it to the session before running. - Forward sessions_spawn resolved model into the agent call when the patch succeeds. ## Root Cause sessions_spawn only patched the session model; the agent call did not carry the model, so new subagent runs could proceed with defaults if the session entry wasn't read as expected at run start. ## Changes - Added optional `model` to gateway agent params schema (`src/gateway/protocol/schema/agent.ts`) - Applied/validated model overrides in `src/gateway/server-methods/agent.ts` before persisting session entry - Forwarded resolved model to agent call when `sessions.patch` succeeds in `src/agents/tools/sessions-spawn-tool.ts` - Added `sessionEntry` passthrough to `AgentCommandOpts` and `resolveSession` so the gateway can inject the pre-resolved entry - Added test for model override threading in `agent.test.ts` ## Testing - `pnpm tsgo`: ✓ clean compilation - `vitest run src/gateway/server-methods/agent.test.ts`: ✓ 4/4 tests pass (includes new model override test) Supersedes #9365 (which had unresolved merge conflict markers). Closes #5369 Closes #9771 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> - Adds an optional `model` parameter to the gateway `agent` method and applies it by updating the resolved session entry before dispatch. - Threads the resolved `sessionEntry` into `agentCommand`/`resolveSession` so model overrides take effect immediately. - Updates `sessions_spawn` to forward the resolved model into the gateway `agent` call when the session patch succeeds. - Extends gateway tests to cover model override threading into `agentCommand`. <h3>Confidence Score: 5/5</h3> - This PR appears safe to merge with minimal risk. - Changes are scoped to threading a model override through existing session resolution paths, with explicit validation against the gateway model catalog and a new unit test covering the new behavior; no behavioral regressions were identified in the modified call paths. - src/gateway/server-methods/agent.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs