Skip to main content

Swarmauri IPython-execution tool for running code cells in an active interactive shell with captured output.

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_tool_jupyterruncell Discord

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 with cell_output, error_output, and success.

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 a success flag plus separated output fields.

Features

  • Swarmauri ToolBase implementation registered as JupyterRunCellTool.
  • 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 Foundations

More Documentation

Best Practices

  • Use short timeouts only for code you expect to complete quickly.
  • Inspect success before trusting cell_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

swarmauri_tool_jupyterruncell-0.11.0.dev1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Hashes for swarmauri_tool_jupyterruncell-0.11.0.dev1.tar.gz
Algorithm Hash digest
SHA256 00a4b6bf92707de900c93d823de56a8abdde390b3518a3aa28a88d1392122b6b
MD5 24f1d642ce59b81542f6d17e3ea16037
BLAKE2b-256 242c446f88ae3095879cc63de684cc4857938dce3e9845da6aca1641b023e263

See more details on using hashes here.

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

Hashes for swarmauri_tool_jupyterruncell-0.11.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 d08e4a746a2369fb8ef250dd4bddd0cfc3c7fd13a9eac3b0223dd132f52be2ae
MD5 781bff41bff22ca3ee617bb9cac65f1b
BLAKE2b-256 70eaac369c11cf5665c04bb141c460352b9729a88737f1cd66287759d9f0f0d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page