xr_ai_tools.async_tools#

Typed tools that yield asynchronous result chunks.

Classes#

AsyncTool

A validated asynchronous tool independent of any output transport.

Module Contents#

class xr_ai_tools.async_tools.AsyncTool(
name: str,
description: str,
request_model: type[RequestT],
chunk_model: type[ChunkT],
handler: collections.abc.Callable[[RequestT], collections.abc.AsyncIterator[ChunkT]],
)#

A validated asynchronous tool independent of any output transport.

async stream(
request: RequestT | collections.abc.Mapping[str, object],
) collections.abc.AsyncIterator[ChunkT]#

Validate and yield chunks produced in an isolated Relay tool scope.

The producer task owns the scope and handler cleanup; chunks are yielded in the consumer’s context. Parent scope-local registrations are not transferred into the isolated context.