Primary source掘金本周最热
View sourceEvent ·Multi-source
LangChain ToolRuntime 入门:context、state 与 store 的实际用法
LangChain 在执行工具时会自动注入 ToolRuntime 对象,工具参数分模型填写的普通参数和框架注入的 runtime 两类。文章用 create_agent 和 openai:gpt-4o-mini 的代码示例分别演示三个核心对象:context 通过 context_schema 传入用户 ID 和角色等运行条件,state 保存当前流程的临时数据如消息列表和重试次数,store 用于跨请求保存用户偏好等长期数据。文中还给出通过 AgentMiddleware 扩展 CustomAgentState 来统计模型调用次数的完整示例。
Current read
写 LangChain 智能体经常分不清 context、state、store 各管什么,这篇直接上代码讲清三个对象怎么用,还带限流中间件例子。
11 sources43° AI heatLast updated 2026/11/9 02:28:22
Evidence
11 sourcesRelated source 1AI Will
View sourceRelated source 2theverge
View sourceRelated source 3shao__meng
View sourceRelated source 4@koltregaskes
View sourceRelated source 5TestingCatalog
View sourceRelated source 6Gergely Orosz
View sourceRelated source 7IT之家
View sourceRelated source 8rohanpaul_ai
View sourceRelated source 9Rest of World
View sourceRelated source 10marktechpost
View sourceConflict check
Dedup data only shows that these sources discuss the same event, not that they agree. There is no structured supporting or refuting evidence yet, so no conflict is inferred automatically.