Skip to main content

Overview

The Argent-native runtime is ArgentOS’s replacement for the upstream Pi Mono agent framework (@mariozechner/pi-*). Pi Mono’s creator joined OpenAI, making continued dependency on the upstream packages a strategic risk. The Argent runtime provides equivalent functionality with a cleaner architecture, native SIS lesson injection, and a multi-provider LLM layer. The runtime consists of two complementary layers:
  • argent-agent (src/argent-agent/) — Agent loop, session management, tool execution, compaction, skills
  • argent-ai (src/argent-ai/) — LLM provider implementations, model database, streaming, completion
A compatibility bridge (compat.ts) enables gradual migration by wrapping Argent providers as Pi-compatible streamSimple functions.

argent-agent: Agent Runtime

Agent Class

The core turn executor that orchestrates:
  1. Lesson injection via SIS — injects relevant lessons into the system prompt
  2. Provider calls — streaming or non-streaming LLM invocations
  3. Tool execution — processes tool calls from the LLM response
  4. Episode recording — captures structured episodes for contemplation
  5. History updates — appends turn results to session history

Session Manager

Append-only JSONL conversation storage with tree structure:
  • Tree-structured entries — each entry has id and parentId for branching support
  • Append-only JSONL — durable, crash-safe format
  • Built-in index — O(1) entry lookups (Pi rebuilds index on every access)
  • Explicit compaction tracking — tracks first-kept-entry for clean compaction
  • Format version 3 — session header, messages, thinking level changes, model changes

File Tools

Coding tools factory providing:
  • read_file — Read file contents
  • write_file — Write file contents
  • edit_file — Edit with diff
  • bash — Execute shell commands

Skills

Skills loaded from .md files with YAML frontmatter:

argent-ai: LLM Layer

Provider Registry

Central registry for LLM providers. Each provider implements the Provider interface:

Provider Implementations

Seven providers in src/argent-ai/providers/:

Models Database

Comprehensive model catalog with pricing, context windows, and capabilities:

Compatibility Bridge

The bridge enables gradual migration from Pi to Argent by wrapping Argent providers as Pi-compatible functions.

Thinking Level Resolution

Feature Flag

The Argent runtime is activated via the ARGENT_RUNTIME=true environment variable:
When enabled, the gateway routes to ArgentSessionManager instead of Pi’s session manager.

SIS Integration

The Argent runtime includes native SIS (Self-Improving System) integration:
  • Lesson Injection — Selects relevant lessons and injects them into the system prompt before each turn
  • Lesson Storage — Persists lessons extracted from agent episodes
  • Confidence Scoring — Scores lesson relevance to the current context
This closes the SIS feedback loop that was a stub in the Pi runtime — lessons extracted from episodes are actively injected back into agent prompts.

Migration Status

The Argent runtime is live in production. Pi code remains in the codebase for fallback but the feature flag routes all traffic through the Argent runtime.