fix(subagent): inherit parent model in tool-agent route instead of hardcoding deepseek-v4-flash#2736
Conversation
…rdcoding deepseek-v4-flash `tool_agent_route` hardcoded `model: "deepseek-v4-flash"`, so routing a ToolAgent sub-agent fails with a 404 on any backend or provider that doesn't serve that exact model id (self-hosted inference servers, non-DeepSeek vendors). The tool-agent fast-lane behaviour is defined by `reasoning_effort = off`, not by a specific model, so inherit the parent session's model from the runtime. This is a no-op for DeepSeek setups (the parent model is already a DeepSeek id) and fixes tool-agent routing everywhere else.
|
Thanks @h3c-hexin for taking the time to contribute. This repository is currently observing a maintainer-managed contribution gate in dry-run mode, so this pull request is staying open. When enforcement is enabled, pull requests from contributors who are not listed in Please read |
There was a problem hiding this comment.
Code Review
This pull request updates the subagent routing logic to inherit the parent session's model from the runtime instead of hardcoding a specific DeepSeek model. The reviewer feedback suggests that the updated tool_agent_route should also accept and respect the configured_model parameter if explicitly provided, falling back to the runtime model only when no explicit model is configured.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| ) -> SubAgentResolvedRoute { | ||
| if matches!(agent_type, SubAgentType::ToolAgent) { | ||
| return tool_agent_route(); | ||
| return tool_agent_route(runtime); |
There was a problem hiding this comment.
The current implementation of tool_agent_route completely ignores the configured_model parameter and always falls back to runtime.model. If a user explicitly configures a model for the tool agent (e.g., via configuration or tool arguments), it should be respected. We should pass configured_model to tool_agent_route so it can be used if present.
return tool_agent_route(runtime, configured_model);| fn tool_agent_route(runtime: &SubAgentRuntime) -> SubAgentResolvedRoute { | ||
| SubAgentResolvedRoute { | ||
| model: "deepseek-v4-flash".to_string(), | ||
| // Inherit the parent session's model instead of hardcoding a DeepSeek | ||
| // model id: the tool-agent "fast lane" semantics come from | ||
| // `reasoning_effort = off`, not from a specific model. Hardcoding | ||
| // `deepseek-v4-flash` makes tool-agent routing fail with a 404 on any | ||
| // backend or provider that doesn't serve that exact model id. | ||
| model: runtime.model.clone(), | ||
| reasoning_effort: Some("off".to_string()), | ||
| } | ||
| } |
There was a problem hiding this comment.
Update tool_agent_route to accept and respect configured_model if it is explicitly provided, falling back to runtime.model only when no explicit model is configured.
Note: If you apply this change, the test tool_agent_route_forces_flash_with_thinking_off in tests.rs (which passes Some("deepseek-v4-pro".to_string()) as configured_model but asserts route.model == "deepseek-v4-flash") will need to be updated, as it will now correctly resolve to "deepseek-v4-pro".
fn tool_agent_route(
runtime: &SubAgentRuntime,
configured_model: Option<String>,
) -> SubAgentResolvedRoute {
SubAgentResolvedRoute {
// Inherit the parent session's model instead of hardcoding a DeepSeek
// model id: the tool-agent "fast lane" semantics come from
// `reasoning_effort = off`, not from a specific model. Hardcoding
// `deepseek-v4-flash` makes tool-agent routing fail with a 404 on any
// backend or provider that doesn't serve that exact model id.
model: configured_model.unwrap_or_else(|| runtime.model.clone()),
reasoning_effort: Some("off".to_string()),
}
}| // `deepseek-v4-flash` makes tool-agent routing fail with a 404 on any | ||
| // backend or provider that doesn't serve that exact model id. | ||
| model: runtime.model.clone(), | ||
| reasoning_effort: Some("off".to_string()), |
There was a problem hiding this comment.
reasoning_effort = off may still reject on non-DeepSeek backends
The PR correctly fixes the 404 caused by the hardcoded model id, but reasoning_effort: Some("off") is still sent unconditionally. On OpenAI-compatible servers or other non-DeepSeek providers that do not recognise reasoning_effort, this field may cause a 400/422 rejection, leaving the ToolAgent path broken for the exact backends this fix is targeting. Since the field is already Option<String> elsewhere in the struct, returning None here (or making it conditional on whether the model is known to support it) would make the fix complete for the general backend case.
Problem
tool_agent_route()hardcodesmodel: "deepseek-v4-flash". Routing aToolAgentsub-agent therefore issues an API request fordeepseek-v4-flashregardless of the parent session's model. On any backend or provider that doesn't serve that exact model id (self-hosted inference servers, non-DeepSeek providers), the call fails with a 404 and the tool-agent path is unusable.Fix
Inherit the parent session's model from
runtime.model. The tool-agent "fast lane" semantics come fromreasoning_effort = off, not from a specific model id, so dropping the hardcoded model preserves the intended behaviour.Scope
One function (
tool_agent_route) + its single caller inresolve_subagent_assignment_route.reasoning_effort: offunchanged. The separatesubagent_flash_router(auto-model router) is intentionally left untouched.Greptile Summary
This PR fixes
tool_agent_routeso thatToolAgentsub-agents inherit the parent session's model viaruntime.modelinstead of hardcoding"deepseek-v4-flash", preventing 404 errors on any backend that does not serve that exact model id.tool_agent_route()now accepts&SubAgentRuntimeand clonesruntime.model;reasoning_effort = offis preserved unchanged to maintain the fast-lane semantics.resolve_subagent_assignment_routeis updated to passruntimethrough to the new signature; all other routing paths are untouched.Confidence Score: 3/5
The model-id fix is correct, but
reasoning_effort: Some("off")is still sent unconditionally and will likely trigger a 400/422 on non-DeepSeek providers — the very backends this PR is meant to unblock.The model inheritance change is straightforward and fixes the described 404. However,
reasoning_effort: Some("off")remains hardcoded intool_agent_routeand is sent to every backend unconditionally. Providers that do not recognise this field (OpenAI-compatible servers, self-hosted LLMs, etc.) will still reject the request, leaving the tool-agent path broken for the general non-DeepSeek case the PR claims to fix. Additionally, the existing testtool_agent_route_forces_flash_with_thinking_offnow passes only because the stub runtime happens to usedeepseek-v4-flash, giving false confidence in the new behaviour.crates/tui/src/tools/subagent/mod.rs — specifically the
tool_agent_routefunction and its unconditionalreasoning_effortfield.Important Files Changed
deepseek-v4-flashmodel fromtool_agent_route, replacing it withruntime.model; fixes 404s on non-DeepSeek backends, butreasoning_effort: Some("off")is still unconditionally sent and may cause 400/422 on providers that don't recognise the field.Reviews (1): Last reviewed commit: "fix(subagent): inherit parent model in t..." | Re-trigger Greptile