KernelBox¶
Persistent IPython kernels for your AI agents β without the Jupyter overhead.
Ever wished your AI agent could "just remember" variables between code executions? Or run Bash commands in the same session? KernelBox makes it happen. No notebook server, no bloat. Just pure execution power.
β‘ Quick Start¶
Get up and running in seconds.
Install via pip¶
Install via uv (Recommended)¶
π€ What is KernelBox?¶
KernelBox is a lightweight utility that talks directly to IPython kernels over ZeroMQ. It gives your agent a persistent Python session it can hold open, run code in, and read structured results from.
Why do you need it?¶
- State Persistence: Variables, imports, and functions stay in memory between calls.
- Agent-First: Built specifically for LLM agents that need to execute code and see results.
- Zero Overhead: No need to spin up a full Jupyter/Notebook server.
- Secure: Designed to run in isolated Docker environments.
π Quick Demo¶
See it in action:
from kernelbox import get_or_create, execute, destroy
# Get a kernel named "my-agent"
kernel = get_or_create("my-agent")
# Step 1: Define something
execute(kernel, "data = {'name': 'KernelBox', 'status': 'awesome'}")
# Step 2: It's still there!
result = execute(kernel, "data['name']")
print(result.return_value) # Output: KernelBox
# Clean up when done
destroy("my-agent")
β¨ Features at a Glance¶
- Named Sessions: Keep multiple agents isolated with unique session names.
- Rich Results: Get
stdout,stderr, andreturn_valuein a clean, structured object. - Self-Correction: Use
execute_with_retryto let your agent fix its own bugs. - Universal Interface: Use it via Python API, REST API (FastAPI), or CLI.
- Docker Ready: Pre-configured for secure, non-root execution.
πΊοΈ Where to go next?¶
- π Installation & Setup β Dive deeper into the setup.
- π Python API Guide β Master the library.
- π HTTP API Reference β Connect via REST.
- π» CLI Reference β Use it from the terminal.
- π‘οΈ Security First β Essential reading for production.
Built with β€οΈ for the agentic future.