Catalog npm
Back to packageRELEASE DETAILS

0.2.3

npm

@0xkobold/pi-learn

Open-source memory infrastructure for pi agents - inspired by Honcho. Provides peer representations, reasoning, and context assembly for stateful AI agents.

agenthoncholearningmemorypi-package
Published6 Apr 2026
Direct dependencies12
Transitive dependenciesNot calculated

README

Current package documentation

@0xkobold/pi-learn

Open-source memory infrastructure for pi agents, inspired by Honcho.

Part of the 0xKobold ecosystem.

Installation

pi install npm:@0xkobold/pi-kobold
# pi-learn loaded as sub-extension automatically

Standalone

pi install npm:@0xkobold/pi-learn

# Or in pi-config.ts
{
  extensions: [
    'npm:@0xkobold/pi-learn'
  ]
}

# Or temporary (testing)
pi -e npm:@0xkobold/pi-learn

Features

  • Peer Representations: Build rich mental models of users through reasoning
  • LLM-Based Reasoning: Uses Ollama for embeddings and reasoning (local or cloud)
  • Context Assembly: Retrieves relevant context for agent prompts
  • Vector Search: Semantic similarity search using embeddings with keyword fallback
  • Dreaming: Background/creative reasoning synthesis
  • Observation Bridge: Unprocessed observations automatically flow into reasoning pipeline
  • Session Summarization: Auto-generates short and long summaries at message thresholds
  • Retention Policies: Automatic data pruning

Architecture

┌─────────────────────────────────────────────────────────────┐
│                        Pi-Learn                             │
├─────────────────────────────────────────────────────────────┤
│  Session Events    │  SQLiteStore   │  Reasoning Engine   │
│  ────────────────  │  ─────────────  │  ────────────────  │
│  • session_start   │  • Workspaces   │  • Message batch    │
│  • before_agent    │  • Peers        │  • Conclusions      │
│  • message_end     │  • Sessions     │  • Observations     │
│  • turn_end        │  • Messages     │  • Peer cards       │
│                    │  • Conclusions  │  • Summaries        │
│                    │  • Observations │  • Dreaming        │
├─────────────────────────────────────────────────────────────┤
│                    Ollama Integration                       │
│  ┌─────────────────┐        ┌─────────────────────────┐  │
│  │ Embeddings       │        │ Reasoning Model          │  │
│  │ nomic-embed-     │        │ (configurable)          │  │
│  │ text-v2-moe      │        │                          │  │
│  └─────────────────┘        └─────────────────────────┘  │
└─────────────────────────────────────────────────────────────┘

Data Model

Inspired by Honcho's hierarchical structure:

  1. Workspace: Top-level container (isolated namespaces)
  2. Peer: User, agent, or entity being observed
  3. Session: Interaction thread between peers
  4. Message: Individual conversation entries
  5. Observation: Raw observations stored before reasoning
  6. Conclusion: Synthesized insights from reasoning
  7. Representation: Aggregated peer knowledge

Reasoning Pipeline

Messages flow through a full pipeline:

  1. Add message → stored with processed=false
  2. learn_reason_now → fetches unprocessed observations, runs LLM reasoning, saves conclusions with embeddings, marks observations as processed
  3. autoSummarize → generates short summaries every 20 messages, long summaries every 60 messages
  4. searchSimilar → uses vector similarity (cosine similarity on embeddings) with keyword fallback

Conclusion Types

  • Deductive: Certain conclusions from explicit premises (90% confidence)
  • Inductive: Patterns observed across messages (70% confidence)
  • Abductive: Simplest explanations for behavior (50% confidence)

Peer Cards

Biographical cache:

  • Name, occupation
  • Interests, traits, goals
  • Updated through reasoning or manually

Dreaming

Dreaming is background reasoning that synthesizes deeper insights:

  • Runs on a schedule (configurable interval)
  • Looks at broader patterns across sessions
  • Generates creative hypotheses about the peer
  • Can update peer cards with insights

