* Agentic RAG * Fix formatting * Agent supervisor * fix links * SQL agent * Graph Runs in LS * fix format * Autogen + LG tutorial * fixes * update sql * remove old notebooks * docs: Add section about data region for LGP data plane (#5378) Add section about data region. * fix: remove empty notebook (#5379) * Fix docstring for _unset_config_context function (#5374) Signed-off-by: jitokim <pigberger70@gmail.com> * Fix typo in StreamMode debug description: checlkpoints → checkpoints (#5371) Signed-off-by: jitokim <pigberger70@gmail.com> * fix: remove unused import in generate_llms_text.py (#5380) * dcos: Fix deprecation of TavilySearch (#5375) Fix deprecation: The class `TavilySearchResults` was deprecated in LangChain 0.3.25 and will be removed in 1.0 * Fix typo: funtion → function (#5370) fix typos Signed-off-by: jitokim <pigberger70@gmail.com> * docs: feedback edits (#5387) * docs: update lgp deployment metric list (#5388) * chore(deps): bump peter-evans/create-pull-request from 6 to 7 (#5365) Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 6 to 7. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v6...v7) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * docs: correct link in docs/docs/how-tos/graph-api.md (#5377) Update graph-api.md * docs: Update quick_start.md Rest API Guide (#5368) Update quick_start.md Rest API Guide The curl command in the quick start needs some minor changes to work out of the box. I hope by adding these changes then new users can get started more quickly * Remove duplicate CONFIG_KEY_CHECKPOINT_MAP from RESERVED set (#5372) Signed-off-by: jitokim <pigberger70@gmail.com> * docs: fix typo in persistence (#5329) * docs: fix typo in application_structure * docs: fix typo in persistence * chore[deps]: upgrade dependencies with `uv lock --upgrade` (#5358) * chore: upgrade dependencies with `uv lock --upgrade` * linting * upgrade PR title --------- Co-authored-by: sydney-runkle <54324534+sydney-runkle@users.noreply.github.com> Co-authored-by: Sydney Runkle <sydneymarierunkle@gmail.com> * Updated examples for SummarizationNode to account for serde with persistence layers (#5257) * docs: move script into scripts (#5384) * docs: update sql tutorial (#5389) --------- Signed-off-by: jitokim <pigberger70@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Andrew Nguonly <andrewnguonly@users.noreply.github.com> Co-authored-by: Michael Li <michaelli65535@gmail.com> Co-authored-by: jito <pigberger70@gmail.com> Co-authored-by: Serhii Polishchuk <serhii.polishchuk@gelato.com> Co-authored-by: hari-dhanushkodi <hari@langchain.dev> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Fadel Akram <af8356207@gmail.com> Co-authored-by: David <31293924+dreadn0ught@users.noreply.github.com> Co-authored-by: Youssef Ahmed Mohamed Abdelrahman <109446360+unauthorised-401@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: sydney-runkle <54324534+sydney-runkle@users.noreply.github.com> Co-authored-by: Sydney Runkle <sydneymarierunkle@gmail.com> Co-authored-by: Nick Riley <nick@sparkida.com> Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com> Co-authored-by: ccurme <chester.curme@gmail.com>
6.5 KiB
How to pass custom run ID or set tags and metadata for graph runs in LangSmith
!!! tip "Prerequisites" This guide assumes familiarity with the following:
- [LangSmith Documentation](https://docs.smith.langchain.com)
- [LangSmith Platform](https://smith.langchain.com)
- [RunnableConfig](https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.config.RunnableConfig.html#langchain_core.runnables.config.RunnableConfig)
- [Add metadata and tags to traces](https://docs.smith.langchain.com/how_to_guides/tracing/trace_with_langchain#add-metadata-and-tags-to-traces)
- [Customize run name](https://docs.smith.langchain.com/how_to_guides/tracing/trace_with_langchain#customize-run-name)
Debugging graph runs can sometimes be difficult to do in an IDE or terminal. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph — read the LangSmith documentation for more information on how to get started.
To make it easier to identify and analyzed traces generated during graph invocation, you can set additional configuration at run time (see RunnableConfig):
| Field | Type | Description |
|---|---|---|
| run_name | str |
Name for the tracer run for this call. Defaults to the name of the class. |
| run_id | UUID |
Unique identifier for the tracer run for this call. If not provided, a new UUID will be generated. |
| tags | List[str] |
Tags for this call and any sub-calls (e.g., a Chain calling an LLM). You can use these to filter calls. |
| metadata | Dict[str, Any] |
Metadata for this call and any sub-calls (e.g., a Chain calling an LLM). Keys should be strings, values should be JSON-serializable. |
LangGraph graphs implement the LangChain Runnable Interface and accept a second argument (RunnableConfig) in methods like invoke, ainvoke, stream etc.
The LangSmith platform will allow you to search and filter traces based on run_name, run_id, tags and metadata.
TLDR
import uuid
# Generate a random UUID -- it must be a UUID
config = {"run_id": uuid.uuid4()}, "tags": ["my_tag1"], "metadata": {"a": 5}}
# Works with all standard Runnable methods
# like invoke, batch, ainvoke, astream_events etc
graph.stream(inputs, config, stream_mode="values")
The rest of the how to guide will show a full agent.
Setup
First, let's install the required packages and set our API keys
%%capture --no-stderr
%pip install --quiet -U langgraph langchain_openai
import getpass
import os
def _set_env(var: str):
if not os.environ.get(var):
os.environ[var] = getpass.getpass(f"{var}: ")
_set_env("OPENAI_API_KEY")
_set_env("LANGSMITH_API_KEY")
!!! tip Sign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph — read more about how to get started here.
Define the graph
For this example we will use the prebuilt ReAct agent.
from langchain_openai import ChatOpenAI
from typing import Literal
from langgraph.prebuilt import create_react_agent
from langchain_core.tools import tool
# First we initialize the model we want to use.
model = ChatOpenAI(model="gpt-4o", temperature=0)
# For this tutorial we will use custom tool that returns pre-defined values for weather in two cities (NYC & SF)
@tool
def get_weather(city: Literal["nyc", "sf"]):
"""Use this to get weather information."""
if city == "nyc":
return "It might be cloudy in nyc"
elif city == "sf":
return "It's always sunny in sf"
else:
raise AssertionError("Unknown city")
tools = [get_weather]
# Define the graph
graph = create_react_agent(model, tools=tools)
Run your graph
Now that we've defined our graph let's run it once and view the trace in LangSmith. In order for our trace to be easily accessible in LangSmith, we will pass in a custom run_id in the config.
This assumes that you have set your LANGSMITH_API_KEY environment variable.
Note that you can also configure what project to trace to by setting the LANGCHAIN_PROJECT environment variable, by default runs will be traced to the default project.
import uuid
def print_stream(stream):
for s in stream:
message = s["messages"][-1]
if isinstance(message, tuple):
print(message)
else:
message.pretty_print()
inputs = {"messages": [("user", "what is the weather in sf")]}
config = {"run_name": "agent_007", "tags": ["cats are awesome"]}
print_stream(graph.stream(inputs, config, stream_mode="values"))
Output:
================================ Human Message ==================================
what is the weather in sf
================================== Ai Message ===================================
Tool Calls:
get_weather (call_9ZudXyMAdlUjptq9oMGtQo8o)
Call ID: call_9ZudXyMAdlUjptq9oMGtQo8o
Args:
city: sf
================================= Tool Message ==================================
Name: get_weather
It's always sunny in sf
================================== Ai Message ===================================
The weather in San Francisco is currently sunny.
View the trace in LangSmith
Now that we've ran our graph, let's head over to LangSmith and view our trace. First click into the project that you traced to (in our case the default project). You should see a run with the custom run name "agent_007".
In addition, you will be able to filter traces after the fact using the tags or metadata provided. For example,

