feat(langgraph): new context api (replacing config['configurable'] and config_schema) (#5243)

This commit is contained in:
Sydney Runkle
2025-07-15 09:20:20 -04:00
committed by GitHub
parent e0bf4a7bc3
commit 0837263542
30 changed files with 845 additions and 386 deletions
@@ -121,11 +121,11 @@ from langgraph.graph import StateGraph, END, START
from my_agent.utils.nodes import call_model, should_continue, tool_node # import nodes
from my_agent.utils.state import AgentState # import state
# Define the config
class GraphConfig(TypedDict):
# Define the runtime context
class GraphContext(TypedDict):
model_name: Literal["anthropic", "openai"]
workflow = StateGraph(AgentState, config_schema=GraphConfig)
workflow = StateGraph(AgentState, context_schema=GraphContext)
workflow.add_node("agent", call_model)
workflow.add_node("action", tool_node)
workflow.add_edge(START, "agent")