Sub-Agent Model Configuration in AI Coding Tools: Why It Silently Fails and How to Fix It

    This article explains why a model set for a sub-agent in an AI coding tool keeps falling back to the parent session's model even though the configuration is saved. It shows how an allowed-models whitelist differs from a default routing setting, why nested agent preset configuration is the layer that actually takes effect, and how to verify routing with logs. A general troubleshooting checklist and configuration management best practices are included.

    Why Sub-Agent Model Configuration Fails: Root Cause Analysis and a Practical Guide

    1. Background

    Most mainstream AI coding tools support a “sub-agent” mechanism: the main session (the parent session) can delegate a specific task to a sub-agent that has its own prompt and its own tool permissions. To let different tasks run on different models — for example, a general-purpose strong model for the main session and a lightweight model for sub-agents — these tools usually expose a model configuration entry point.

    A frequent problem in practice: you set the model inside the sub-agent plugin, restart the process, create a new session, and re-check the configuration file. The value is definitely written, yet the sub-agent always runs on the parent session’s model. In most cases this is not a failure to save the configuration. The setting merely looks effective while it is not on the path that actually decides the model.

    2. Root Cause: Treating an Authorization Whitelist as a Default Value

    The typical root cause is confusing two configuration concepts with completely different responsibilities:

    • Authorization whitelist (allowedModels) — this only answers “which models are allowed“, and belongs to the permission validation layer. The system reads this whitelist only when the caller explicitly passes a routing field (that is, explicitly states which model this sub-agent invocation should switch to), and then checks whether that model is permitted.
    • Default routing (the model setting inside agentOptions) — this answers “when nothing is specified explicitly, which model does the sub-agent use by default“, and belongs to the routing decision layer. If this field is missing, the system falls back to inheriting the parent session’s model.

    In other words, the whitelist is only an admission gate, not a default choice. Configuring the whitelist without configuring the default route is like putting up a sign at the door that says “entry allowed” without telling the system which room to go to — so the system follows its default logic and reuses the parent session’s model.

    A direct illustration of the call path:

    1. Call path:
    2. Parent session starts a sub-agent task
    3. ├─ Is a model specified explicitly?
    4. │ ├─ Yes → read the whitelist to validate that the model is allowed → use the specified model
    5. │ └─ No → read the default routing configuration
    6. │ ├─ Configured → use the default routing model
    7. │ └─ Not configured → fallback: inherit the parent session model

    The correct approach therefore is: first specify the sub-agent model in the default routing configuration, then make sure that model also appears in the authorization whitelist. Both are required, and neither can substitute for the other.

    3. Another Common Pitfall: Where Nested Configuration Actually Takes Effect

    The second frequent mistake concerns the hierarchy of the configuration. In some AI coding tools, sub-agent settings are not flattened at the top level but are mounted on nested rows under an “agent preset”. This has two consequences:

    1. Settings at the host layer (top level / host configuration row) do not take effect. A developer writes a configuration at the host layer, assuming it will be passed down to the sub-agent, but what actually applies is the nested configuration inside the preset.
    2. Patching by id may hit the wrong target. When multiple presets and sub-agents share similar ids or inheritance relationships, locating a target by id and patching it may modify another entry with the same name or a nested one — and no error is raised. This kind of “silently written to the wrong place” problem is harder to diagnose than an error, because everything appears normal on the surface.

    Recommendations when investigating this class of problem:

    • Prefer the tool’s “final effective configuration” view (if it provides one) instead of reading only the hand-written configuration file;
    • Export and compare the effective configuration before and after a change to confirm the edit actually landed on the nested row inside the preset;
    • Avoid fuzzy matching by id; locate targets with the full hierarchical path instead.

    4. General Troubleshooting Checklist

    Abstracting the root causes above into a general procedure, verify the following items in order:

    1. Confirm the configuration is actually persisted: check that the configuration file content matches what the tool’s UI displays, ruling out caching or unsaved changes.
    2. Separate the configuration responsibilities: determine whether the item is a permission/whitelist entry or a default route, and make sure the default routing field is explicitly set.
    3. Trace the effective path: confirm the configuration sits at the hierarchical level that actually takes effect (the nested preset location) rather than an ineffective copy at the host layer.
    4. Verify the routing result with logs: inspect the model identifier in sub-agent invocation logs to confirm which model was actually selected at runtime, instead of inferring it from the configuration.
    5. Minimize the reproduction: create a minimal configuration containing a single sub-agent, then add configuration items one by one to identify which one causes the routing fallback.

    An illustrative configuration structure (pseudocode, showing hierarchy only):

    1. agentPreset:
    2. id: code-review-preset
    3. toolSubagent:
    4. # Effective location: nested configuration inside the preset
    5. agentOptions:
    6. defaultModel: "sub-agent default model"
    7. allowedModels:
    8. - "sub-agent default model"
    9. - "fallback model"
    10. # Note: an identically named configuration row at the host layer
    11. # will not take effect, and will not raise an error

    5. Best Practices for Configuration Management

    • Manage permissions and routing separately: maintain the whitelist centrally according to security policy; maintain default routes per preset or per scenario, so that one change does not affect all sub-agents.
    • Explicit over implicit: declare routing intent explicitly for critical invocations, reducing reliance on inheritance and fallback logic.
    • Configuration as code: put preset and sub-agent configuration under version control so changes are traceable and the team can spot ineffective configuration written at the host layer.
    • Add validation: if the tool supports it, validate at startup that the default model is in the whitelist, surfacing configuration inconsistencies early.
    • Verify after changes: after each adjustment, run a simple sub-agent task to confirm the model actually used before relying on it in daily work.

    6. Summary

    For problems of the form “the configuration was written but the behavior did not change”, the cause is usually not a failed write but the wrong semantic layer being written: the whitelist governs whether a model can be used, the default route governs whether it is used; the host layer configuration is for display, while the nested configuration inside the preset is what takes effect. Understanding these two distinctions, together with verifying the actual routing result in logs, turns this seemingly mysterious class of problem into a reproducible and fixable configuration issue.