惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
GbyAI
GbyAI
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
B
Blog
aimingoo的专栏
aimingoo的专栏
酷 壳 – CoolShell
酷 壳 – CoolShell
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
月光博客
月光博客
H
Help Net Security
V
Visual Studio Blog
量子位
A
About on SuperTechFans
博客园 - Franky
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
Martin Fowler
Martin Fowler
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog

LangChain Forum - Topics tagged python-help

Llama-server process has terminated: invalid argument --load-mode with Ollama client 0.32.6 and langchain-ollama 1.1.0 Langchain Certified Agent Engineer Exam - Exam link not received and no response Null-drift: A bare-metal O(1) Memory Store for continuous LangGraph agents Clarification needed: Assistant config vs context and graph initialization Proposal: a small local helper for readable run traces via PR Proxy Authentication Required 407 What is the right way to dynamically create and run a graph? Re-Implement claude code's dynamic workflow using langchian & deepagents How to define a correct state for multi-agent system Response Format Groq Model Pydantic I hope to get some recommendations for practical skills Interrupt does not work correctly in LangGraph The Qwen3.6b model in fireworks through initchatmodel reporting hugely inflated tokens For parallel execution in Node, should i use the functional API? Potential Enhancement: Django-Managed PostgresSaver Pre-interrupt() code re-runs on resume — anti-pattern, or is there a sanctioned way to detect resume? Interrupt parallel branch execution Best practices for self-hosting LangGraph Server OSS without LangGraph keys Dynamically Enabling/Disabling Graphs in a LangGraph Server at Runtime LangGraph thread copy can take 12+ minutes: recommended production pattern? Will DeltaChannel be the default for AgentState.messages, or expected to stay opt-in? Proposal: additional docs for implementing custom DB checkpointers or a guide on generic base checkpointer Prompt_cache_retention: '24h' supported in langchain agents and where to provide it, inside invoke or while creating client? Could RAG pipelines realistically cause deployment timeouts, is Render suitable for first-time RAG deployments? How do I use langchain_postgres' init_vectorstore_table correctly? Proposal: Graph-wide default error handler for StateGraph (fallback for nodes without error_handler) Support timedelta for CachePolicy.ttl, consistent with TimeoutPolicy Anyone confirms this issue that deepagent ui streaming is disturb by update in deepagent or bug issue Best Stack for Building AI Applications Seeking help regarding the connection between Websocket and tool calls
In-place model update on a compiled create_agent and per-...
@pawel-tward · 2026-04-19 · via LangChain Forum - Topics tagged python-help

1

Updating a model in-place on a compiled create_agent and per-subagent in deep agents?

Setup: Long-running web-socket sessions. On session connect, I build a deep agent with a main agent and several subagents — each can use a different model (Bedrock, Anthropic, in-house, etc.). Conversations can run 30+ minutes, longer than some of these providers’ credential lifetimes (STS, SSO, rotating tokens).

What I want: When credentials rotate mid-session, update the model on the already-compiled agent or on a specific subagent without rebuilding the graph.

# At t = 0
main_agent = create_agent(
    model=self.driver_model,
    system_prompt=self.system_prompt,
    tools=self.tools,
    middleware=self.middlewares,
    checkpointer=self.checkpointer,
    ...
)
# subagents constructed similarly, each with its own model

# At t = 30 min, after a credential refresh — what I'd like:
main_agent.update_model(fresh_model_with_cred)
main_agent.update_model(fresh_model_with_cred, subagent="research")

What I know already:

  • @wrap_model_call middleware with request.override(model=...) works as a runtime swap.

  • Rebuilding via create_agent(...) works but it could tear down checkpointer/MCP connections and recompile the graph — too heavy for a credential refresh.

  • Mutating model.client in place is provider-specific and brittle (e.g. ChatBedrockConverse has two boto3 clients, custom-headers event handlers, etc.).

Questions:

  1. Is there a supported way to update the bound model on a compiled create_agent (and on individual subagents in deepagents) without rebuilding?

  2. If not, is wrap_model_call with a model registry the intended pattern for credential rotation across multiple subagents — or is something better planned?

Thanks!

hi @NikhilKamathB

AFAIK there is no public update_model / set_model API on a graph compiled by create_agent, and none on the subagents that deepagentsSubAgentMiddleware creates. My search of the current langchain_v1 and deepagents sources returns zero matches for either name on the agent or middleware surface.

wrap_model_call + request.override(model=...) seems to be the intended runtime-swap pattern. It is the mechanism LangChain itself uses internally (e.g. ModelFallbackMiddleware), it is the only public knob for per-call model substitution, and it works equally well for the main agent and for each declarative subagent - as long as you attach the middleware to each subagent’s own middleware stack, or hand SubAgentMiddleware a CompiledSubAgent you built yourself. Direct attribute mutation on ModelRequest was explicitly deprecated in favour of request.override(...).

Caveat worth planning for: in deepagents, create_summarization_middleware(subagent_model, backend) binds a model outside the wrap_model_call chain, so summarization calls will keep using the original credentials. For 30-min sessions with stale STS/SSO tokens, plan credential rotation at a level that covers these out-of-band calls as well