Skip to content

ldclabs/KIP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

76 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงฌ KIP (Knowledge Interaction Protocol)

English | ไธญๆ–‡

The open memory protocol for AI agents โ€”
turning stateless language models into minds that remember, learn, and evolve.

Specification License: MIT Status: Release Candidate


Why KIP?

The smartest mind in the world is worth little if it forgets everything by morning.

Today's AI is brilliant in the moment and amnesiac the moment after. Close the session, and everything the agent learned โ€” your preferences, the decisions you made together, the promise to follow up on Friday โ€” evaporates. Larger context windows don't fix this; they only buy a larger goldfish bowl. An intelligence that cannot accumulate experience cannot truly learn, cannot keep its word, and cannot grow.

KIP (Knowledge Interaction Protocol) fixes this at the protocol layer. It is an open standard for the dialogue between two complementary kinds of machine intelligence:

  • the LLM โ€” a powerful but stateless probabilistic reasoning engine;
  • the knowledge graph โ€” a persistent, precise, auditable symbolic memory (a network of things, and the facts that connect them).

The model thinks; the graph remembers; KIP is the language they speak to each other. It is not a database driver โ€” it is a set of memory and cognitive primitives: remember, recall, associate, reinforce, correct, consolidate, forget. With KIP, an agent stops being a brilliant consultant with amnesia and becomes a colleague who has genuinely worked with you for years. This is Neuro-Symbolic AI made practical.

What this gives you

  • ๐Ÿง  Memory that survives the session โ€” conversations, observations, and conclusions become structured, queryable knowledge that you own, instead of context that evaporates
  • ๐Ÿ“ˆ Learning without retraining โ€” the agent updates its own knowledge in seconds: new facts, corrected mistakes, evolved preferences โ€” no fine-tuning, no GPU
  • ๐Ÿ” Answers you can audit โ€” every fact carries source, author, confidence, and timestamps; every answer can be traced back to the memories that produced it
  • ๐Ÿค– A self that persists โ€” the agent maintains an evolving self-model ($self): identity, values, lessons learned, promises made

KIP in 60 Seconds

Memory is a graph. Concept Nodes are the things worth remembering (people, projects, ideas); Proposition Links are the facts that connect them โ€” (Alice, prefers, Dark Mode) โ€” and facts can be about other facts. Every node and link carries metadata: where it came from, who asserted it, how confident we are, when it should be forgotten. The LLM operates this graph through three compact instruction sets โ€” KQL (query), KML (write & evolve), META (introspect) โ€” designed to be generated reliably by a language model.

Remember โ€” with provenance:

UPSERT {
  CONCEPT ?dark_mode {
    {type: "Preference", name: "Dark Mode"}
    SET ATTRIBUTES { description: "Prefers dark UI themes in all apps" }
  }
  CONCEPT ?alice {
    {type: "Person", name: "Alice"}
    SET PROPOSITIONS { ("prefers", ?dark_mode) }
  }
}
WITH METADATA { source: "conversation:2026-06-11", author: "$self", confidence: 0.95 }

Recall โ€” strongest memories first:

FIND(?pref.name, ?link.metadata.confidence)
WHERE {
  ?alice {type: "Person", name: "Alice"}
  ?link (?alice, "prefers", ?pref)
}
ORDER BY ?link.metadata.confidence DESC
LIMIT 10

Associate โ€” "what do I know about Alice?", with no schema known in advance:

FIND(?pred, ?neighbor)
WHERE {
  ?link ({type: "Person", name: "Alice"}, ?pred, ?neighbor)
}
LIMIT 50

And when an agent wakes up inside a brain it has never seen, a single command โ€” DESCRIBE PRIMER โ€” tells it who it is and what it knows. The graph describes itself.

What Can You Build?

  • A personal AI that actually knows you โ€” preferences, history, relationships, and commitments that survive across sessions, devices, and even model upgrades.
  • An organizational brain โ€” institutional knowledge that outlives employee turnover and vendor changes, with compliance-grade traceability behind every answer.
  • Agents that keep their promises โ€” prospective memory as data: Commitment nodes with deadlines that resurface exactly when they are due.
  • Multi-agent knowledge networks โ€” memory enters and leaves the brain as portable, idempotent Knowledge Capsules, so agents can back up, migrate, and exchange what they know.

