pi-mojo is a native Mojo port of Pi—a popular, tool-efficient agentic AI platform (utilizing only 4 core tools) prominent in open-source systems like OpenClaw. It provides the Mojo community with a compiled, self-contained reference implementation to explore systems-level agent architectures, type-safe structures, and native C integrations.
🚀 Getting Started
Prerequisites
Ensure you have the Modular Mojo compiler installed:
Running Examples
The repository features progressive, systems-level agentic AI examples demonstrating the spectrum of agent architectures and compiled system execution capabilities:
🤖 Example 1: Progressive AI Completions & Chat (Sample Run)
A progressive exploration of text completions, starting from zero dependencies, local llm and live cloud LLMs.
mojo -I src examples/example_1_basic_ai/example_basic_ai.mojo
💻 Example 2: Systems Coding Agent (Sample Run)
A systems agent that translates high-level task descriptions into shell commands and executes them natively via system process spawning.
mojo -I src examples/example_2_coding_agent/example_coding_agent.mojo
🔧 Example 3: Native AI Tool Calling (Sample Run)
A cloud-only agent demonstrating how to expose native Mojo functions as tools (Function Calling) to a live LLM.
mojo -I src examples/example_3_tool_calling/example_tool_calling.mojo
🌊 Example 4: Real-Time AI Event Streaming (Sample Run)
A cloud-only completions stream demonstrating real-time streaming token parsing and flushed printing.
mojo -I src examples/example_4_event_stream/example_event_stream.mojo
⚡ Example 5: GPU-Accelerated Hardware Analytics (Sample Run)
A local performance benchmark executing parallel token classification on a hardware-accelerated GPU pipeline.
mojo -I src examples/example_5_gpu_analytics/example_gpu_analytics.mojo
🌐 Example 6: Concurrent Multi-URL Web Research Agent (Sample Run)
A concurrent web agent spawning parallel thread pools to fetch and sanitize multiple websites concurrently, then synthesizing research reports via Gemini 3.5 Flash.
mojo -I src examples/example_6_web_researcher/example_web_researcher.mojo
🔍 Example 7: Codebase Semantic Auditor & Refactoring Agent (Sample Run)
A systems security auditor agent crawling files dynamically and extracting zero-copy StringView lifetimes slices to synthesize refactoring proposals.
mojo -I src examples/example_7_codebase_auditor/example_codebase_auditor.mojo
🔁 Example 8: Long-Running Coder Agent (Sample Run)
An autonomous systems-level coding agent running in a persistent loop (Plan -> Act -> Observe -> Repeat) that maintains session state history, executes system commands, and solves multi-step engineering tasks.
mojo -I src examples/example_8_long_running_coder/example_long_running_coder.mojo --interactive
💓 Example 9: Local LLM Service Heartbeat Check (Sample Run)
A diagnostics checker that executes health queries and round-trip timing checks to verify the state of local LLM models on port 1234.
mojo -I src examples/example_9_local_heartbeat/example_local_heartbeat.mojo
🔄 Example 10: Towards Full-Fledged Agentic Loops (Sample Run)
An autonomous background-ticking daemon agent driven by a heartbeat clock that polls workspace states, monitors compilation status, patches error logs, and drives tasks to completion.
mojo -I src examples/example_10_full_fledged_agent/example_full_fledged_agent.mojo --interactive
🤖 Example 11: Playbook-Guided Autonomous Agent
An autonomous systems agent using the v0.2 playbook package to match tasks against a local repository of successful command playbooks (Alignment), and synthesize new ones upon success (Extraction).
mojo -I src examples/example_11_playbook_agent/example_playbook_agent.mojo --interactive
💾 Example 12: Crash-Resilient Durable Agent Loop
An autonomous systems agent using the v0.2 durable package to checkpoint its full state (messages, history, iteration index) to disk at every turn, enabling seamless recovery and completion after unexpected system crashes or restarts.
mojo -I src examples/example_12_durable_agent/example_durable_agent.mojo --interactive
🔬 Example 13: Basic Karpathy Autoresearch Loop
An autonomous systems agent implementing a basic Karpathy autoresearch loop (Propose -> Compile/Run -> Evaluate Metric -> Keep/Discard) to dynamically optimize a math compute kernel.
mojo run -I src examples/example_13_autoresearch/example_autoresearch.mojo
🏗️ High-Level System Architecture
pi-mojo unifies compiled, high-performance systems logic with dynamic agent loops. High-level agent packages leverage low-level subprocess utilities and filesystem caching tools to achieve zero-overhead execution.
In v0.2, we introduced the Autonomous Playbook package (src/packages/playbook/) to enable agents to learn from successful executions and avoid trial-and-error, as well as the Durable Checkpointing package (src/packages/durable/) to enable resilient state recovery across process boundaries. Each of the examples is built around a concrete systems-level story narrative.
For complete technical implementation details, sequence diagrams of the execution, and the repository directory layout, refer to ARCHITECTURE.md.
🎭 Real-World Systems Scenarios
For comprehensive, end-to-end systems engineering operations demonstrations, check out our dedicated Systems Storyboard Scenarios suite.
Instead of basic progressive API capability showcases, these scenarios are built around narrative-driven systems storyboards, including:
- Scenario 1: Onboarding Assistant - Environment checks and developer configs.
- Scenario 2: Git Sanitizer - Automated repo workspace untracked cleanup.
- Scenario 3: Thermal Monitor - Fast native thermodynamics tools.
- Scenario 4: Log Auditor - Real-time security events auditing stream.
- Scenario 5: GPU Benchmarker - Matrix multiplication latencies benchmarks.
- Scenario 6: Intel Aggregator - Multi-threaded release notes scrapers.
- Scenario 7: Lifecycle Leak Auditor - Zero-copy resource leaks scans.
- Scenario 8: Migration Assistant - Compilation diagnostic corrections.
- Scenario 9: Recovery Monitor - Service checks and failover playbooks.
- Scenario 10: CI Self-Healer Daemon - Autonomous background daemon.
- Scenario 11: Deep Research Agent - Multi-turn information gathering using multiple search APIs (Tavily, Exa, Brave, Google, Bing).
- Scenario 12: FlashInfer GPU Competition Optimizer - Closed-loop GPU kernel tuning cycle targeting FP8 MoE routing kernels for the MLSys 2026 contest.
For details on running these operations storyboards, see the Scenarios Hub README.
🛡️ License
Licensed under the MIT License (refer to the LICENSE file for details).



























