@@ -115,7 +115,7 @@ pip install langgraph-checkpoint-cosmosdb
115115```
116116
117117``` python
118- from langchain.agents import create_agent
118+ from langgraph.graph import StateGraph, MessagesState, START
119119from langgraph_checkpoint_cosmosdb import CosmosDBSaver # [!code highlight]
120120import os
121121
@@ -124,16 +124,16 @@ os.environ["COSMOSDB_ENDPOINT"] = "your_cosmosdb_endpoint"
124124os.environ[" COSMOSDB_KEY" ] = " your_cosmosdb_key"
125125
126126# Database and Container are created if they don't exist
127- with CosmosDBSaver( # [!code highlight]
127+ checkpointer = CosmosDBSaver( # [!code highlight]
128128 database_name = " your_database" , # [!code highlight]
129129 container_name = " your_container" # [!code highlight]
130- ) as checkpointer: # [!code highlight]
130+ ) # [!code highlight]
131131
132- agent = create_agent(
133- " gpt-5 " ,
134- [get_user_info],
135- checkpointer = checkpointer, # [!code highlight]
136- )
132+ # Build your graph with the checkpointer
133+ builder = StateGraph(MessagesState)
134+ builder.add_node( " call_model " , call_model)
135+ builder.add_edge( START , " call_model " )
136+ graph = builder.compile( checkpointer = checkpointer) # [!code highlight]
137137```
138138
139139:::
@@ -712,7 +712,7 @@ def update_user_info(
712712 runtime : ToolRuntime[CustomContext, CustomState],
713713) -> Command:
714714 """ Look up and update user info."""
715- user_id = runtime.context.user_id
715+ user_id = runtime.context.user_id
716716 name = " John Smith" if user_id == " user_123" else " Unknown user"
717717 return Command(update = { # [!code highlight]
718718 " user_name" : name,
@@ -737,7 +737,7 @@ agent = create_agent(
737737 model = " gpt-5-nano" ,
738738 tools = [update_user_info, greet],
739739 state_schema = CustomState, # [!code highlight]
740- context_schema = CustomContext,
740+ context_schema = CustomContext,
741741)
742742
743743agent.invoke(
0 commit comments