Retention Policies

Automatic data pruning:

  • Summaries: Default 30 days retention
  • Conclusions: Default 90 days retention
  • Messages: Forever by default (configurable)

Commands

CommandDescription
/learn statusShow memory status
/learn contextShow assembled context
/learn configShow configuration
/learn enableEnable reasoning
/learn disableDisable reasoning
/learn dreamTrigger dream cycle
/learn prunePrune old data

Tools (14 total)

ToolDescription
learn_add_messageAdd a message to memory
learn_add_observationStore raw observation for later reasoning
learn_add_messages_batchBatch add multiple messages
learn_get_contextRetrieve assembled peer context
learn_querySearch memory with embeddings
learn_reason_nowTrigger immediate reasoning on unprocessed observations
learn_trigger_dreamManually trigger dreaming
learn_get_peer_cardGet biographical info card
learn_update_peer_cardUpdate peer card manually
learn_list_peersList all peers in workspace
learn_get_statsGet memory statistics
learn_get_summariesGet peer summaries
learn_pruneTrigger retention pruning
learn_search_sessionsSearch sessions by keyword
learn_get_sessionGet specific session with messages
learn_list_sessionsList all sessions
learn_tag_sessionTag sessions for categorization

Configuration

{
  "learn": {
    "workspaceId": "default",
    "reasoningEnabled": true,
    "reasoningModel": "kimi-k2.5:cloud",
    "embeddingModel": "nomic-embed-text-v2-moe:latest",
    "tokenBatchSize": 1000,
    "dream": {
      "enabled": true,
      "intervalMs": 3600000,
      "minMessagesSinceLastDream": 5,
      "batchSize": 50
    },
    "retention": {
      "summaryRetentionDays": 30,
      "conclusionRetentionDays": 90,
      "retentionDays": 0
    }
  },
  "ollama": {
    "apiKey": "your-api-key"
  }
}

Environment variables:

  • LEARN_REASONING_MODEL - Override reasoning model
  • LEARN_EMBEDDING_MODEL - Override embedding model
  • LEARN_TOKEN_BATCH_SIZE - Override token batch size
  • OLLAMA_API_KEY - Override Ollama API key

API Functions

Library functions are importable for programmatic use:

// Core modules
import { SQLiteStore } from "@0xkobold/pi-learn/core/store";
import { ReasoningEngine, type ReasonedConclusion } from "@0xkobold/pi-learn/core/reasoning";
import { ContextAssembler } from "@0xkobold/pi-learn/core/context";

// Shared types and utilities
import { cosineSimilarity, GLOBAL_WORKSPACE_ID } from "@0xkobold/pi-learn/shared";

// CLI renderers
import { renderStats, renderPeerCard } from "@0xkobold/pi-learn/renderers";

// Use vector search
const store = new SQLiteStore(dbPath);
const results = await store.searchSimilar(workspaceId, peerId, "query text", 10);

// Manual reasoning
const reasoningEngine = new ReasoningEngine(ollama, model);
const conclusions = await reasoningEngine.reasonOnObservations(workspaceId, peerId, observations);

// Auto-summarize at thresholds
const assembler = new ContextAssembler(store, ollama, model);
await assembler.autoSummarize(workspaceId, peerId, reasoningEngine);

Local Storage

Data is stored in SQLite at ~/.pi/memory/pi-learn.db:

-- Tables
workspaces, peers, sessions, messages,
observations, conclusions, summaries, peer_cards

-- Indexes for performance
idx_conclusions_peer, idx_conclusions_created,
idx_summaries_peer, idx_messages_session

Ollama Requirements

Pi-learn requires Ollama running locally or via cloud:

  • Embeddings: nomic-embed-text-v2-moe:latest (required for semantic search)
  • Reasoning: Any Ollama chat model (default: kimi-k2.5:cloud)
# Pull required models
ollama pull nomic-embed-text-v2-moe:latest

