jeevesagent.tools.registry

In-process tool registry.

A Tool wraps a Python callable with a JSON-Schema-style input description. tool() is a decorator that derives the schema from type hints. InProcessToolHost is the simplest ToolHost: a dict keyed by tool name.

Attributes

Classes

InProcessToolHost

A dict-backed ToolHost.

Tool

A registered tool: definition plus the callable that executes it.

Functions

tool(…)

Promote a callable to a Tool.

Module Contents

class jeevesagent.tools.registry.InProcessToolHost(tools: list[Tool | collections.abc.Callable[Ellipsis, Any]] | None = None)[source]

A dict-backed ToolHost.

async call(tool: str, args: collections.abc.Mapping[str, Any], *, call_id: str = '') jeevesagent.core.types.ToolResult[source]
get(name: str) Tool | None[source]
async list_tools(*, query: str | None = None) list[jeevesagent.core.types.ToolDef][source]
register(item: Tool | collections.abc.Callable[Ellipsis, Any]) Tool[source]
unregister(name: str) bool[source]

Remove a tool by name. Returns True if removed.

async watch() collections.abc.AsyncIterator[jeevesagent.core.types.ToolEvent][source]

In-process registry is static; the generator yields nothing.

Iterating over an empty tuple keeps this an async generator (so the return type is AsyncIterator) without ever producing an event at runtime.

class jeevesagent.tools.registry.Tool[source]

A registered tool: definition plus the callable that executes it.

async execute(args: collections.abc.Mapping[str, Any]) Any[source]

Invoke the underlying callable.

Async functions are awaited; sync functions are dispatched to a worker thread via anyio.to_thread.run_sync() so they don’t block the event loop.

to_def() jeevesagent.core.types.ToolDef[source]
description: str
destructive: bool = False
fn: collections.abc.Callable[Ellipsis, Any]
input_schema: dict[str, Any]
name: str
jeevesagent.tools.registry.tool(fn: collections.abc.Callable[Ellipsis, Any]) Tool[source]
jeevesagent.tools.registry.tool(*, name: str | None = None, description: str | None = None, destructive: bool = False) collections.abc.Callable[[collections.abc.Callable[Ellipsis, Any]], Tool]

Promote a callable to a Tool.

Use as @tool (bare) or @tool(name=..., description=..., destructive=...). The schema is derived from parameter annotations; primitive types map to their JSON-Schema equivalents, anything else falls back to string.

jeevesagent.tools.registry.ToolCallable