From bef76b791ca273bc87adf092950d27caf5b7835c Mon Sep 17 00:00:00 2001 From: le-codeur-rapide <166131032+le-codeur-rapide@users.noreply.github.com> Date: Fri, 7 Nov 2025 22:01:19 +0100 Subject: [PATCH] docs(langgraph): Fix docstring code examples of task function (#6410) Hi all, I found out that the sync and async code examples of the `task` function in `libs/langgraph/langgraph/func/__init__.py` have a typo: ``` Example: Sync Task ```python from langgraph.func import entrypoint, task @task def add_one(a: int) -> int: return a + 1 @entrypoint() def add_one(numbers: list[int]) -> list[int]: futures = [add_one(n) for n in numbers] results = [f.result() for f in futures] return results # Call the entrypoint add_one.invoke([1, 2, 3]) # Returns [2, 3, 4] ``` ``` Both task and entrypoint functions have the same name which gives an error. This is a small PR to fix this --- libs/langgraph/langgraph/func/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/langgraph/langgraph/func/__init__.py b/libs/langgraph/langgraph/func/__init__.py index 9cf770f67..b156bf9d1 100644 --- a/libs/langgraph/langgraph/func/__init__.py +++ b/libs/langgraph/langgraph/func/__init__.py @@ -151,13 +151,13 @@ def task( @task - def add_one(a: int) -> int: + def add_one_task(a: int) -> int: return a + 1 @entrypoint() def add_one(numbers: list[int]) -> list[int]: - futures = [add_one(n) for n in numbers] + futures = [add_one_task(n) for n in numbers] results = [f.result() for f in futures] return results @@ -173,13 +173,13 @@ def task( @task - async def add_one(a: int) -> int: + async def add_one_task(a: int) -> int: return a + 1 @entrypoint() async def add_one(numbers: list[int]) -> list[int]: - futures = [add_one(n) for n in numbers] + futures = [add_one_task(n) for n in numbers] return asyncio.gather(*futures)