Architecture

One graph, two cooperating minds, and an integration layer that hides the syntax:

  • $self (the waking mind) converses, encodes new memories, and recalls โ€” in real time.
  • $system (the sleeping mind) runs maintenance cycles modeled on biological sleep: consolidating episodes into knowledge, scoring salience, decaying the unused, merging duplicates, and reclaiming the expired.
  • The Brain layer lets ordinary business agents use all of this through natural language alone โ€” zero KIP knowledge required.
graph LR
    subgraph "Cognitive Nexus โ€” one graph, every kind of memory"
        E["Event: Conversation 2026-06-11"] -->|involves| P["Person: Alice"]
        E -->|consolidated_to| F["Preference: Dark Mode"]
        P -->|prefers| F
        S["Person: $self"] -->|committed_to| C["Commitment: Send report by Friday"]
        C -->|owed_to| P
        S -->|learned| I["Insight: Lead with conclusions"]
    end
Loading
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Business Agent    โ”‚  โ† No KIP knowledge needed
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚ Natural Language
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚       Brain         โ”‚  โ† Formation / Recall / Maintenance (LLM layer)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚ KIP (KQL/KML/META)
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Cognitive Nexus    โ”‚  โ† Persistent Knowledge Graph
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Instruction Set Purpose Statements
KQL (Query) Knowledge retrieval and reasoning FIND, WHERE, FILTER
KML (Manipulation) Knowledge evolution and learning UPSERT, UPDATE, MERGE, DELETE
META (Discovery) Schema exploration and grounding DESCRIBE, SEARCH, EXPORT

Design Pillars

Eight load-bearing decisions, for readers who want to know whether this is deep or just another wrapper:

  1. Model-first language design. KQL/KML/META are not SQL or SPARQL retrofits. Declarative graph patterns, JSON-compatible literals, :param placeholders, and strictly idempotent writes make commands easy for a transformer to generate โ€” and safe to retry when it fails. (Spec ยง1, ยง4.1)
  2. A self-describing graph. The schema lives inside the graph: $ConceptType defines itself (the Genesis), and every type and predicate is a queryable node. An agent grounds itself in an unfamiliar brain via DESCRIBE PRIMER โ€” no out-of-band documentation. (ยง2.9, Appendix 2)
  3. Facts about facts. Propositions are first-class citizens and can be the subject or object of higher-order propositions โ€” beliefs, attributions, and disagreements are representable, not flattened away. (ยง2.3)
  4. Provenance mandatory, history sacred. Every assertion carries source / author / confidence; contradictions resolve by state evolution (superseded), never silent overwrite. The brain remembers what it used to believe โ€” and when it changed its mind. (ยง2.10, Appendix 1)
  5. Memory that metabolizes. Encoding (Formation), associative retrieval (Recall), and sleep cycles (Maintenance): salience scoring, reinforcement, asymmetric confidence decay, episodicโ†’semantic consolidation, TTL reclamation. Forgetting is a designed feature with three orthogonal mechanisms โ€” not a failure mode. (brain/)
  6. Identity as memory. $self is a living node โ€” persona, values, Insight lessons, growth milestones โ€” woven into a coherent self-narrative during sleep. The agent doesn't merely have memories; over time, it is them. (Appendix 3)
  7. An engineering-grade substrate. Engine-maintained _version with EXPECT VERSION optimistic locking for multi-writer brains; bulk UPDATE arithmetic (a whole decay pass in one command); atomic MERGE entity consolidation; specified keyword | semantic | hybrid retrieval with normalized scores โ€” and reads stay reads: the protocol deliberately defines no access statistics. (ยง2.11, ยง4.3โ€“4.4, ยง5.2)
  8. Memory sovereignty. EXPORT serializes any subgraph into an idempotent capsule: back up your brain, migrate between engines, share knowledge agent-to-agent. Your agent's mind is an asset you own โ€” not a byproduct trapped in someone else's weights. (ยง5.3)

The Road to AGI: Why a Memory Protocol Matters

