Skip to content

fraction12/agentsense

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 AgentSense

Your AI agent doesn't just talk. It remembers who, what, and how things connect.

AgentSense is a knowledge graph memory plugin for OpenClaw. It watches your conversations, extracts the people, projects, tools, and decisions you discuss, and weaves them into a persistent web of relationships your agent can query instantly.

Think of it as giving your agent a second brain β€” not a pile of notes, but a map of your world.


Why?

OpenClaw already has memory. It chunks your markdown files, embeds them, and searches semantically. That's good for "what did we talk about?"

But it can't answer "who's connected to what?"

AgentSense can.

You: Tell me about Alice

graph_search β†’ alice chen [person]
                β†’ partner β†’ solar bid tool [project]
                    β†’ competes_with β†’ buildcost ai [company]
                    β†’ competes_with β†’ estimate pro [company]
                β†’ colleague β†’ bob martinez [person]

One query. Three hops. Relationships your agent never has to re-discover.


How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Your Conversations                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚    Plugin Hooks     β”‚
            β”‚  agent_end          β”‚
            β”‚  before_compaction  β”‚    ← Captures raw text
            β”‚  message_received   β”‚      (instant, free)
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚  Observations Table β”‚    ← SQLite buffer
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚   Extraction Cron   β”‚
            β”‚   (Haiku, hourly)   β”‚    ← Reads text, finds entities,
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      writes structured data
                       β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚   Knowledge Graph   β”‚
            β”‚  β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β” β”‚
            β”‚  β”‚Nodes β”‚β†’β”‚Edges β”‚ β”‚    ← People, projects, tools,
            β”‚  β””β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜ β”‚      decisions β€” all connected
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β–Ό             β–Ό             β–Ό
   graph_search    /graph cmd    auto-recall
   (agent tool)    (Telegram)    (context injection)

Capture is instant and free β€” hooks buffer raw conversation text. Extraction happens asynchronously via a cron job. Bring your own model. Query is local FTS5 β€” no API calls, no embedding costs.


Quick Start

1. Clone

git clone https://github.com/fraction12/agentsense.git ~/.openclaw/extensions/agentsense
cd ~/.openclaw/extensions/agentsense
npm install

2. Configure

Add to your openclaw.json:

{
  "plugins": {
    "allow": ["agentsense"],
    "slots": {
      "memory": "agentsense"
    },
    "load": {
      "paths": ["~/.openclaw/extensions/agentsense"]
    },
    "entries": {
      "agentsense": {
        "enabled": true,
        "config": {
          "autoCapture": true,
          "autoRecall": true
        }
      }
    }
  }
}

3. Restart

openclaw gateway restart

4. Verify

openclaw status
# Should show: Memory: enabled (plugin agentsense)

That's it. AgentSense will start capturing from your conversations immediately.


The Extraction Cron

AgentSense captures text automatically, but extraction requires an LLM. The plugin doesn't call any LLM directly β€” instead, you set up an OpenClaw cron job that reads pending observations and writes entities.

This is by design. Your model, your cost, your schedule.

Example cron setup (using Haiku under Claude Max β€” free):

Create a cron via OpenClaw that runs an isolated Haiku session hourly. The session reads pending observations from SQLite, extracts entities, and writes them back. See CRON_SETUP.md for the full prompt template.

Without the cron, observations accumulate but the graph stays empty. The plugin still works β€” memory_search and memory_get function normally, and you can manually add entities via SQLite.


What You Get

graph_search Tool

Your agent gets a new tool for structured entity lookup:

graph_search("Alice")
β†’ alice chen [person]
  β†’ partner β†’ solar bid tool [project]
  β†’ colleague β†’ bob martinez [person]

/graph Telegram Command

/graph              β†’ Stats overview
/graph search X     β†’ Find entities
/graph recent       β†’ Latest additions
/graph connections X β†’ All relationships for an entity
/graph types        β†’ Breakdown by entity type

Auto-Recall

