Swarmauri code-execution tool for running notebook cells in an active IPython environment with captured output.
Project description
Swarmauri Tool Jupyter Execute Cell
swarmauri_tool_jupyterexecutecell is a Swarmauri code-execution tool for
running a single code cell inside the active IPython or Jupyter environment and
capturing stdout, stderr, and error information. It is useful for notebook
automation, agent-directed code execution, validation workflows, and interactive
runtime tooling.
Why Use Swarmauri Tool Jupyter Execute Cell
- Execute code snippets from Swarmauri workflows in a live notebook context.
- Capture stdout, stderr, and tracebacks in a structured response.
- Apply timeouts to code execution to avoid hanging runs.
- Reuse the same callable surface across automation, agents, and testing flows.
FAQ
What inputs does the tool accept?
A code string plus an optional timeout in seconds.
What does the tool return?
A dictionary containingstdout,stderr, anderror.
What happens when no active IPython kernel is available?
The tool returns an error payload indicating the kernel could not be found.
Does the tool execute asynchronously?
No. It executes synchronously and uses a thread-backed timeout guard.
Features
- Swarmauri
ToolBaseimplementation registered asJupyterExecuteCellTool. - Runs code in the active IPython/Jupyter environment.
- Captures stdout, stderr, and traceback information.
- Supports timeout-based interruption of long-running tasks.
- Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
Installation
uv add swarmauri_tool_jupyterexecutecell
pip install swarmauri_tool_jupyterexecutecell
Usage
from swarmauri_tool_jupyterexecutecell import JupyterExecuteCellTool
tool = JupyterExecuteCellTool()
result = tool("print('Hello from Swarmauri')", timeout=30)
print(result)
Examples
Execute a quick print statement
from swarmauri_tool_jupyterexecutecell import JupyterExecuteCellTool
tool = JupyterExecuteCellTool()
result = tool("print(2 + 2)")
print(result["stdout"])
Capture a runtime error
from swarmauri_tool_jupyterexecutecell import JupyterExecuteCellTool
tool = JupyterExecuteCellTool()
result = tool("raise ValueError('bad input')")
print(result["error"])
Register the tool in a Swarmauri collection
from swarmauri_standard.tools.ToolCollection import ToolCollection
from swarmauri_tool_jupyterexecutecell import JupyterExecuteCellTool
tools = ToolCollection(tools=[JupyterExecuteCellTool()])
print(tools)
Related Packages
- swarmauri_tool_jupyterruncell
- swarmauri_tool_jupyterstartkernel
- swarmauri_tool_jupytershutdownkernel
- swarmauri_tool_jupyterclearoutput
Swarmauri Foundations
More Documentation
Best Practices
- Keep executed code small and purposeful when running inside agents.
- Use timeouts for untrusted or potentially long-running cells.
- Inspect both
stderranderrorbefore assuming success. - Prefer explicit kernel lifecycle management in multi-step notebook workflows.
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_jupyterexecutecell-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_tool_jupyterexecutecell-0.11.0.dev1.tar.gz
- Upload date:
- Size: 9.7 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 |
ac3229c908c2749de1a5e06eed3d194b655d36e124162d5c0a708b620d06a122
|
|
| MD5 |
e2a7a9059fe2540033b80a0f8cce401d
|
|
| BLAKE2b-256 |
ccc94c453e0e6f6fd30005bb4a6f966d29462f61bcd3d9ee167171556d8a967a
|
File details
Details for the file swarmauri_tool_jupyterexecutecell-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_tool_jupyterexecutecell-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 10.8 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 |
dced00be6c813bb8b4da0a23df6ee7f6e345f07ecca51799a55506d70e4e0a5e
|
|
| MD5 |
95eae56a748642286ea4822ded46991c
|
|
| BLAKE2b-256 |
5d547da10e43382ba848b6b0ab54906482fb04c35d0512860e193fb9e7d1f51e
|