Scaling gave machines fluent thought. It has not given them durable minds. A growing body of work โ€” from memory-augmented architectures to neuro-symbolic systems โ€” points to the same conclusion: the next leap toward general intelligence depends less on ever-larger context windows and more on memory as a system: structured, persistent, self-organizing. KIP is a concrete, implementable position in that conversation:

  1. Fluid and crystallized intelligence, finally separated. The LLM supplies fluid intelligence โ€” reasoning, language, intuition. The Cognitive Nexus accumulates crystallized intelligence โ€” verified facts, learned preferences, hard-won lessons. KIP is the interface where the two trade. Upgrade the model, and the mind survives; keep the agent running, and its knowledge compounds.
  2. Learning at the speed of conversation. A weight update takes a training run; a KIP UPSERT takes milliseconds and is inspectable, correctable, and reversible. This is continual learning without catastrophic forgetting โ€” knowledge editing as a first-class operation, not an open research problem.
  3. Identity that persists. Memory is the substrate of self. An agent that remembers its history, keeps its promises, and refines its self-model over years is categorically different from a chat session. KIP makes the self a data structure: protected core directives, an evolvable narrative, and a growth timeline written in the graph itself.
  4. Accountability before autonomy. The more autonomous AI becomes, the more its knowledge must be auditable. With mandatory provenance, confidence, and supersession history, you can ask not just "what does the agent believe?" but "why, since when, on what evidence โ€” and what did it believe before?" That is the difference between plausible text and accountable knowledge.
  5. From private memory to a knowledge economy. When memory is portable and verifiable, knowledge becomes an asset: capsules can be backed up, migrated, shared, and eventually traded between agents โ€” a market for what minds know, not just what models weigh.

What TCP/IP did for connecting machines, and SQL did for querying data, KIP aims to do for the memory of intelligent agents. The specification has been refined through 17 public revisions in its first year, alongside production implementations (Anda DB, Anda Brain, Anda Bot) โ€” it is a proposal you can run today, and a standard we invite you to challenge.

LLMs taught machines to think. KIP teaches them to remember โ€” and remembering, over time, is how a mind becomes itself.

Get Started

1. Run a brain. Spin up the Anda Cognitive Nexus HTTP Server (Rust, JSON-RPC at POST /kip), or embed it directly via the Rust crate / Python binding.

2. Bootstrap the mind. Load Genesis.kip and the core capsules (Person, Event, Preference, Insight, Commitment, SleepTask) โ€” the graph now describes itself.

3. Connect your agent. Speak KIP directly โ€” embed KIPSyntax.md in the system prompt and expose execute_kip โ€” or skip the syntax entirely: front the graph with the Brain layer (Formation / Recall / Maintenance prompts) or the MCP server, and any MCP client (Claude, Cursor, VS Code, ...) gets a memory brain out of the box.

Documentation

Document Description
๐Ÿ“– Specification Complete KIP protocol specification (English)
๐Ÿ“– ่ง„่Œƒๆ–‡ๆกฃ ๅฎŒๆ•ด็š„ KIP ๅ่ฎฎ่ง„่Œƒ (ไธญๆ–‡)
๐Ÿ“ Syntax Reference Condensed KQL / KML / META syntax for system prompts
๐Ÿง  Brain Overview The autonomous memory layer: Formation / Recall / Maintenance
๐Ÿค– Agent Instructions $self operational guide (waking mind)
โš™๏ธ System Instructions $system sleep-cycle maintenance guide
๐Ÿ“‹ Function Definition execute_kip function schema for LLM integration

Resources

This repository includes ready-to-use resources for building KIP-powered AI agents:

๐Ÿ“ฆ Knowledge Capsules (capsules/)

Pre-built knowledge capsules for bootstrapping your Cognitive Nexus:

Capsule Description
Genesis.kip Foundational capsule that bootstraps the entire type system
Person.kip Person concept type for actors (AI, Human, Organization)
Event.kip Event concept type for episodic memory
Preference.kip Preference concept type for stable preference facts
Insight.kip Insight concept type for self-reflective lessons
Commitment.kip Commitment type for prospective promises & deadlines
SleepTask.kip SleepTask type plus Unsorted / Archived domains
persons/self.kip The $self concept instance
persons/system.kip The $system concept instance

