A persistent Python notebook for AI agents, driven from the CLI
Project description
agentnb
A persistent project-scoped Python REPL for coding agents, exposed through a simple CLI.
Status: alpha. Expect rough edges and breaking changes. Use in local development workflows at your own risk.
Why
Agents can run shell commands, but they lose state when using one-off python -c and script invocations. agentnb gives agents a long-running IPython kernel they can drive with CLI commands, so they can explore incrementally, keep expensive setup in memory, inspect live variables, and recover without restarting from scratch on every step.
The right mental model is a persistent REPL for agents, or an append-only notebook without a notebook UI. agentnb keeps execution state and history, but it does not edit notebook cells or manage .ipynb files.
Install
uv add agentnb
# or
pip install agentnb
Quick Start
agentnb start --project /path/to/project --json
agentnb exec "from myapp.models import User" --json
agentnb exec "u = User(name='test'); print(u)" --json
agentnb vars --json
agentnb stop --json
Recommended Workflow
The normal agent loop is:
agentnb start --jsonagentnb exec "..." --jsonagentnb vars --jsonagentnb inspect NAME --jsonagentnb reload MODULE --jsonafter source editsagentnb history --json
Use agentnb doctor --json if startup fails, agentnb interrupt --json if execution hangs, and agentnb reset --json if the namespace needs a clean slate.
If startup reports that ipykernel is missing, rerun agentnb start with
--auto-install or use agentnb doctor --fix --json.
Running agentnb with no arguments, or agentnb --help, prints an agent-oriented command guide and workflow summary.
Positioning
agentnb is optimized for stateful agent iteration inside a project:
- a persistent REPL the agent can keep using across steps
- a lightweight append-only notebook model backed by execution history
- module reload and variable inspection without a notebook editor
It is not a notebook editing tool:
- it does not edit cells
- it does not write
.ipynbfiles - it does not synchronize with JupyterLab
Commands
agentnb start [--project PATH] [--python PATH] [--auto-install]agentnb status [--project PATH]agentnb exec [CODE] [-f FILE] [--timeout SECONDS] [--project PATH] [--json]agentnb vars [--project PATH] [--json] [--types]agentnb inspect NAME [--project PATH] [--json]agentnb reload MODULE [--project PATH] [--json]agentnb history [--project PATH] [--errors] [--json]agentnb interrupt [--project PATH] [--json]agentnb reset [--project PATH] [--json]agentnb stop [--project PATH] [--json]agentnb doctor [--project PATH] [--python PATH] [--fix] [--json]
Out-of-the-box startup
On agentnb start, the runtime selects an interpreter in this order:
--pythoninterpreter<project>/.venvinterpreter- active
VIRTUAL_ENVinterpreter - current Python executable
If ipykernel is missing for the selected interpreter, agentnb start fails
with the exact install command. Pass --auto-install to let agentnb install
it for you, or use agentnb doctor --fix --json.
JSON Mode
Pass --json to emit a stable machine-readable envelope. This is the preferred mode for agent integrations.
{
"schema_version": "1.0",
"status": "ok",
"command": "exec",
"project": "/path/to/project",
"session_id": "default",
"timestamp": "2026-03-08T21:00:00+00:00",
"data": {
"status": "ok",
"stdout": "",
"stderr": "",
"result": "42",
"execution_count": 1,
"duration_ms": 12
},
"suggestions": [
"Run `agentnb vars --json` to inspect the updated namespace.",
"Run `agentnb inspect NAME --json` to inspect a specific variable.",
"Run `agentnb history --json` to review prior executions."
],
"error": null
}
How It Works
agentnb starts an IPython kernel process and stores connection/session metadata under .agentnb/ in the target project. CLI commands connect via Jupyter messaging protocol.
Architecture
SessionStore: project/session metadata, stale cleanup, historyKernelRuntime: lifecycle + execution APIRuntimeBackend: backend interface, with local IPython backend for v0.1NotebookOps: vars/inspect/reload semantic operationsOutputContract: human + JSON output from one response envelopeHooks: no-op extension points for future policy/plugins/telemetry
Development
uv sync --extra dev
uv run ruff check src tests
uv run ruff format --check src tests
uv run ty check src
uv run pytest
License
MIT
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 agentnb-0.1.0.tar.gz.
File metadata
- Download URL: agentnb-0.1.0.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00cc3609a7dfc0a64839019e80cbb25755d5c7acd1cc40fd399c5edcc65c667c
|
|
| MD5 |
52c959114ad59d976b2aabc39686ac30
|
|
| BLAKE2b-256 |
b3392cd53bde7f68ca32553bd4c7483af3d16444157ee72013abda1563f95327
|
Provenance
The following attestation bundles were made for agentnb-0.1.0.tar.gz:
Publisher:
publish.yml on oegedijk/agentnb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentnb-0.1.0.tar.gz -
Subject digest:
00cc3609a7dfc0a64839019e80cbb25755d5c7acd1cc40fd399c5edcc65c667c - Sigstore transparency entry: 1067072085
- Sigstore integration time:
-
Permalink:
oegedijk/agentnb@1f11116c712c078722ac0c9a48bfb3bfb23d28e0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/oegedijk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1f11116c712c078722ac0c9a48bfb3bfb23d28e0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file agentnb-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agentnb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99efe07e91849a0eb4945109d4a61426ba1248aea7023376b1d855897938dc5d
|
|
| MD5 |
977a082d26b6ea252927b2346c945561
|
|
| BLAKE2b-256 |
0f238ef397b96999fda49929ce560ce58c42e0c7157232cf83aa972c1903c04a
|
Provenance
The following attestation bundles were made for agentnb-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on oegedijk/agentnb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentnb-0.1.0-py3-none-any.whl -
Subject digest:
99efe07e91849a0eb4945109d4a61426ba1248aea7023376b1d855897938dc5d - Sigstore transparency entry: 1067072150
- Sigstore integration time:
-
Permalink:
oegedijk/agentnb@1f11116c712c078722ac0c9a48bfb3bfb23d28e0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/oegedijk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1f11116c712c078722ac0c9a48bfb3bfb23d28e0 -
Trigger Event:
push
-
Statement type: