Skip to content

antikythera_agents.context ¤

Classes¤

ExecutionContext ¤

ExecutionContext()

Provides runtime context and lifecycle hooks for the currently executing task.

Currently, only on_cancel is available as lifecycle event, but in the future, more events will be added to this context class.

Attributes¤

is_cancelled property ¤
is_cancelled: bool

Returns True if the task has been requested to cancel.

Functions¤

cancel ¤
cancel() -> None

Marks the context as cancelled and executes all registered callbacks. This method is called by the runtime/launcher, not by the tool itself.

on_cancel ¤
on_cancel(callback: Callable[[], None]) -> None

Register a callback to be executed when the task is cancelled. Useful for cleaning up external resources (sockets, file handles).

If the context is already cancelled, the callback is executed immediately.