Skip to content

Commit b2656b3

Browse files
authored
Merge pull request #48 from afx-team/codex/agent-session-sync
feat: add agent session sync
2 parents 39e9f62 + 149e9ad commit b2656b3

37 files changed

Lines changed: 2604 additions & 59 deletions

AGENTS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ def test_retrieve_returns_sorted_memories():
113113

114114
## Conventions (SHOULD)
115115

116+
### UI / CLI Parity
117+
- New Web Console features **SHOULD** have a corresponding `hebb` CLI command for the same core workflow.
118+
- If CLI parity is intentionally skipped, document why the feature is UI-only or why a CLI would not be useful.
119+
116120
### Visual Documentation
117121
- Use **mermaid diagrams** for architecture, data flow, and component relationships
118122
- Example:
@@ -176,4 +180,4 @@ Before marking any task complete, verify:
176180
| Public documentation | `repo_pages/` | VuePress page format |
177181
| Paper summary | `reports/papers/` | See `reports/papers/.template.md` |
178182
| Project analysis | `reports/analysis/` | See `reports/analysis/.template.md` |
179-
| Architecture design | `reports/design/` | See `reports/design/.template.md` |
183+
| Architecture design | `reports/design/` | See `reports/design/.template.md` |

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ Open <http://localhost:8321/> for the Web Console.
8181
<img src="repo_pages/public/web-console-hero.jpg" alt="Hebb Mind Web Console — partitioned memories and tag graph" width="760">
8282
</p>
8383

84+
Use **Agent Sync** in the Web Console to make Hebb Mind the shared memory hub for Claude Code and Codex. It collects local session history from both tools, shows synced vs pending turns, and imports pending turns into the Hebb Mind database. The same workflow is available from the CLI:
85+
86+
```bash
87+
hebb agent-sync list --host codex
88+
hebb agent-sync sync --host codex --dry-run
89+
```
90+
8491
### Full experience (5 min) — enable LLM consolidation
8592

8693
Consolidation, conflict resolution, and tag extraction need an LLM backend. The gate is `llm_model` — until it's set, those endpoints are a no-op (see [#consolidation-no-op](https://afx-team.github.io/hebb-mind/troubleshooting.html)). A hosted provider also needs `llm_api_key`; a local model (e.g. Ollama via `llm_base_url`) does not.
@@ -106,6 +113,8 @@ pipx install 'hebb-mind[pg]' # + PostgreSQL/pgvector
106113
pipx upgrade hebb-mind # upgrade later
107114
hebb claude-code install --scope user # Claude Code: hooks-based recall + turn capture
108115
hebb codex install # Codex: project MCP + automatic memory hooks
116+
hebb agent-sync list # Audit Claude Code / Codex session sync status
117+
hebb agent-sync sync --dry-run # Preview historical session import
109118
```
110119

111120
Docker, one-line install, and source build: [Installation Guide](https://afx-team.github.io/hebb-mind/guide/installation.html).

README_ZH.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ curl -X POST http://localhost:8321/api/v1/search \
8181
<img src="repo_pages/public/web-console-hero.jpg" alt="Hebb Mind Web 控制台 — 分区记忆与标签图谱" width="760">
8282
</p>
8383

84+
在 Web 控制台中使用 **Agent 同步**,可把 Hebb Mind 作为 Claude Code 与 Codex 的共享记忆中转站。它会收集两类工具的本机会话历史,显示已同步与待同步回合,并把待处理回合导入 Hebb Mind 数据库。同一流程也可通过 CLI 使用:
85+
86+
```bash
87+
hebb agent-sync list --host codex
88+
hebb agent-sync sync --host codex --dry-run
89+
```
90+
8491
### 完整体验(5 分钟)— 启用 LLM 巩固
8592

8693
记忆巩固、冲突解决、标签提取需要一个 LLM 后端。开关由 `llm_model` 决定 —— 未设置前这些接口为 no-op(详见 [#consolidation-no-op](https://afx-team.github.io/hebb-mind/zh/troubleshooting.html))。托管 provider 还需要 `llm_api_key`;本地模型(例如通过 `llm_base_url` 接入的 Ollama)则不需要。
@@ -106,6 +113,8 @@ pipx install 'hebb-mind[pg]' # 启用 PostgreSQL/pgvector
106113
pipx upgrade hebb-mind # 后续升级
107114
hebb claude-code install --scope user # Claude Code:基于 hooks 的召回 + 回合写入
108115
hebb codex install # Codex:项目级 MCP + 自动记忆 hooks
116+
hebb agent-sync list # 查看 Claude Code / Codex 会话同步状态
117+
hebb agent-sync sync --dry-run # 预览历史会话导入
109118
```
110119

111120
Docker、一键脚本、源码安装详见 [安装指南](https://afx-team.github.io/hebb-mind/zh/guide/installation.html)

repo_pages/.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ function guideSidebar(prefix = '') {
313313
{ text: prefix ? '切换 Embedding 模型' : 'Switch Embedding Model', link: `${prefix}/guide/switch-embedding-model` },
314314
{ text: 'Claude Code', link: `${prefix}/guide/claude-code` },
315315
{ text: 'Codex', link: `${prefix}/guide/codex` },
316+
{ text: prefix ? 'Agent 同步' : 'Agent Sync', link: `${prefix}/guide/agent-sync` },
316317
{ text: prefix ? 'MCP 集成' : 'MCP Integration', link: `${prefix}/guide/mcp-integration` },
317318
{ text: prefix ? 'Web 控制台' : 'Web Console', link: `${prefix}/guide/web-console` },
318319
{ text: prefix ? '从其他系统迁移' : 'Migration from mem0 / Letta / Zep', link: `${prefix}/guide/migration` },

repo_pages/api/cli.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,34 @@ hebb console # open in browser
114114
hebb console --print # print URL only (CI / SSH friendly)
115115
```
116116

117+
## hebb agent-sync
118+
119+
Collect local Claude Code and Codex session history, show sync state, and import pending turns into Hebb Mind. This is the CLI counterpart to the Web Console **Agent Sync** page and uses the same `/api/v1/agent-sync/*` endpoints.
120+
121+
```bash
122+
hebb agent-sync list [--host all|claude-code|codex] [--limit 100] [--json] [--url URL]
123+
hebb agent-sync sync [--host all|claude-code|codex] [--id SESSION_ID]... [--limit 100] [--dry-run] [--json] [--url URL]
124+
```
125+
126+
| Option | Applies to | Description |
127+
|--------|------------|-------------|
128+
| `--host` | `list`, `sync` | Filter to one source. `claude-code` maps to the API host `claude_code`. |
129+
| `--limit` | `list`, `sync` | Maximum sessions to scan. |
130+
| `--id` | `sync` | Sync only specific opaque session ids returned by `list --json`. May be repeated. |
131+
| `--dry-run` | `sync` | Report pending turns without writing memories. |
132+
| `--json` | `list`, `sync` | Print the raw API payload for scripts. |
133+
| `--url` | `list`, `sync` | Override the server URL, useful for dev servers on non-default ports. |
134+
135+
Common workflow:
136+
137+
```bash
138+
hebb agent-sync list --host codex
139+
hebb agent-sync sync --host codex --dry-run
140+
hebb agent-sync sync --host codex
141+
```
142+
143+
Synced turns land in `mem_hippocampus` with `source` set to `sync:codex` or `sync:claude_code`, then follow the normal consolidation and recall lifecycle. See [Agent Sync](../guide/agent-sync.md) for the full workflow.
144+
117145
## hebb doctor
118146

119147
Run a one-shot health check covering Python version, config file, workspace, LLM, embedding model cache, web console assets, server reachability, and Claude Code / Codex MCP registration.

repo_pages/guide/agent-sync.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
description: "Use Hebb Mind as the shared memory hub for Claude Code and Codex: collect local session history, sync pending turns, and keep the Web Console and CLI in parity."
3+
---
4+
5+
# Agent Sync
6+
7+
Agent Sync turns Hebb Mind into the shared memory hub between **Claude Code** and **Codex**.
8+
9+
The normal hooks capture new turns after installation. Agent Sync covers the other half of the workflow: it scans local session history that already exists on disk, shows what has and has not reached Hebb Mind, and imports pending turns into the same database used by recall, consolidation, and search.
10+
11+
```mermaid
12+
flowchart LR
13+
Claude["Claude Code sessions"]
14+
Codex["Codex sessions"]
15+
Hub["Hebb Mind<br/>mem_hippocampus"]
16+
Recall["Recall from<br/>Claude Code / Codex / MCP"]
17+
18+
Claude -->|collect + sync| Hub
19+
Codex -->|collect + sync| Hub
20+
Hub -->|shared memory| Recall
21+
```
22+
23+
## When to use it
24+
25+
Use Agent Sync when you want to:
26+
27+
- populate Hebb Mind from past Claude Code or Codex conversations;
28+
- verify which local sessions have already been written into Hebb Mind;
29+
- move memories from one agent surface to another through Hebb Mind;
30+
- run the same workflow from either the Web Console or the `hebb` CLI.
31+
32+
Agent Sync does not replace the live hooks. Install the hooks for future capture, then use Agent Sync to backfill history or audit sync state.
33+
34+
```bash
35+
hebb claude-code install --scope user
36+
hebb codex install
37+
```
38+
39+
## Web Console workflow
40+
41+
Open the console:
42+
43+
```bash
44+
hebb console
45+
```
46+
47+
Then go to **Agent Sync**.
48+
49+
1. Choose **All software**, **Claude Code**, or **Codex**.
50+
2. Read the hub flow: **Source software → Hebb Mind → Available to Claude Code / Codex**.
51+
3. Review the sync queue. Each row shows project, transcript path, synced turns, pending turns, and update time.
52+
4. Click **Sync pending** to import all pending turns for the selected source, or **Sync** on a single session.
53+
54+
The page intentionally replaces the old Claude Code-only memory browser as the primary cross-agent workflow. Claude Code file memory and Hebb Mind database memory are different systems; Agent Sync makes the Hebb Mind database the shared hub.
55+
56+
## CLI workflow
57+
58+
The CLI mirrors the Web Console actions.
59+
60+
List sessions and sync state:
61+
62+
```bash
63+
hebb agent-sync list
64+
hebb agent-sync list --host claude-code
65+
hebb agent-sync list --host codex
66+
```
67+
68+
Dry-run a sync before writing:
69+
70+
```bash
71+
hebb agent-sync sync --host codex --dry-run
72+
```
73+
74+
Sync pending turns:
75+
76+
```bash
77+
hebb agent-sync sync --host claude-code
78+
hebb agent-sync sync --host codex
79+
```
80+
81+
For scripts or troubleshooting, use JSON output:
82+
83+
```bash
84+
hebb agent-sync list --host codex --json
85+
hebb agent-sync sync --host codex --dry-run --json
86+
```
87+
88+
If you run a development server on a non-default port, pass it explicitly:
89+
90+
```bash
91+
hebb agent-sync list --url http://127.0.0.1:8765
92+
```
93+
94+
## What gets stored
95+
96+
Synced turns are written to the working-memory inbox, `mem_hippocampus`, so the normal lifecycle still applies: inspect, consolidate, recall, and forget.
97+
98+
Each imported memory includes:
99+
100+
| Field | Value |
101+
|---|---|
102+
| `source` | `sync:claude_code` or `sync:codex` |
103+
| `partition_id` | `mem_hippocampus` |
104+
| `metadata.host` | `claude_code` or `codex` |
105+
| `metadata.session_id` | Source session identifier |
106+
| `metadata.turn` | Turn index used for dedupe |
107+
| `metadata.source_path` | Local transcript path |
108+
| `metadata.tools` / `metadata.mcps` | Tool and MCP names observed in the turn |
109+
110+
Agent Sync deduplicates by `host + session_id + turn`, and also avoids duplicating older hook writes that did not yet include a `host` field.
111+
112+
## Troubleshooting
113+
114+
**No sessions found.** Make sure the sessions exist locally on the same machine as the Hebb Mind service. Agent Sync currently scans the local Claude Code and Codex transcript locations.
115+
116+
**The CLI says the Agent Sync API is missing.** The running service is probably older than the checkout or package that provided your CLI. Restart the service:
117+
118+
```bash
119+
hebb service restart
120+
```
121+
122+
If you are using a dev server, pass `--url`.
123+
124+
**Hook output still shows an old command.** Codex and Claude Code load hook configuration at session startup. Start a new session or reload hooks after reinstalling the integration.
125+
126+
**This is local-first.** The console displays local transcript paths. Do not expose the console on a public network without authentication; see [Web Console](./web-console.md#authentication).

repo_pages/guide/web-console.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
description: "Browse, search, and edit your AI agent memory in the browser: the Hebb Mind Web Console bundles hybrid retrieval, a knowledge graph view, and live config on port 8321."
2+
description: "Browse, search, sync, and tune AI agent memory in the browser: the Hebb Mind Web Console bundles Agent Sync, hybrid retrieval, a knowledge graph view, and live config on port 8321."
33
---
44

55
# Web Console
66

7-
The Web Console is a single-page app that ships inside the Hebb Mind binary. It gives you a browseable view of your memories, a search box wired to the same hybrid retrieval that powers the API, a graph view of your knowledge graph, and a settings panel for changing config without touching JSON.
7+
The Web Console is a single-page app that ships inside the Hebb Mind binary. It gives you a browseable view of your memories, Agent Sync for Claude Code and Codex session history, a search box wired to the same hybrid retrieval that powers the API, a graph view of your knowledge graph, and a settings panel for changing config without touching JSON.
88

99
## Access
1010

@@ -40,7 +40,7 @@ The whole stack reads from your resolved workspace (run `hebb config get workspa
4040

4141
## Tour
4242

43-
The sidebar is organised around the memory lifecycle. The first four entries — **Manage**, **Activate**, **Consolidate**, **Forget** — are the write → recall → consolidate → forget loop; a divider separates them from **CC Memory**, **System**, and a link out to the **Docs**. Each entry is a hash route, so you can deep-link straight to it.
43+
The sidebar is organised around the memory lifecycle. **Manage**, **Activate**, **Agent Sync**, **Consolidate**, and **Forget** cover browse/write → recall → cross-agent sync → consolidate → forget; a divider separates them from **System** and a link out to the **Docs**. Each entry is a hash route, so you can deep-link straight to it.
4444

4545
### Manage (`#manage`)
4646

@@ -59,6 +59,17 @@ If the stat band reads zero on a fresh install, you're probably in the wrong wor
5959

6060
Recall, end to end. A **recall test** at the top lets you run a semantic search with per-query sliders for `relevance`, `importance`, and `recency`, and renders the scored results. Below it sit the global **recall parameters** — the recall-pipeline toggles, cross-encoder rerank, and the default scoring weights — so you can tune against real queries and then persist what works.
6161

62+
### Agent Sync (`#agent-sync`)
63+
64+
The cross-agent memory hub for Claude Code and Codex.
65+
66+
- Choose **All software**, **Claude Code**, or **Codex**.
67+
- Read the flow as **Source software → Hebb Mind → Available to Claude Code / Codex**.
68+
- Inspect the sync queue: project, transcript path, synced turns, pending turns, and update time.
69+
- Click **Sync pending** to import all pending turns for the current filter, or **Sync** on one session.
70+
71+
This is the primary UI for making Hebb Mind the shared memory layer across agent tools. The matching CLI commands are `hebb agent-sync list` and `hebb agent-sync sync`; see [Agent Sync](./agent-sync.md).
72+
6273
### Consolidate (`#consolidate`)
6374

6475
Consolidation runs automatically on a daily cron. This page gives you an **Organize now** trigger to run it on demand and stream the run log live, the **run records** of past consolidations, and the **consolidation config**.
@@ -70,10 +81,6 @@ The forgetting counterpart of Consolidate. A **Clean up now** trigger runs a swe
7081
<!-- TODO(asset): screenshot of the Manage → Graph tab with a non-trivial graph rendered (5+ tag clusters). Save as repo_pages/public/console-graph.png, then uncomment the image below. -->
7182
<!-- ![Graph view](../public/console-graph.png) -->
7283

73-
### CC Memory (`#cc-memory`)
74-
75-
Browse and edit Claude Code's file-based memory documents directly on disk.
76-
7784
### System (`#system`)
7885

7986
Infrastructure config, grouped into tabs: **LLM**, **Embedding**, **Storage**, and **Server**.
@@ -104,10 +111,18 @@ This requires an LLM key — see [Troubleshooting](../troubleshooting.md#consoli
104111

105112
**Change the LLM model without restarting.** System → LLM → enter a LiteLLM string (e.g. `anthropic/claude-3-haiku-20240307`) → save. If the field shows `restart_required`, run `hebb service restart`.
106113

114+
**Backfill Claude Code or Codex sessions.** Open Agent Sync → pick the source software → click **Sync pending**. For headless use:
115+
116+
```bash
117+
hebb agent-sync list --host codex
118+
hebb agent-sync sync --host codex --dry-run
119+
hebb agent-sync sync --host codex
120+
```
121+
107122
## When to use the Console vs. the CLI vs. the API
108123

109-
- **Console** — exploration, tuning weights, sanity-checking ingest, demos.
110-
- **CLI (`hebb …`)** — install, configuration, running the server, integration setup.
124+
- **Console** — exploration, tuning weights, sanity-checking ingest, syncing agent sessions, demos.
125+
- **CLI (`hebb …`)** — install, configuration, running the server, integration setup, and the same Agent Sync workflow in headless form.
111126
- **REST API** — anything programmatic, CI, custom UIs.
112127

113128
All three operate on the same workspace simultaneously. Updates from one show up in the others on next refresh.

repo_pages/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ features:
3636
title: Built-in Web Console
3737
details: Single-page app for memory CRUD, search, partitions, and graph view. Lives at http://localhost:8321/ — no separate deploy.
3838
- icon: 🔌
39-
title: REST + MCP + Claude Code hooks
40-
details: Three-line install gives Claude Code or Codex automatic cross-session recall and turn capture, backed by MCP memory tools. REST docs at /docs.
39+
title: REST + MCP + Agent Sync
40+
details: Claude Code and Codex get automatic recall and turn capture through hooks, explicit memory tools over MCP, and historical session backfill through the Agent Sync hub.
4141
---
4242

4343
<div class="hippo-home">

repo_pages/public/llms.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Headline benchmark results (reproducible via the `eval/` harness): LongMemEval r
1919
- [Switch the Embedding Model](https://afx-team.github.io/hebb-mind/guide/switch-embedding-model.html): Use local sentence-transformers or a LiteLLM API embedding provider, handle dimension changes, and re-embed with resume.
2020
- [Claude Code Integration](https://afx-team.github.io/hebb-mind/guide/claude-code.html): Give Claude Code cross-session memory via the MCP server plus session hooks for automatic recall, turn capture, and consolidation.
2121
- [Codex Integration](https://afx-team.github.io/hebb-mind/guide/codex.html): Give Codex automatic cross-session recall and turn capture with native hooks, plus explicit memory tools over MCP.
22+
- [Agent Sync](https://afx-team.github.io/hebb-mind/guide/agent-sync.html): Use Hebb Mind as the shared memory hub for Claude Code and Codex by collecting local session history and syncing pending turns.
2223
- [MCP Integration](https://afx-team.github.io/hebb-mind/guide/mcp-integration.html): Connect Claude Code, Codex, Cursor, and Claude Desktop to long-term memory over MCP — write, recall, and consolidate.
2324
- [Web Console](https://afx-team.github.io/hebb-mind/guide/web-console.html): Browser UI bundled with the service (port 8321) — memory CRUD, hybrid search, partitions, a knowledge-graph view, and live config.
2425
- [Migration from mem0 / Letta / Zep](https://afx-team.github.io/hebb-mind/guide/migration.html): Concept and API mapping, before/after code, data import, and an honest gap analysis.
@@ -39,7 +40,7 @@ Headline benchmark results (reproducible via the `eval/` harness): LongMemEval r
3940
- [Knowledge Graph API](https://afx-team.github.io/hebb-mind/api/graph.html): Inspect tags, query neighbors by depth, find shortest paths, and export nodes and edges.
4041
- [Admin API](https://afx-team.github.io/hebb-mind/api/admin.html): Trigger consolidation/forgetting, read stats, restart, and poll health/status.
4142
- [Config API](https://afx-team.github.io/hebb-mind/api/config.html): Read and update config at runtime — LLM and embedding settings, masked secrets, connectivity tests.
42-
- [CLI Reference](https://afx-team.github.io/hebb-mind/api/cli.html): The `hebb` command — setup, model download, background service, MCP/Claude Code wiring, and config.
43+
- [CLI Reference](https://afx-team.github.io/hebb-mind/api/cli.html): The `hebb` command — setup, model download, background service, MCP/Claude Code/Codex wiring, Agent Sync, and config.
4344

4445
## Advanced
4546

0 commit comments

Comments
 (0)