Runtime toolkit for explicit-parameter registration, inspection, replacement, listing, and removal of Swarmauri tools during agent execution.
Project description
Swarmauri Toolkit RuntimeToolkit
RuntimeToolkit is a Swarmauri runtime-management toolkit for agents that need to register, inspect, list, replace, and remove tools during execution. It keeps tool mutation inside the active toolkit instance and requires both explicit parameter declarations and an explicit __call__ implementation when a new runtime tool is introduced.
Features
- Bundles agent-callable CRUD operations for toolkit members.
- Accepts serialized runtime tool specs with
type,parameters, and__call__fields. - Enforces a non-empty declared
parameterslist and a non-empty__call__body for runtime tool registration and replacement. - Evaluates runtime
__call__bodies through a restricted expression rail rather than unrestricted Python execution. - Returns agent-friendly dictionaries for reads, lists, and mutation results.
- Protects the toolkit's own management tools from accidental overwrite or removal.
- Supports Python 3.10 through 3.12.
Support
- Python
3.10 - Python
3.11 - Python
3.12
Installation
uv
uv add swarmauri_toolkit_runtime
pip
pip install swarmauri_toolkit_runtime
Usage
Use RuntimeToolkit when an agent needs to mutate its own tool surface safely at runtime. The expected workflow is:
- Start with the management toolkit.
- Register a runtime tool using an explicit parameter contract and explicit callable body.
- Inspect or list the available runtime tools.
- Execute the registered tool.
- Replace or unregister the tool when the runtime surface changes.
Instantiate the toolkit and hand it to an agent or tool-capable model. The toolkit starts with only its management tools, then grows as the agent adds tools.
from swarmauri_toolkit_runtime import RuntimeToolkit
toolkit = RuntimeToolkit()
toolkit.get_tool_by_name("RegisterRuntimeTool")(
{
"type": "RuntimeAdditionTool",
"name": "RuntimeAdditionTool",
"description": "Adds two integers during the active agent session.",
"parameters": [
{
"name": "x",
"input_type": "integer",
"description": "The left operand",
"required": True,
},
{
"name": "y",
"input_type": "integer",
"description": "The right operand",
"required": True,
},
],
"__call__": '{"sum": str(x + y)}',
}
)
result = toolkit.get_tool_by_name("RuntimeAdditionTool")(2, 3)
print(result)
Agent Workflow
- Call
ListRuntimeToolsto inspect the current runtime surface. - Call
RegisterRuntimeToolwith a tool spec to extend the toolkit. - Call
InspectRuntimeToolto inspect the hydrated tool metadata. - Call
ReplaceRuntimeToolwhen the agent needs to replace a tool with a revised spec. - Call
UnregisterRuntimeToolwhen a runtime tool should no longer be available.
Tool Spec Contract
Mutation tools accept a serialized tool specification. At minimum, provide:
- a non-empty
typefield that names the runtime tool surface - a non-empty
parameterslist that explicitly declares the runtime callable contract - a non-empty
__call__string that evaluates as a safe Python expression over the declared parameters and approved builtins
The runtime evaluator permits only a constrained expression subset and approved builtins such as str, int, float, len, sum, min, max, and abs. Imports, attribute traversal, and arbitrary function calls are rejected.
{
"type": "RuntimeAdditionTool",
"name": "RuntimeAdditionTool",
"description": "Adds two integers.",
"parameters": [
{
"name": "x",
"input_type": "integer",
"description": "The left operand",
"required": True,
},
{
"name": "y",
"input_type": "integer",
"description": "The right operand",
"required": True,
},
],
"__call__": '{"sum": str(x + y)}',
}
The __call__ value is evaluated against the declared parameter names. A body such as {"sum": str(x + y)} is valid. A body that tries to import modules, access attributes, or reference undeclared names is rejected.
Failure Modes
- Registration fails when the tool spec omits
parameters. - Registration fails when the tool spec omits
__call__. - Registration fails when the
__call__body uses unsafe syntax or disallowed names. - Registration fails when the tool name collides with a protected management tool.
- Execution failures inside an accepted runtime tool return a structured error payload instead of propagating a hard exception or terminating the host process.
- Replacement fails when the target tool is missing, reserved, or renamed to an existing tool.
- Unregistration fails when the target is reserved or absent.
License
swarmauri_toolkit_runtime is released under the Apache 2.0 License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmauri_toolkit_runtime-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_toolkit_runtime-0.11.0.dev1.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aef3653dbf0f70eb5fdecab60e00fda3c97b0f120257ab0626ceb591a7b7dc62
|
|
| MD5 |
a4307fe2a7fe14a9f9f39a99e9bc7911
|
|
| BLAKE2b-256 |
24129a9e944a162e5caa15997936b23f5608f8ac8b655541cefb2805cd2e468d
|
File details
Details for the file swarmauri_toolkit_runtime-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_toolkit_runtime-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
167a3c36d2ed9075a34d8bc0b72bd8eb3f82eccb50ec73bdc1bb118baefe177f
|
|
| MD5 |
7f6b6e2d455727220c54ee870169f2e7
|
|
| BLAKE2b-256 |
c1f62c291534673657e23c0096a630e4e18f173aaac85711877b47613ce547e0
|