掘金 AI· 锋行天下·· 2026-10-30AI 评分32
LangGraph 运行时上下文使用示例
Langgraph 运行时上下文使用示例
AI 导读
LangGraph 支持通过 context_schema 传入自定义上下文类型,在 StateGraph 初始化时声明 UserContext,调用 graph.invoke 时以 context=UserContext(username="Alice") 注入运行时上下文,节点函数通过 runtime.context 读取该上下文信息。
来源:掘金 AI · juejin.cn