[PR #2378] Imperative API #2669

Closed
opened 2026-02-20 17:47:22 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/2378

State: closed
Merged: Yes


  • Whereas Send is for fire-and-forget type of calls, new call and acall functions are for flows where you want to wait for the node to finish before doing something else
  • Because we return regular python future objects (concurrent.futures.Future or asyncio.Future) all the python primitives for working with futures work, eg. wait, gather, etc
    @task()
    def mapper(input: str) -> str:
        print(f"mapper {input}")
        return input * 2

    @entrypoint(checkpointer=checkpointer)
    def graph(input: list[str]) -> list[str]:
        futures = [mapper(i) for i in input]
        mapped = [f.result() for f in futures]
        return mapped

    thread1 = {"configurable": {"thread_id": "1"}}
    assert graph.invoke(["0", "1"], thread1) == ["00", "11"]
**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/2378 **State:** closed **Merged:** Yes --- - Whereas `Send` is for fire-and-forget type of calls, new `call` and `acall` functions are for flows where you want to wait for the node to finish before doing something else - Because we return regular python future objects (concurrent.futures.Future or asyncio.Future) all the python primitives for working with futures work, eg. wait, gather, etc ```py @task() def mapper(input: str) -> str: print(f"mapper {input}") return input * 2 @entrypoint(checkpointer=checkpointer) def graph(input: list[str]) -> list[str]: futures = [mapper(i) for i in input] mapped = [f.result() for f in futures] return mapped thread1 = {"configurable": {"thread_id": "1"}} assert graph.invoke(["0", "1"], thread1) == ["00", "11"] ```
yindo added the pull-request label 2026-02-20 17:47:22 -05:00
yindo closed this issue 2026-02-20 17:47:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#2669