The before_agent_start hook automatically injects relevant entities into your agent's context before every turn. No tool call needed β€” your agent just knows.

Preserved Memory Tools

AgentSense replaces memory-core as the memory plugin but re-registers memory_search and memory_get identically. Your existing memory system works exactly as before. The graph is additive.


Configuration

Option Default Description
autoCapture true Buffer conversation text via hooks
autoRecall true Inject graph context before agent turns
dbPath ~/.openclaw/memory/agentsense.db SQLite database location
captureMinMessageLength 50 Minimum text length to capture
maxRecallEntities 5 Max entities injected per turn

Entity Types

AgentSense recognizes: person, project, decision, event, idea, preference, place, tool, organization, company

Relationships are freeform strings: works_on, partner, built, uses, decided, prefers, employed_by, located_in, manages, created β€” whatever the extraction model finds.


Architecture Decisions

SQLite + FTS5, not Neo4j. A knowledge graph doesn't need a graph database. SQLite is single-file, zero-config, fast enough for thousands of nodes, and already a dependency via better-sqlite3.

Cron extraction, not inline. Early versions called Haiku directly from hooks. This required an API key, added latency, and crashed when the key expired. Moving extraction to a cron job means: zero API dependencies in the plugin, no hook failures, batch context for better extraction quality.

Memory plugin slot. AgentSense registers as kind: "memory", replacing memory-core in the plugin slot. This lets it re-register the standard memory tools while adding graph capabilities. Switch back to memory-core anytime β€” your graph data persists on disk untouched.

Eager DB initialization. The database initializes at plugin registration time, not in the service start() method. This prevents a race condition where hooks fire before the service is ready.


Rollback

Switch back to the default memory system in 30 seconds:

{
  "plugins": {
    "slots": {
      "memory": "memory-core"
    }
  }
}
openclaw gateway restart

Your graph database persists at ~/.openclaw/memory/agentsense.db. Re-enable AgentSense anytime and everything is still there.


Requirements

  • OpenClaw 2026.2.17+
  • Node.js 20+
  • better-sqlite3 (installed automatically)

File Structure

agentsense/
β”œβ”€β”€ index.ts              # Main entry β€” tools, hooks, commands, services
β”œβ”€β”€ graph-db.ts           # SQLite + FTS5 database layer
β”œβ”€β”€ config.ts             # Plugin configuration schema
β”œβ”€β”€ types.ts              # TypeScript type definitions
β”œβ”€β”€ extractor.ts          # Extraction prompt template + JSON parser
β”œβ”€β”€ hooks/
β”‚   β”œβ”€β”€ auto-capture.ts   # Buffers text on agent_end / before_compaction
β”‚   β”œβ”€β”€ auto-recall.ts    # Injects graph context on before_agent_start
β”‚   └── message-capture.ts # Captures individual messages
β”œβ”€β”€ tools/
β”‚   └── graph-search.ts   # graph_search agent tool
β”œβ”€β”€ cli/
β”‚   └── graph-cli.ts      # CLI commands (stats, search, entities)
β”œβ”€β”€ skill/
β”‚   └── SKILL.md          # Agent skill documentation
└── openclaw.plugin.json  # Plugin manifest

The Honest Truth

At small scale (< 100 nodes), AgentSense is mostly redundant with OpenClaw's built-in memory search. The embedding-based system finds the same information, often with richer context.

The graph earns its keep at scale. When you have hundreds of entities with dense connections, relationship queries β€” "who connects to what through whom?" β€” become something keyword and vector search fundamentally cannot do.

The auto-recall injection is useful from day one. Relevant entities pre-loaded into every turn, zero tool calls, zero latency.

Build the graph. Let it grow. The connections compound.


License

MIT


Built by Dushyant Garg & Jarvis β€” because an agent that forgets who you know isn't really paying attention.

About

🧠 Knowledge graph memory plugin for OpenClaw β€” your agent remembers who, what, and how things connect

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors