Skip to content

Commit ddd97e7

Browse files
LakyFxclaude
andcommitted
[release] v4.2.0 — Subagent Memory Protocol + context compression
- Subagent Memory Protocol: research agents write findings to DB, parent gets 500-token summary - Tags filter in memory_search (AND logic for multi-tag subagent filtering) - memory_write rollback bugfix (locked DB no longer returns false success) - README: subagent docs, real-world example, updated token savings (80-200K+) - Updated version, description, keywords across all files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d2d185c commit ddd97e7

File tree

4 files changed

+62
-8
lines changed

4 files changed

+62
-8
lines changed

README.md

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ With CogniLayer, it already knows. Three things your agent doesn't have today:
1010

1111
🔍 **Code intelligence** — who calls what, what depends on what, what breaks if you rename a function. Tree-sitter AST parsing across 10+ languages, not grep
1212

13-
**80-100K tokens saved per session**3 semantic queries replace 15 file reads. Your agent works faster because it already knows your codebase
13+
🤖 **Subagent context compression**research subagents write findings to DB instead of dumping 40K+ tokens into parent context. Parent gets a 500-token summary + on-demand `memory_search` retrieval
1414

15-
[![Version](https://img.shields.io/badge/version-4.1.0-orange.svg)](#)
15+
**80-200K+ tokens saved per session** — semantic search replaces file reads, subagent findings go to DB instead of context. Longer sessions with subagents save more
16+
17+
[![Version](https://img.shields.io/badge/version-4.2.0-orange.svg)](#)
1618
[![License: Elastic-2.0](https://img.shields.io/badge/License-Elastic%202.0-blue.svg)](LICENSE)
1719
[![Python 3.11+](https://img.shields.io/badge/Python-3.11%2B-green.svg)](https://www.python.org/)
1820
[![MCP Server](https://img.shields.io/badge/MCP-17%20tools-purple.svg)](https://modelcontextprotocol.io/)
@@ -134,6 +136,32 @@ memory_search("stripe sdk upgrade")
134136

135137
Zero re-explanation. Claude picks up exactly where it left off, **including the blocker you hadn't mentioned yet**.
136138

139+
### Subagent research: "What MCP frameworks exist?"
140+
141+
Without CogniLayer, the subagent returns a 40K-token dump into parent context:
142+
143+
```
144+
Parent (200K context):
145+
→ spawn subagent: "Research community MCP servers"
146+
← subagent returns: 40K tokens about 15 projects
147+
→ all 40K crammed into parent context
148+
→ remaining: 160K → next subagent → 120K → next → 80K...
149+
```
150+
151+
With CogniLayer's Subagent Memory Protocol:
152+
153+
```
154+
Parent (200K context):
155+
→ spawn subagent: "Research MCP servers, save to memory"
156+
← subagent writes details to DB, returns: "Saved 3 facts,
157+
search 'MCP server ecosystem'. Summary: Python dominates,
158+
FastMCP most popular, 3 architectural patterns."
159+
→ parent context: ~500 tokens
160+
→ need details? memory_search("MCP server ecosystem") → targeted pull
161+
```
162+
163+
40K tokens compressed to 500. The findings persist in DB across sessions — not just for this conversation, but forever.
164+
137165
---
138166

139167
## Killer Features
@@ -143,7 +171,8 @@ Zero re-explanation. Claude picks up exactly where it left off, **including the
143171
| **Code Intelligence** | `code_context` shows who calls what. `code_impact` maps blast radius before you touch anything. Powered by tree-sitter AST parsing |
144172
| **Semantic Search** | Hybrid FTS5 + vector search finds the right fact even with different wording. Sub-millisecond response |
145173
| **17 MCP Tools** | Memory, code analysis, safety, project context — Claude uses them automatically, no commands needed |
146-
| **Token Savings** | 3 targeted queries (~800 tokens) replace 15 file reads (~60K tokens). Typical session saves 80-100K tokens |
174+
| **Token Savings** | 3 targeted queries (~800 tokens) replace 15 file reads (~60K tokens). Typical session saves 80-200K+ tokens |
175+
| **Subagent Protocol** | Research subagents save findings to DB instead of flooding parent context. 40K → 500 tokens per subagent task |
147176
| **Crash Recovery** | Session dies? Next one auto-recovers from the change log. Works across both agents |
148177
| **Cross-Project Knowledge** | Solved a CORS issue in project A? Search it from project B. Your experience compounds |
149178
| **14 Fact Types** | Not dumb notes — error_fix, gotcha, api_contract, decision, pattern, procedure, and more |
@@ -470,6 +499,31 @@ Powered by [tree-sitter](https://tree-sitter.github.io/) AST parsing with langua
470499
471500
Indexing runs with a configurable time budget (default 30s). Partial results are usable immediately. Unresolved references are re-resolved on the next incremental run.
472501
502+
## Subagent Memory Protocol
503+
504+
When Claude spawns research subagents, the raw findings can be 40K+ tokens. Without the protocol, all of that goes into the parent's context window. The Subagent Memory Protocol uses the CogniLayer database as a side channel:
505+
506+
```
507+
Subagent Parent
508+
│ │
509+
├── research (WebSearch, Read...) │
510+
├── synthesize findings │
511+
├── memory_write(consolidated facts) │ ← data goes to DB, not context
512+
└── return: 500-token summary ────────┤ ← only summary enters context
513+
514+
memory_search() ──┤ ← parent pulls details on demand
515+
```
516+
517+
Key design decisions:
518+
- **Synthesis over granularity** — subagents group related findings into cohesive facts, not one-per-discovery
519+
- **Task-specific tags** — each subagent gets a unique tag (e.g. `tags="subagent,auth-review"`) for filtering via `memory_search(tags="auth-review")`
520+
- **Keywords inside facts** — each fact ends with `Search: keyword1, keyword2` so retrieval works even after context compaction
521+
- **Write-last pattern** — all `memory_write` calls happen as the last step before return, saving subagent turns and tokens
522+
- **Foreground-first** — subagents launch as foreground (reliable MCP access), user can Ctrl+B to background
523+
- **Graceful fallback** — if MCP tools are unavailable, findings go directly in return text
524+
525+
The protocol is injected into CLAUDE.md automatically and requires no user configuration.
526+
473527
## Codex CLI Integration
474528
475529
Codex CLI has no hook system, so CogniLayer adapts:

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.1.0
1+
4.2.0

config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# CogniLayer v4 — Knowledge layer + code intelligence for AI coding agents
33

44
# General
5-
version: "4.1.0"
5+
version: "4.2.0"
66
language: "en" # "en" or "cs"
77

88
# Paths (auto-detected)

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[project]
22
name = "cognilayer"
3-
version = "4.1.0"
4-
description = "Persistent memory + code intelligence for Claude Code & Codex CLI — save ~100K tokens/session. 17 MCP tools, hybrid search, TUI dashboard, crash recovery."
3+
version = "4.2.0"
4+
description = "Persistent memory + code intelligence + subagent protocol for Claude Code & Codex CLI — save 80-200K+ tokens/session. 17 MCP tools, hybrid search, subagent context compression, TUI dashboard, crash recovery."
55
readme = "README.md"
66
license = "Elastic-2.0"
77
requires-python = ">=3.11"
88
authors = []
9-
keywords = ["claude", "claude-code", "codex-cli", "mcp", "memory", "ai", "llm", "persistent-memory", "vibecoding", "tui"]
9+
keywords = ["claude", "claude-code", "codex-cli", "mcp", "memory", "ai", "llm", "persistent-memory", "vibecoding", "tui", "subagent", "code-intelligence", "context-compression"]
1010
classifiers = [
1111
"Development Status :: 4 - Beta",
1212
"Intended Audience :: Developers",

0 commit comments

Comments
 (0)