2.2 KiB
2.2 KiB
Notebook Workflow for Agent Tasks
This directory demonstrates a sovereign, version-controlled workflow for LLM agent tasks using Jupyter notebooks.
Philosophy
- **
.pyfiles are the source of truth** — authored and reviewed as plain Python with# %%` cell markers (via Jupytext) .ipynbfiles are generated artifacts — auto-created from.pyfor execution and rich viewing- Papermill parameterizes and executes — each run produces an output notebook with code, narrative, and results preserved
- Output notebooks are audit artifacts — every execution leaves a permanent, replayable record
File Layout
notebooks/
agent_task_system_health.py # Source of truth (Jupytext)
agent_task_system_health.ipynb # Generated from .py
docs/
NOTEBOOK_WORKFLOW.md # This document
.gitea/workflows/
notebook-ci.yml # CI gate: executes notebooks on PR/push
How Agents Work With Notebooks
- Create — Agent generates a
.pynotebook using# %% [markdown]and# %%code blocks - Review — PR reviewers see clean diffs in Gitea (no JSON noise)
- Generate —
jupytext --to ipynbproduces the.ipynbbefore merge - Execute — Papermill runs the notebook with injected parameters
- Archive — Output notebook is committed to a
reports/branch or artifact store
Converting Between Formats
# .py -> .ipynb
jupytext --to ipynb notebooks/agent_task_system_health.py
# .ipynb -> .py
jupytext --to py notebooks/agent_task_system_health.ipynb
# Execute with parameters
papermill notebooks/agent_task_system_health.ipynb output.ipynb \
-p threshold 1.0 -p hostname forge-vps-01
CI Gate
The notebook-ci.yml workflow executes all notebooks in notebooks/ on every PR and push, ensuring that checked-in notebooks still run and produce outputs.
Why This Matters
| Problem | Notebook Solution |
|---|---|
| Ephemeral agent reasoning | Markdown cells narrate the thought process |
| Stateless single-turn tools | Stateful cells persist variables across steps |
| Unreviewable binary artifacts | .py source is diffable and PR-friendly |
| No execution audit trail | Output notebook preserves code + outputs + metadata |