# Pull your preferred reasoning model
ollama pull kimi-k2.5:cloud

Local Development

git clone https://github.com/0xKobold/pi-learn
cd pi-learn
npm install
npm run build
pi install ./

Changelog

See CHANGELOG.md for version history.

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 14

Native requirements
12 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
sql.js
Environment
{
  "local_name": "sql.js",
  "alias": false,
  "peer_metadata": null
}
^1.14.1runtime
@0xkobold/pi-ollama
Environment
{
  "local_name": "@0xkobold/pi-ollama",
  "alias": false,
  "peer_metadata": null
}
^0.2.0runtime
vitest
Environment
{
  "local_name": "vitest",
  "alias": false,
  "peer_metadata": null
}
^4.1.1development
esbuild
Environment
{
  "local_name": "esbuild",
  "alias": false,
  "peer_metadata": null
}
^0.24.2development
bun-types
Environment
{
  "local_name": "bun-types",
  "alias": false,
  "peer_metadata": null
}
^1.3.11development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5.9.3development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^25.5.0development
@types/sql.js
Environment
{
  "local_name": "@types/sql.js",
  "alias": false,
  "peer_metadata": null
}
^1.4.11development
@sinclair/typebox
Environment
{
  "local_name": "@sinclair/typebox",
  "alias": false,
  "peer_metadata": null
}
^0.34.48development
@mariozechner/pi-tui
Environment
{
  "local_name": "@mariozechner/pi-tui",
  "alias": false,
  "peer_metadata": null
}
^0.62.0development
@mariozechner/pi-coding-agent
Environment
{
  "local_name": "@mariozechner/pi-coding-agent",
  "alias": false,
  "peer_metadata": null
}
^0.62.0development
ollama
Environment
{
  "local_name": "ollama",
  "alias": false,
  "peer_metadata": null
}
>=0.6.0peer
@sinclair/typebox
Environment
{
  "local_name": "@sinclair/typebox",
  "alias": false,
  "peer_metadata": null
}
>=0.32.0peer
@mariozechner/pi-coding-agent
Environment
{
  "local_name": "@mariozechner/pi-coding-agent",
  "alias": false,
  "peer_metadata": null
}
>=0.62.0peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "9674e0299498fc1c3cd71ecd4fe6b5acfbe3f155",
  "tarball": "https://registry.npmjs.org/@0xkobold/pi-learn/-/pi-learn-0.2.3.tgz",
  "fileCount": 57,
  "integrity": "sha512-Sh3jVYYtI8vmtYlG7EuYAWMoi6L5ZlB380MAFt3jdZXELbKQSMxBADsP/CevX5uJ9I9k3HKtga7pv+xQloCfuA==",
  "signatures": [
    {
      "sig": "MEUCIHEVD8GFwAEUg/gLrOArxOqEdkv6668jkV6qdKZysaRtAiEAzty02OHU1YxmnQ/arbzzBBLAfCWO0YMSf04YhuYtgs8=",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 582561
}

Repository

ACCESSIBLE
0xkobold/pi-learn

Shared repository data · GitHub

License detected in repository
Not collected
Last push
8 Apr 2026
Archived
No
Contributor identities
— · partial collection

Public sponsor counts have not been collected. These signals belong to the repository owner.

Downloads & popularity

0count
Gauge · observed snapshots22 Oct 2026
10.50
2026-10-22: 0 · observed 2026-10-22T13:25:06.0686764Z
22 Oct22 Oct

github · 1 observations shown. Missing days are unknown.

View observed values
Date / source periodValueObserved at
2026-10-2202026-10-22T13:25:06.0686764Z

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 09:03 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:8a71a3e0abdff9be2298bfd8f65d89bff600bd0e1ca956fbbd610286166776b0

Other collected versions

0.4.09 Apr0.3.07 Apr0.2.23 Apr0.2.124 Mar0.2.024 Mar0.1.024 MarView all collected versions →