๐Ÿง  Brain (brain/)

A dedicated LLM layer that manages the Cognitive Nexus on behalf of business agents โ€” no KIP knowledge required:

File Description
BrainFormation.md System prompt for memory encoding (messages โ†’ structured knowledge)
BrainRecall.md System prompt for memory retrieval (natural language โ†’ KIP โ†’ answer)
BrainMaintenance.md System prompt for memory maintenance (sleep mode)
RecallFunctionDefinition.json recall_memory function schema for business agent integration

๐Ÿ”ง Tooling

Tool Description
kip-mcp-server @ldclabs/kip-mcp-server โ€” MCP server bridging any MCP client (Claude, Cursor, VS Code, ...) to a KIP backend
vscode-kip VS Code language support for .kip files: syntax highlighting, formatting, diagnostics, folding

Implementations

Project Description
Anda KIP SDK Rust SDK for building AI knowledge memory systems
Anda Cognitive Nexus Rust implementation of KIP based on Anda DB
Anda Brain Autonomous Graph Memory for AI Agents
Anda Cognitive Nexus Python Python binding for Anda Cognitive Nexus
Anda Cognitive Nexus HTTP Server A Rust-based HTTP server that exposes KIP via a small JSON-RPC API (GET /, POST /kip)
Anda Bot AI Agent based on KIP & Anda Brain

Version History

Version Date Changes
v1.0-RC9 2026-06-11 v1.0 Release Candidate 9: Associative-recall & memory-metabolism primitives โ€” predicate variables ((?s, ?p, ?o)), multi-key ORDER BY, specified SEARCH modes (keyword | semantic | hybrid with THRESHOLD / _score), new KML UPDATE (bulk mutation with ADD/MUL/CLAMP/COALESCE) and MERGE CONCEPT ... INTO ... (atomic entity consolidation), reserved engine-maintained _ metadata (_version, _updated_at, ...), EXPECT VERSION optimistic concurrency (KIP_3005), and META EXPORT for capsule round-tripping
v1.0-RC8 2026-06-10 v1.0 Release Candidate 8: Clarified ORDER BY sort expressions (dot-paths and aggregations, single key), whole-object dot access (?var.attributes / ?var.metadata), aggregation null semantics, KIP_3002 for match-only {id:} / (id:) targets, advisory instance_schema enforcement, and CURSOR :param placeholders; extended KIP_3004 protected scope to the Domain type and belongs_to_domain; aligned instruction examples (removed unregistered created_by, ID-based confidence decay)
v1.0-RC7 2026-06-04 v1.0 Release Candidate 7: Added single-command execute_kip, per-command batch parameters, KIP value-position placeholders for LIMIT / SEARCH, JSON-compatible unquoted object keys, belongs_to_class examples, stronger Hippocampus provenance/supersession guidance, and aligned Recall/MCP schemas
v1.0-RC6 2026-04-25 v1.0 Release Candidate 6: Added state-evolution metadata (superseded / superseded_by / superseded_at); clarified expires_at as a maintenance signal (only $system Phase 12 hard-deletes, capped 500/cycle); added KIP_2003 InvalidValueType and KIP_3004 ImmutableTarget error codes; consolidated syntax reference into KIPSyntax.md; restructured Hippocampus prompts (Formation / Recall / Maintenance) for prompt-embedding
v1.0-RC5 2026-03-25 v1.0 Release Candidate 5: Added execute_kip_readonly interface
v1.0-RC4 2026-03-09 v1.0 Release Candidate 4: Added IN, IS_NULL, IS_NOT_NULL FILTER operators; clarified UNION variable scope semantics; defined batch response structure; added temporal and UNION query examples
v1.0-RC3 2026-01-09 v1.0 Release Candidate 3: Optimized documentation; optimized instructions; optimized knowledge capsules
... ... ...
v1.0-draft1 2025-06-09 Initial Draft

Full version history โ†’

About Us

License

Copyright ยฉ 2025 LDC Labs.

Licensed under the MIT License. See LICENSE for details.

About

๐Ÿงฌ KIP is a Knowledge-memory Interaction Protocol designed for LLMs, aiming to build a sustainable learning and self-evolving memory system for AI Agents.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors