Skip to content

agentic.handle

Page status: scaffold Source state: generated Applies to: Shepherd v1.0-dev Owner: @docs-system-owner (TBD) Validation: scripts/gen_shepherd_api_inventory.py --check

This is reference — exact, generated facts. The mental model lives in concepts; recipes live in guides.

Pre-rename surface

Generated from the internal agentic facade; names and paths change at the Shepherd rename.

function

handle

handle(
    effect: type, fn: Callable[..., Any]
) -> _HandleContext
handle(
    effects: dict[type, Callable[..., Any]],
) -> _HandleContext
handle(
    effect_kind: str, fn: Callable[..., Any]
) -> _HandleContext
handle(*args: Any, **kwargs: Any) -> _HandleContext

Install a handler in the active binding env for the lexical block.

See module docstring for accepted call shapes. Signatures and keys are validated eagerly; bindings are active only for the dynamic extent of the returned sync or async context manager.

See also