Tools¶
Helpers for integrating Temporal Activities with LangGraph tools.
activity_as_tool¶
activity_as_tool
¶
activity_as_tool(
activity_fn: Callable[..., Any],
*,
name: str | None = None,
description: str | None = None,
task_queue: str | None = None,
) -> Callable[..., Any]
Convert a Temporal Activity function into a LangGraph-compatible tool.
This wraps an @activity.defn decorated function so it can be used as
a tool within LangGraph nodes. When the tool is called inside a node
Activity, it executes the target Activity via the Temporal worker,
providing durable execution guarantees for tool invocations.
Note: The returned tool is a regular callable that invokes the Activity
function directly (in-process). For cross-worker Activity invocation,
use Temporal's workflow.execute_activity() from within a Workflow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
activity_fn
|
Callable[..., Any]
|
A function decorated with |
required |
name
|
str | None
|
Override the tool name (defaults to function name). |
None
|
description
|
str | None
|
Override the tool description (defaults to docstring). |
None
|
task_queue
|
str | None
|
Task queue for Activity execution (for future use). |
None
|
Returns:
| Type | Description |
|---|---|
Callable[..., Any]
|
A callable that can be used as a LangGraph tool. |