Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(langgraph): Add tags and run name to message stream output #2312

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions libs/langgraph/langgraph/pregel/messages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import (

Check notice on line 1 in libs/langgraph/langgraph/pregel/messages.py

View workflow job for this annotation

GitHub Actions / benchmark

Benchmark results

......................................... fanout_to_subgraph_10x: Mean +- std dev: 48.1 ms +- 0.9 ms ......................................... fanout_to_subgraph_10x_sync: Mean +- std dev: 44.0 ms +- 0.7 ms ......................................... fanout_to_subgraph_10x_checkpoint: Mean +- std dev: 76.4 ms +- 1.7 ms ......................................... fanout_to_subgraph_10x_checkpoint_sync: Mean +- std dev: 84.9 ms +- 0.7 ms ......................................... fanout_to_subgraph_100x: Mean +- std dev: 475 ms +- 10 ms ......................................... fanout_to_subgraph_100x_sync: Mean +- std dev: 426 ms +- 5 ms ......................................... fanout_to_subgraph_100x_checkpoint: Mean +- std dev: 797 ms +- 47 ms ......................................... fanout_to_subgraph_100x_checkpoint_sync: Mean +- std dev: 835 ms +- 17 ms ......................................... react_agent_10x: Mean +- std dev: 31.0 ms +- 3.0 ms ......................................... react_agent_10x_sync: Mean +- std dev: 22.5 ms +- 1.5 ms ......................................... react_agent_10x_checkpoint: Mean +- std dev: 46.8 ms +- 3.2 ms ......................................... react_agent_10x_checkpoint_sync: Mean +- std dev: 37.3 ms +- 3.0 ms ......................................... react_agent_100x: Mean +- std dev: 325 ms +- 7 ms ......................................... react_agent_100x_sync: Mean +- std dev: 261 ms +- 3 ms ......................................... react_agent_100x_checkpoint: Mean +- std dev: 905 ms +- 9 ms ......................................... react_agent_100x_checkpoint_sync: Mean +- std dev: 814 ms +- 6 ms ......................................... wide_state_25x300: Mean +- std dev: 18.3 ms +- 0.4 ms ......................................... wide_state_25x300_sync: Mean +- std dev: 10.9 ms +- 0.1 ms ......................................... wide_state_25x300_checkpoint: Mean +- std dev: 276 ms +- 11 ms ......................................... wide_state_25x300_checkpoint_sync: Mean +- std dev: 269 ms +- 13 ms ......................................... wide_state_15x600: Mean +- std dev: 21.3 ms +- 0.4 ms ......................................... wide_state_15x600_sync: Mean +- std dev: 12.5 ms +- 0.1 ms ......................................... wide_state_15x600_checkpoint: Mean +- std dev: 479 ms +- 14 ms ......................................... wide_state_15x600_checkpoint_sync: Mean +- std dev: 464 ms +- 14 ms ......................................... wide_state_9x1200: Mean +- std dev: 21.2 ms +- 0.4 ms ......................................... wide_state_9x1200_sync: Mean +- std dev: 12.5 ms +- 0.1 ms ......................................... wide_state_9x1200_checkpoint: Mean +- std dev: 313 ms +- 14 ms ......................................... wide_state_9x1200_checkpoint_sync: Mean +- std dev: 301 ms +- 14 ms

Check notice on line 1 in libs/langgraph/langgraph/pregel/messages.py

View workflow job for this annotation

GitHub Actions / benchmark

Comparison against main

+-----------------------------------------+---------+-----------------------+ | Benchmark | main | changes | +=========================================+=========+=======================+ | wide_state_25x300_checkpoint | 272 ms | 276 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600_checkpoint_sync | 456 ms | 464 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_9x1200_checkpoint | 305 ms | 313 ms: 1.03x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint | 74.5 ms | 76.4 ms: 1.03x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint | 881 ms | 905 ms: 1.03x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint_sync | 789 ms | 814 ms: 1.03x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300_checkpoint_sync | 260 ms | 269 ms: 1.03x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600_checkpoint | 464 ms | 479 ms: 1.03x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_9x1200_checkpoint_sync | 291 ms | 301 ms: 1.03x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600_sync | 12.1 ms | 12.5 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_sync | 252 ms | 261 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_9x1200 | 20.4 ms | 21.2 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600 | 20.5 ms | 21.3 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x | 29.7 ms | 31.0 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_checkpoint | 44.9 ms | 46.8 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x | 312 ms | 325 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x | 46.2 ms | 48.1 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_sync | 21.5 ms | 22.5 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_sync | 407 ms | 426 ms: 1.05x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_9x1200_sync | 12.0 ms | 12.5 ms: 1.05x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_checkpoint_sync | 798 ms | 835 ms: 1.05x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300 | 17.5 ms | 18.3 ms: 1.05x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint_sync | 81.0 ms | 84.9 ms: 1.05x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_sync | 41.9 ms | 44.0 ms: 1.05x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300_sync | 10.3 ms | 10.9 ms: 1.05x slower | +---------------------------------------
Any,
AsyncIterator,
Callable,
Expand Down Expand Up @@ -61,12 +61,13 @@
parent_run_id: Optional[UUID] = None,
tags: Optional[list[str]] = None,
metadata: Optional[dict[str, Any]] = None,
name: Optional[str] = None,
**kwargs: Any,
) -> Any:
if metadata and (not tags or TAG_NOSTREAM not in tags):
self.metadata[run_id] = (
tuple(cast(str, metadata["langgraph_checkpoint_ns"]).split(NS_SEP)),
metadata,
{"name": name, "tags": tags, **metadata},
)

def on_llm_new_token(
Expand Down Expand Up @@ -112,6 +113,7 @@
parent_run_id: Optional[UUID] = None,
tags: Optional[List[str]] = None,
metadata: Optional[Dict[str, Any]] = None,
name: Optional[str] = None,
**kwargs: Any,
) -> Any:
if (
Expand All @@ -121,7 +123,7 @@
):
self.metadata[run_id] = (
tuple(cast(str, metadata["langgraph_checkpoint_ns"]).split(NS_SEP)),
metadata,
{"name": name, "tags": tags, **metadata},
)

def on_chain_end(
Expand Down
Loading