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

推荐订阅源

C
Check Point Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
LangChain Blog
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
A
About on SuperTechFans
J
Java Code Geeks
量子位
博客园 - 三生石上(FineUI控件)
博客园 - Franky
博客园_首页
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
Martin Fowler
Martin Fowler
有赞技术团队
有赞技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

LangChain Forum - Latest posts

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 Question about LangSmith Trace Search via API How to cancel a run correct !! Anyone confirms this issue that deepagent ui streaming is disturb by update in deepagent or bug issue Would pre-inference routing help long-context agent workflows? Best Stack for Building AI Applications Question about LangSmith Trace Search 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) Metadata filter not filtering for alerts Connecting the Slack integration fails with invalid_team_for_non_distributed_app Trouble understanding and editing experiment summary evaluators feedbacks SSL certificate error from httpx with LangGraph server WikipediaLoader endup in JSONDecodeError Human-in-the-loop approval dashboard for LangGraph agents — open source, free to deploy Should interrupt() be split into two primitives — one for human input, one for s2s data fetching? How are people handling data governance across agent handoffs in production? Feature Request: @task metadata Research: Friction Points in Agentic Commerce Transactions How should I provide an agent to a LangGraph server?
In-place model update on a compiled create_agent and per-...
@pawel-tward · 2026-04-19 · via LangChain Forum - Latest posts

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