← Back to Plugins
Voice

Bee

skysphere-labs By skysphere-labs 👁 83 views ▲ 0 votes

BEE β€” Belief Extraction Engine: Cognitive memory plugin for OpenClaw that learns what matters about you and recalls it before every response

GitHub

Install

npm install

#

README

# BEE β€” Belief Extraction Engine

**Your AI assistant should know who you are without being told twice.**

BEE is an [OpenClaw](https://github.com/skysphere-labs/openclaw) plugin that gives your AI assistant persistent, local-first cognitive memory. It automatically extracts beliefs, preferences, facts, goals, and decisions from your conversations, stores them in a local SQLite database, and recalls relevant context before every response β€” so your assistant genuinely learns who you are over time.

---

## The Problem

Every AI assistant today suffers from the same fundamental limitation: **amnesia**.

- You tell your assistant you prefer concise answers β€” it forgets next session.
- You explain your tech stack, your role, your goals β€” gone after the conversation ends.
- You make a decision ("we're going with PostgreSQL") β€” your assistant won't remember tomorrow.

Commercial "memory" features are either cloud-dependent, shallow (keyword matching), or both. Your personal context β€” the things that make interactions feel natural and productive β€” shouldn't live on someone else's server, and it shouldn't require you to repeat yourself.

**BEE solves this.** It creates a local, structured memory layer that learns what matters about you and automatically brings it back when it's relevant.

## How It Works

BEE hooks into two points of the OpenClaw agent lifecycle:

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  AGENT LIFECYCLE                     β”‚
β”‚                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                β”‚
β”‚  β”‚ before_agent_start│──► RECALL                     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   Query beliefs DB             β”‚
β”‚           β”‚              Build <bee-recall> context   β”‚
β”‚           β–Ό              Prepend to agent context     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                β”‚
β”‚  β”‚   Agent Response  β”‚                               β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                β”‚
β”‚           β”‚                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                β”‚
β”‚  β”‚    agent_end      │──► EXTRACT                    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   Prefilter messages            β”‚
β”‚                         Classify & score beliefs      β”‚
β”‚                         Store in SQLite               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

### 1. Extract β€” Learning from conversation

After each agent turn, BEE processes the last few user messages through a multi-stage pipeline:

- **Prefilter**: Discards noise β€” acknowledgments ("ok", "thanks"), emoji-only messages, system messages, URLs without commentary, and short filler. Only messages with genuine belief signals pass through.
- **Classification**: Categorizes each belief as `identity`, `goal`, `preference`, `decision`, `fact`, or `implicit_inference`.
- **Confidence scoring**: Assigns a confidence score (0–1) based on linguistic signals β€” explicit first-person declarations score higher than ambiguous statements.
- **Decay sensitivity**: Tags each belief with how quickly it should fade (`low` for identity, `high` for transient facts).

### 2. Store β€” Local SQLite with structure

Beliefs are stored in a local SQLite database with WAL mode for performance:

```sql
beliefs (
  id, content, confidence, category, status,
  activation_score, decay_sensitivity,
  source, reasoning, context_summary,
  created_at, updated_at, last_relevant
)
```

Statuses include `active`, `provisional`, `archived`, and `flagged_for_review`. Beliefs with low confidence start as `provisional`.

### 3. Recall β€” Tiered retrieval before every response

Before the agent generates a response, BEE queries the belief database and constructs a context block with three tiers:

| Tier | What it contains | Selection criteria |
|---|---|---|
| **Core** | Durable identity, goals, strong preferences | High confidence, identity/goal/preference categories, never archived |
| **Active** | Recently relevant beliefs | Accessed or updated within last 7 days, sorted by activation score |
| **Recalled** | Beliefs relevant to the current prompt | Token-matched against the user's current message |

The tiers are deduplicated and size-capped (max 2200 chars) to avoid overwhelming the agent context. The result is injected as a `<bee-recall>` block prepended to the agent's context.

### 4. Profile Distillation β€” A synthesized "who you are"

On top of per-turn recall, BEE periodically distills your high-confidence beliefs (identity, goals, strong preferences) into a natural-language **user profile** β€” a 2–3 sentence summary of who you are and what you care about.

- Profile is regenerated asynchronously every N turns (default 50) or when the underlying belief set changes.
- Uses a lightweight LLM call (`claude-haiku`) to synthesize beliefs into prose.
- The profile is cached in SQLite (`bee_profile` table) and injected as a `<bee-profile>` block alongside the recall context.
- If no runtime is available, profile synthesis is gracefully skipped.

This gives the agent a stable, high-level understanding of the user that doesn't fluctuate turn-to-turn β€” think of it as long-term memory vs. the working memory of per-turn recall.

## Install

```bash
openclaw plugin install skysphere-labs/openclaw-bee
```

Zero config required. BEE will create its SQLite database at `~/.openclaw/workspace/state/bee.db` automatically.

## Configuration

All configuration is optional. Override via your OpenClaw plugin config:

| Key | Type | Default | Description |
|---|---|---|---|
| `dbPath` | string | `~/.openclaw/workspace/state/bee.db` | Path to the SQLite database file |
| `extractionModel` | string | `anthropic/claude-haiku` | Model used for belief extraction (Opus is blocked to prevent cost overruns) |
| `maxCoreBeliefs` | number | `10` | Maximum core beliefs recalled per turn |
| `maxActiveBeliefs` | number | `5` | Maximum active beliefs recalled per turn |
| `maxRecalledBeliefs` | number | `5` | Maximum prompt-relevant beliefs recalled per turn |
| `autoExtract` | boolean | `true` | Automatically extract beliefs after each agent turn |
| `autoRecall` | boolean | `true` | Automatically recall beliefs before each agent turn |
| `profileEnabled` | boolean | `true` | Enable profile distillation (synthesized user summary) |
| `profileRefreshTurns` | number | `50` | Regenerate profile every N turns (when beliefs change) |
| `debug` | boolean | `false` | Enable verbose logging |

## Architecture

```
src/
β”œβ”€β”€ index.ts        # Plugin entry β€” registers hooks, parses config
β”œβ”€β”€ types.ts        # TypeScript types (BeeConfig, BeliefRow, etc.)
β”œβ”€β”€ prefilter.ts    # Message prefilter β€” discards noise, passes signal
β”œβ”€β”€ extract.ts      # Belief extraction β€” classification, scoring, storage
β”œβ”€β”€ recall.ts       # Tiered recall β€” core/active/recalled + profile beliefs query
β”œβ”€β”€ profile.ts      # Profile distillation β€” LLM-synthesized user summary
β”œβ”€β”€ db.ts           # SQLite operations β€” schema, CRUD, queries
└── openclaw-plugin-sdk.d.ts  # OpenClaw plugin SDK type declarations
```

### Prefilter intelligence

The prefilter is the first line of defense against noisy extractions. It uses pattern matching to classify messages:

- **DISCARD**: "ok", "thanks", "nice", emoji-only, URLs, assistant messages, system messages
- **CONTEXT_ONLY**: Questions without personal info, imperative directives, pure task commands
- **PASS**: First-person declarations, messages with named entities/specifics, decision language, anything 4+ words that doesn't match a discard pattern

## Privacy

- **100% local** β€” all belief data stays on your machine in a SQLite file
- **No cloud storage** β€” nothing leaves your device unless you explicitly configure an extraction model that makes API calls
- **No telemetry** β€” BEE collects zero analytics or usage data
- **You own your data** β€” the SQLite database is a standard file you can inspect, export, or delete at any time

## Comparison

| Feature | BEE | Cloud-based memory (e.g. Supermemory) |
|---|---|---|
| Storage | Local SQLite | Cloud servers |
| Cost | Free & open source | ~$20/mo subscription |
| Privacy | Data never leaves your machine | Data stored on third-party servers |
| Extraction | LLM-powered semantic classification | Mostly regex/rules |
| Recall | Tiered (core/active/recalled) | Flat retrieval |
| Customization | Full config + open source | Limited |
| Offline | Works completely offline | Requires internet |

## Development

```bash
# Install dependencies
npm install

# Run prefilter tests
npm test

# Type check
npm run typecheck
```

## Requirements

- [OpenClaw](https://github.com/skysphere-labs/openclaw) >= 2026.2.0
- Node.js (for better-sqlite3)

## License

MIT β€” see [LICENSE](LICENSE)

---

Built by [Skysphere Labs](https://skyslabs.ai)
voice

Comments

Sign in to leave a comment

Loading comments...