# Managed Deep Agents: can the model be chosen at runtime, without redeploying?

**URL:** <https://forum.langchain.com/t/managed-deep-agents-can-the-model-be-chosen-at-runtime-without-redeploying/4595>\
**Category:** Deployment\
**Created:** [September 23, 2026, 9:42am UTC](https://forum.langchain.com/t/managed-deep-agents-can-the-model-be-chosen-at-runtime-without-redeploying/4595 "2026-09-23T09:42:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dilip](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@dilip](https://forum.langchain.com/u/dilip)\
**Post date:** [September 23, 2026, 9:42am UTC](https://forum.langchain.com/t/managed-deep-agents-can-the-model-be-chosen-at-runtime-without-redeploying/4595/1 "2026-09-23T09:42:45Z")

</div>

I’d like users of our app to pick between provider models (Gemini / GPT / Claude) on a deployed Managed Deep Agent. The model seems fixed at deploy time, and the two overrides I’d expect to work are accepted and then silently ignored.

**Questions:**

1. Is runtime model selection on a deployed MDA supported by any route?
2. Is one-deployment-per-model the intended pattern instead?

---

<div class="post-metadata">

**Author:** ![pawel-twardziak](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/pawel-twardziak/32/960_2.png) [@pawel-twardziak](https://forum.langchain.com/u/pawel-twardziak)\
**Post date:** [September 23, 2026, 1:03pm UTC](https://forum.langchain.com/t/managed-deep-agents-can-the-model-be-chosen-at-runtime-without-redeploying/4595/2 "2026-09-23T13:03:40Z")

</div>

hi @dilip

I think runtime model selection on a deployed MDA is supported, but only through a `wrap_model_call` middleware in the agent definition. One deployment per model is not the intended pattern.

Why the overrides are ignored:

- `configurable.model` is read only by `compile_managed_agent_for_eval`, the `mda eval` path. The deploy path `compile_managed_agent` never touches it
- `context.model` does reach `runtime.context` (LangGraph passes it through even without a schema), but nothing in the stock Deep Agents stack consumes it

Try an async `@wrap_model_call` middleware that maps an allowlisted `runtime.context.model` value to `init_chat_model(...)`, passed via `define_deep_agent(middleware=[...], context_schema=Context)`. Clients then send `context={"model": "gpt"}` on `runs.stream`, or you create one assistant per model on the same deployment. Both are documented LangChain patterns and require one redeploy to add the hook.

The hook must be async (MDA only uses `ainvoke`/`astream`, sync-only hooks raise `NotImplementedError`). Subagents keep the deploy-time model unless they get the same middleware. The Deep Agents harness profile is chosen from the deploy-time model. Switching providers mid-thread can trip on provider-specific reasoning blocks.

Per-run context via wrap\_model\_call middleware:

- Deep Agents, Select a model at runtime (Python): [Models - Docs by LangChain](https://docs.langchain.com/oss/python/deepagents/models#select-a-model-at-runtime)
- Deep Agents, Select a model at runtime (JS): [Models - Docs by LangChain](https://docs.langchain.com/oss/javascript/deepagents/models#select-a-model-at-runtime)
- LangChain, Dynamic model selection: [Models - Docs by LangChain](https://docs.langchain.com/oss/python/langchain/models#dynamic-model-selection)
- MDA, Add custom middleware (lists “select models dynamically” and the async-hook requirement):  
[Add custom middleware to Managed Deep Agents - Docs by LangChain](https://docs.langchain.com/langsmith/python/managed-deep-agents-middleware)

One assistant per model on the same deployment:

- LangSmith, Manage assistants (model selection via stored context, no graph code change): [Manage assistants - Docs by LangChain](https://docs.langchain.com/langsmith/configuration-cloud)
- LangSmith, Assistants concept: [Assistants - Docs by LangChain](https://docs.langchain.com/langsmith/assistants)

---

<div class="post-metadata">

**Author:** ![pawel-twardziak](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/pawel-twardziak/32/960_2.png) [@pawel-twardziak](https://forum.langchain.com/u/pawel-twardziak)\
**Post date:** [September 23, 2026, 1:12pm UTC](https://forum.langchain.com/t/managed-deep-agents-can-the-model-be-chosen-at-runtime-without-redeploying/4595/3 "2026-09-23T13:12:52Z")

</div>

```py
@wrap_model_call
async def select_model(request, handler):
    spec = getattr(request.runtime.context, "model", None)
    if spec not in _MODELS:
        raise ValueError(f"Unsupported model {spec!r}.")
    return await handler(request.override(model=_MODELS[spec]))

agent = define_deep_agent(
    name="research-assistant",
    model="openai:gpt-5.5",
    middleware=[select_model],
    context_schema=Context,
)

```
