From 5a795ff5f226e6703fc7868709d7ca68a7866cd7 Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Sun, 10 Aug 2025 16:44:10 -0400 Subject: [PATCH] new api --- src/agent/graph.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/agent/graph.py b/src/agent/graph.py index 2cecc0b..a89e7bf 100644 --- a/src/agent/graph.py +++ b/src/agent/graph.py @@ -8,12 +8,12 @@ from __future__ import annotations from dataclasses import dataclass from typing import Any, Dict, TypedDict -from langchain_core.runnables import RunnableConfig from langgraph.graph import StateGraph +from langgraph.runtime import Runtime -class Configuration(TypedDict): - """Configurable parameters for the agent. +class Context(TypedDict): + """Context parameters for the agent. Set these when creating assistants OR when invoking the graph. See: https://langchain-ai.github.io/langgraph/cloud/how-tos/configuration_cloud/ @@ -33,21 +33,20 @@ class State: changeme: str = "example" -async def call_model(state: State, config: RunnableConfig) -> Dict[str, Any]: +async def call_model(state: State, runtime: Runtime[Context]) -> Dict[str, Any]: """Process input and returns output. - Can use runtime configuration to alter behavior. + Can use runtime context to alter behavior. """ - configuration = config["configurable"] return { "changeme": "output from call_model. " - f'Configured with {configuration.get("my_configurable_param")}' + f"Configured with {runtime.context.get('my_configurable_param')}" } # Define the graph graph = ( - StateGraph(State, config_schema=Configuration) + StateGraph(State, context_schema=Context) .add_node(call_model) .add_edge("__start__", "call_model") .compile(name="New Graph")