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

推荐订阅源

爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
Y
Y Combinator Blog
I
InfoQ
美团技术团队
罗磊的独立博客
B
Blog RSS Feed
GbyAI
GbyAI
小众软件
小众软件
IT之家
IT之家
Engineering at Meta
Engineering at Meta
Blog — PlanetScale
Blog — PlanetScale
V
V2EX
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
MyScale Blog
MyScale Blog
博客园 - 聂微东
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss

LangChain Forum - Latest topics

Seeking help regarding the connection between Websocket and tool calls Tool invocation error with empty error message when using `InjectedState` + `Command` return in async tool How to use @langchain/react FileSystem middleware Using ChatSnowflake with agents Built llmsessioncontract on AgentMiddleware: runtime enforcement of tool-call protocols — feedback wanted DeltaChannelHistory not found in langgraph-api:3.12 Improving citation accuracy and reducing hallucinations in custom Parent-Child RAG pipeline (Gemma3:4B + FAISS+BM25 + Cross-encoder reranker) Built a live autonomous AI agent network using LangGraph-style economics — looking for feedback How are you validating LangChain agent output before it executes shell commands? Cross-site pattern pool for production agent failures — looking for 5 pilot teams (open spec, CC-BY-4.0) Metadata filter not filtering for alerts Using custom MCP servers with assistants How to use tool calling using ChatLlamaCpp and Gemma 4 E4B with create_agent? CLI - No Longer Sending traces to Langsmith Connecting the Slack integration fails with invalid_team_for_non_distributed_app The Docs says open router can be used with init_chat_model but throws an error Interested to contribute to langgraph postgre checkpointer for multiple adapter support Modal Inference Trouble understanding and editing experiment summary evaluators feedbacks SSL certificate error from httpx with LangGraph server [Feature Request] Wire allowed_msgpack_modules in langgraph.json Serving an agent with the LangGraph CLI dev command Proposal: implement delete_for_runs for SQLite checkpoint savers WikipediaLoader endup in JSONDecodeError Human-in-the-loop approval dashboard for LangGraph agents — open source, free to deploy Ombre — open source security and audit layer for LangChain apps Should interrupt() be split into two primitives — one for human input, one for s2s data fetching? Unable to delete runs from annotation queue First Bedrock call after idle is slow on TTFT (follow-ups in the same trace are fast)
In-place model update on a compiled create_agent and per-...
@pawel-tward · 2026-04-19 · via LangChain Forum - Latest topics

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