Skip to content

fix(subagent): inherit parent model in tool-agent route instead of hardcoding deepseek-v4-flash#2736

Open
h3c-hexin wants to merge 1 commit into
Hmbown:mainfrom
h3c-hexin:fix/tool-agent-inherit-parent-model
Open

fix(subagent): inherit parent model in tool-agent route instead of hardcoding deepseek-v4-flash#2736
h3c-hexin wants to merge 1 commit into
Hmbown:mainfrom
h3c-hexin:fix/tool-agent-inherit-parent-model

Conversation

@h3c-hexin
Copy link
Copy Markdown
Contributor

@h3c-hexin h3c-hexin commented Jun 4, 2026

Problem

tool_agent_route() hardcodes model: "deepseek-v4-flash". Routing a ToolAgent sub-agent therefore issues an API request for deepseek-v4-flash regardless 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 from reasoning_effort = off, not from a specific model id, so dropping the hardcoded model preserves the intended behaviour.

  • No-op for DeepSeek setups: the parent model is already a DeepSeek id.
  • Fixes tool-agent routing on every other backend/provider.

Scope

One function (tool_agent_route) + its single caller in resolve_subagent_assignment_route. reasoning_effort: off unchanged. The separate subagent_flash_router (auto-model router) is intentionally left untouched.

Greptile Summary

This PR fixes tool_agent_route so that ToolAgent sub-agents inherit the parent session's model via runtime.model instead of hardcoding "deepseek-v4-flash", preventing 404 errors on any backend that does not serve that exact model id.

  • tool_agent_route() now accepts &SubAgentRuntime and clones runtime.model; reasoning_effort = off is preserved unchanged to maintain the fast-lane semantics.
  • resolve_subagent_assignment_route is updated to pass runtime through 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 in tool_agent_route and 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 test tool_agent_route_forces_flash_with_thinking_off now passes only because the stub runtime happens to use deepseek-v4-flash, giving false confidence in the new behaviour.

crates/tui/src/tools/subagent/mod.rs — specifically the tool_agent_route function and its unconditional reasoning_effort field.

Important Files Changed

Filename Overview
crates/tui/src/tools/subagent/mod.rs Removes the hardcoded deepseek-v4-flash model from tool_agent_route, replacing it with runtime.model; fixes 404s on non-DeepSeek backends, but reasoning_effort: Some("off") is still unconditionally sent and may cause 400/422 on providers that don't recognise the field.

Fix All in Codex Fix All in Claude Code Fix All in Cursor

Reviews (1): Last reviewed commit: "fix(subagent): inherit parent model in t..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

…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.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

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 .github/APPROVED_CONTRIBUTORS will be closed automatically.

Please read CONTRIBUTING.md for the expected contribution shape. A maintainer can grant PR access by commenting /lgtm on a pull request.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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);

Comment on lines +4723 to 4733
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()),
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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()),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Fix in Codex Fix in Claude Code Fix in Cursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant