Swarmauri IPython-execution tool for running code cells in an active interactive shell with captured output.
Project description
Swarmauri Tool Jupyter Run Cell
swarmauri_tool_jupyterruncell is a Swarmauri IPython-execution tool for
running code inside the active interactive shell and capturing cell output,
error output, and success state. It is useful for notebook-style automation,
interactive assistants, teaching flows, and environments that already host an
IPython shell.
Why Use Swarmauri Tool Jupyter Run Cell
- Execute code directly inside the active IPython shell.
- Capture both successful output and exception traces in a consistent shape.
- Apply optional signal-based timeouts to interactive cell execution.
- Reuse an execution primitive across notebook and agent workflows.
FAQ
What inputs does the tool accept?
A code string and an optional timeout.
What does the tool return?
A dictionary withcell_output,error_output, andsuccess.
What happens if no IPython shell is active?
The tool returns a failed result with an explanatory error message.
How is this different from
jupyterexecutecell?
This tool is explicitly oriented around an already-running interactive IPython shell and returns asuccessflag plus separated output fields.
Features
- Swarmauri
ToolBaseimplementation registered asJupyterRunCellTool. - Executes Python code in the active IPython shell.
- Captures stdout and stderr-like error output into separate fields.
- Supports optional timeout-based interruption.
- Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
Installation
uv add swarmauri_tool_jupyterruncell
pip install swarmauri_tool_jupyterruncell
Usage
from swarmauri_tool_jupyterruncell import JupyterRunCellTool
tool = JupyterRunCellTool()
result = tool(code="print('hello')", timeout=5)
print(result)
Examples
Run a simple expression
from swarmauri_tool_jupyterruncell import JupyterRunCellTool
tool = JupyterRunCellTool()
result = tool("print(3 * 7)")
print(result["cell_output"])
Capture an exception
from swarmauri_tool_jupyterruncell import JupyterRunCellTool
tool = JupyterRunCellTool()
result = tool("1 / 0")
print(result["success"], result["error_output"])
Register the tool in a Swarmauri collection
from swarmauri_standard.tools.ToolCollection import ToolCollection
from swarmauri_tool_jupyterruncell import JupyterRunCellTool
tools = ToolCollection(tools=[JupyterRunCellTool()])
print(tools)
Related Packages
- swarmauri_tool_jupyterexecutecell
- swarmauri_tool_jupyterstartkernel
- swarmauri_tool_jupytershutdownkernel
- swarmauri_tool_jupyterclearoutput
Swarmauri Foundations
More Documentation
Best Practices
- Use short timeouts only for code you expect to complete quickly.
- Inspect
successbefore trustingcell_output. - Prefer controlled code snippets when exposing this tool to agents.
- Use this tool when you already have an active IPython shell rather than a separately managed Jupyter kernel session.
License
This project is licensed under the Apache-2.0 License.
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_tool_jupyterruncell-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_tool_jupyterruncell-0.11.0.dev1.tar.gz
- Upload date:
- Size: 9.1 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 |
00a4b6bf92707de900c93d823de56a8abdde390b3518a3aa28a88d1392122b6b
|
|
| MD5 |
24f1d642ce59b81542f6d17e3ea16037
|
|
| BLAKE2b-256 |
242c446f88ae3095879cc63de684cc4857938dce3e9845da6aca1641b023e263
|
File details
Details for the file swarmauri_tool_jupyterruncell-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_tool_jupyterruncell-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 10.1 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 |
d08e4a746a2369fb8ef250dd4bddd0cfc3c7fd13a9eac3b0223dd132f52be2ae
|
|
| MD5 |
781bff41bff22ca3ee617bb9cac65f1b
|
|
| BLAKE2b-256 |
70eaac369c11cf5665c04bb141c460352b9729a88737f1cd66287759d9f0f0d0
|