Skip to content

handle

etrack.logic.handle

logic/handle: RunHandle — the run in progress, reached from anywhere inside it: span, fact, declare, annotate.

Tracker.track binds the run's fold in a context variable for its block; LangGraph runs its nodes, tools and middlewares in copies of the caller's context, so the code the run calls reaches the fold without being handed it. A span opened here hangs from what is running where it is opened — the node, the tool — as the source locates it. Outside a run every call is a no-op: the same code runs tracked and untracked, and never fails for want of a tracker.

RunHandle

The run in progress, whoever calls: every method acts on the run bound in the caller's context, or does nothing.

active property

active: bool

Whether the caller stands inside a tracked run.

annotate

annotate(**attributes: Any) -> None

Attributes the run learnt on its way — a verdict, a cut, a consent —, carried by the run's END.

declare

declare(
    input: str | None = None, output: str | None = None
) -> None

What the run took in, what it published: stated by the code that says it, carried on the run's END.

fact

fact(value: Fact) -> None

A business event, validated against its class, as one frame under what is running; refused at the call when it does not meet its class, tracked or not.

span

span(
    name: str,
    kind: EventKind = CUSTOM,
    payload: dict[str, Any] | None = None,
    **attributes: Any,
) -> Generator[str]

A span around a block, under what is running where it opens; yields its id — empty outside a run.

Running dataclass

Running(fold: FoldProcessor, locate: Callable[[], str])

The fold of the run in progress, and how its source tells which span is running where the caller stands.