Tool Registry¶
Registry¶
agora_workbench.code_execution.tool_registry.tool_registry.ToolRegistry(package=None)
¶
Registry that stores and indexes :class:~code_execution.tool_registry.ToolDefinition objects.
Each registered tool receives a unique integer ID (assigned sequentially
starting from 0). Tools can be retrieved by ID or by name in O(1) time
via internal dictionaries.
By default, tool X is imported as from {package}.{X} import {X}.
Override with ToolDefinition.module or ToolDefinition.module_override
to use a custom import path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
str | None
|
Default Python package for tool imports. When set, the kernel
proxy generates |
None
|
Source code in src/agora_workbench/code_execution/tool_registry/tool_registry.py
register_tool(tool)
¶
Register a tool in the registry.
A copy of tool is stored so that the registry's internal state
cannot be mutated through the caller's reference. The copy is
assigned a unique integer id before being stored.
Module resolution order
tool.module_override(explicit full module path on the tool)tool.module(already resolved, e.g. from catalog deserialization){registry.package}.{tool.name}(default convention)
If none of these yield a module path, a :class:ValueError is raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
ToolDefinition
|
The :class: |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the tool's module cannot be resolved. |
Source code in src/agora_workbench/code_execution/tool_registry/tool_registry.py
get_tool_by_name(name)
¶
Return the tool registered under name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The tool's string name as supplied when it was registered. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
The |
ToolDefinition
|
class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no tool with that name is registered. |
Source code in src/agora_workbench/code_execution/tool_registry/tool_registry.py
get_tool_by_server_and_name(server_name, name)
¶
Return the tool registered under server_name and name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_name
|
str
|
The MCP server name the tool belongs to. |
required |
name
|
str
|
The tool's string name. |
required |
Returns:
| Type | Description |
|---|---|
ToolDefinition
|
The matching :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no matching tool can be found. |
Source code in src/agora_workbench/code_execution/tool_registry/tool_registry.py
get_tool_by_id(tool_id)
¶
Return the tool with the given integer registry ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_id
|
int
|
The integer ID assigned to the tool at registration time. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
The |
ToolDefinition
|
class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no tool with that ID is registered. |
Source code in src/agora_workbench/code_execution/tool_registry/tool_registry.py
get_id_by_name(name)
¶
Return the integer registry ID for the tool registered under name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The tool's string name. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The integer ID assigned to the tool at registration time. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no tool with that name is registered. |
Source code in src/agora_workbench/code_execution/tool_registry/tool_registry.py
get_name_by_id(tool_id)
¶
Return the name of the tool with the given integer registry ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_id
|
int
|
The integer ID assigned to the tool at registration time. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The string name of the registered tool. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no tool with that ID is registered. |
Source code in src/agora_workbench/code_execution/tool_registry/tool_registry.py
remove_tool_by_id(tool_id)
¶
Remove the tool with the given ID and update indexes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_id
|
int
|
The integer ID of the tool to remove. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no tool with that ID is registered. |
Source code in src/agora_workbench/code_execution/tool_registry/tool_registry.py
remove_tool_by_name(name)
¶
Remove the tool with the given name and update indexes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The string name of the tool to remove. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no tool with that name is registered. |
Source code in src/agora_workbench/code_execution/tool_registry/tool_registry.py
Tool Schema¶
agora_workbench.code_execution.tool_registry.tool_schema
¶
Pydantic models for tool definitions used by code execution servers.
This module provides strongly-typed schemas for tool registry entries, ensuring consistent structure and validation for tools registered on MCP code execution servers.
ToolParameter
¶
Bases: BaseModel
Schema for a tool parameter (required or optional).
ReturnSpec
¶
Bases: BaseModel
Specification for a single return value from a tool.
Tool implementation returns a dict mapping names to values
return {"builder": builder_obj, "model": model_obj, "summary": {...}}
State(token, description='', affordances=None)
¶
A named state in a domain's tool workflow graph.
States represent meaningful intermediate artifacts that tools produce and consume. They form the nodes in the state-transition graph that powers workflow planning and skill discovery.
Can be used directly in StateTransition.requires and
StateTransition.produces alongside plain strings::
MOLECULE_PARSED = State(
token="chemistry.molecule_parsed",
description="A SMILES string has been validated and canonicalized",
affordances=["validate a SMILES string", "identify a molecule from SMILES"],
)
parse_molecule = ToolDefinition(
...,
state_transition=StateTransition(produces=frozenset({MOLECULE_PARSED})),
)
Attributes:
| Name | Type | Description |
|---|---|---|
token |
Canonical string identifier (e.g. |
|
description |
Human-readable explanation of what this state represents. |
|
affordances |
Search phrases describing what achieving this state enables. |
Source code in src/agora_workbench/code_execution/tool_registry/tool_schema.py
StateTransition
¶
Bases: BaseModel
Preconditions and postconditions for a tool expressed as state tokens.
State tokens can be plain strings or :class:State objects. When
State objects are used, the token string is extracted for storage
and serialization. The requires set lists states that must hold
before the tool can run; produces lists states that will hold
after a successful invocation.
normalize_state_tokens(v)
classmethod
¶
Accept State objects, strings, or Enums and normalize to a frozenset of token strings.
Source code in src/agora_workbench/code_execution/tool_registry/tool_schema.py
ToolDefinition
¶
Bases: BaseModel
Schema for a complete tool definition in the registry.
By default, tool X is imported as from {package}.{X} import {X}
when registered in ToolRegistry(package=...). Override with module
or module_override for custom import paths.