module documentation

Helpers for wiring Temporal activities into Strands' agent and hook surfaces.

Both activity_as_tool and activity_as_hook produce workflow-side objects that dispatch user activities via temporalio.workflow.execute_activity, so the I/O actually happens off the workflow.

Function activity_as_hook Wrap a Temporal activity as a Strands hook callback.
Function activity_as_tool Wrap a Temporal activity as a Strands tool.
Type Variable TEvent Undocumented
def activity_as_hook(activity_fn: Callable, *, activity_input: Callable[[TEvent], Any], task_queue: str | None = None, schedule_to_close_timeout: timedelta | None = None, schedule_to_start_timeout: timedelta | None = None, start_to_close_timeout: timedelta | None = None, heartbeat_timeout: timedelta | None = None, retry_policy: RetryPolicy | None = None, cancellation_type: ActivityCancellationType = ActivityCancellationType.TRY_CANCEL, activity_id: str | None = None, versioning_intent: VersioningIntent | None = None, summary: str | None = None, priority: Priority = Priority.default) -> HookCallback[TEvent]: (source)

Wrap a Temporal activity as a Strands hook callback.

The returned coroutine, when registered with HookRegistry.add_callback, dispatches activity_fn as a Temporal activity each time the associated event fires. activity_input is called with the event to produce a serializable activity input — events themselves are not serializable, since they hold references to the Agent and other workflow-bound objects. All other keyword arguments are forwarded to workflow.execute_activity.

def activity_as_tool(activity_fn: Callable, *, task_queue: str | None = None, schedule_to_close_timeout: timedelta | None = None, schedule_to_start_timeout: timedelta | None = None, start_to_close_timeout: timedelta | None = None, heartbeat_timeout: timedelta | None = None, retry_policy: RetryPolicy | None = None, cancellation_type: ActivityCancellationType = ActivityCancellationType.TRY_CANCEL, activity_id: str | None = None, versioning_intent: VersioningIntent | None = None, summary: str | None = None, priority: Priority = Priority.default) -> AgentTool: (source)

Wrap a Temporal activity as a Strands tool.

activity_fn must be decorated by @activity.defn. All keyword arguments are forwarded to workflow.execute_activity.

Undocumented

Value
TypeVar('TEvent',
        bound=BaseHookEvent)