Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/oss/langchain/short-term-memory.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,9 @@ def update_user_info(
runtime: ToolRuntime[CustomContext, CustomState],
) -> Command:
"""Look up and update user info."""
user_id = runtime.context.user_id # [!code highlight]
user_id = runtime.context.user_id
name = "John Smith" if user_id == "user_123" else "Unknown user"
return Command(update={
return Command(update={ # [!code highlight]
"user_name": name,
# update the message history
"messages": [
Expand All @@ -699,12 +699,11 @@ def greet(
"""Use this to greet the user once you found their info."""
user_name = runtime.state["user_name"]
return f"Hello {user_name}!"
# [!code highlight]
agent = create_agent(
model="openai:gpt-5-nano",
tools=[update_user_info, greet],
state_schema=CustomState,
context_schema=CustomContext, # [!code highlight]
state_schema=CustomState, # [!code highlight]
context_schema=CustomContext,
)

agent.invoke(
Expand Down