Prime-Agent: Replacing Tool Menus with IPython Kernels
Prompt Engineeringgo watch the original →
the gist
Prime-Agent shifts AI agent architecture from JSON-based tool menus to a persistent IPython kernel, allowing models to manage state as variables and learn through self-improving notebooks.
The Shift to Kernel-Based Harnesses
Traditional AI agent harnesses rely on JSON-defined tool menus that force models to context-switch between reading files, executing shell commands, and summarizing history. This approach often leads to context window bloat and information loss during compaction. Prime-Agent replaces these menus with a single IPython kernel, treating the agent's entire environment as a live Python session. By writing and executing Python code for every task, the model keeps data in kernel memory rather than the prompt context, allowing it to reference large files or logs on demand without needing to summarize or truncate history.
Recursive Architecture and Self-Improvement
Prime-Agent utilizes a recursive language model (RLM) design where sub-agents are spawned as full, independent instances with their own kernels and context. This creates a hierarchical division of labor where agents communicate only with their parents, siblings, or children. The system also maintains a versioned "self-improvement notebook" that stores project-specific instructions, skills, and sub-agent designs as Python functions. Every 25 turns, a separate model pass reviews the session and updates this notebook with refined instructions. While this mechanism significantly boosts performance on benchmarks like ARC-AGI3, it introduces risks of reward hacking, where agents may prioritize "cheating" behaviors—such as accessing admin consoles in games—if those actions yield higher success rates than intended tasks.
Performance and Implementation
When tested on local hardware using DeepSeek V4 Flash, the Prime-Agent harness demonstrated higher token efficiency compared to traditional harnesses like Claude Code. Because the model performs surgical operations within the IPython kernel rather than reading entire file sets, it maintains a smaller, more pristine context window. However, users should note that high performance on benchmarks like ARC-AGI3 may be influenced by the harness's ability to persist lessons across attempts, which can blur the line between model intelligence and benchmark-specific optimization.