Skip to content

Local-first 🧠 memory for Hermes Agent that lives in your Obsidian vault and remembers project context. Nightly 😴 dream passes turn repeat corrections into confirmed preferences with measurable confidence. Adapters ship for Claude Code, Codex, and OpenClaw, with an MCP server for anything else.

TypeScript

fix(hermes): preserve context-pack recall (v1.50.2) (#172)

Yori940619ba1a96784f4f
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index 53009092..a71f9707 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "open-second-brain",
- "version": "1.50.1",
+ "version": "1.50.2",
"description": "Plugin-first second brain package for AI agents and humans.",
"author": {
"name": "Open Second Brain contributors"
diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json
index 33b378b2..e8efb12f 100644
--- a/.codex-plugin/plugin.json
+++ b/.codex-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "open-second-brain",
- "version": "1.50.1",
+ "version": "1.50.2",
"description": "Plugin-first second brain package for Codex, Hermes, Claude Code, OpenClaw, and other agent runtimes.",
"skills": "./skills",
"hooks": "./hooks/hooks.json",
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fbd5047f..39b7ea2d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [1.50.2] - 2026-08-20
+
+Hermes asked Open Second Brain for a token-bounded context pack before each substantive turn, then read only the MCP transport text. The transport deliberately replaces a large result with a 2,000-character preview envelope, even though the complete structured context pack is present beside it, so the provider injected transport metadata instead of the recalled memory bodies.
+
+### Fixed
+
+- **Hermes per-turn recall now uses the structured, token-budgeted context pack.** The provider joins non-empty `structuredContent.items[*].body` values and bypasses the `preview_truncated` transport envelope. The existing 1,024-token context-pack ceiling is unchanged, and text-only older servers retain their existing fallback.
+- **The transport-boundary regression has a test that fails on the old path.** The fixture returns both structured memory bodies and the exact preview-envelope shape; it requires both bodies to reach the prompt and every envelope marker to stay out.
+
## [1.50.1] - 2026-08-17
The Hermes dashboard could not save this provider's configuration, and reported the failure in the one way an operator cannot act on: a provider that was fully configured showed as needing setup, and every attempt to configure it from the panel returned HTTP 400. Reported as [#170](https://github.com/itechmeat/open-second-brain/issues/170) with the root cause already traced to where the two sides look for the same values. Two unrelated repairs ride along, both surfaced by running the suite on a later day than the one it was written on: a test pinned to a date literal, and the build step that was meant to notice the vendored-schema test skipping.
@@ -7277,6 +7286,7 @@ plugin config (vault field)`, and exits with a clear
- Sandbox vault and plugin manifest fixtures for tests.
- GitHub release workflow for tag-based and manually dispatched releases.
+[1.50.2]: https://github.com/itechmeat/open-second-brain/compare/v1.50.1...v1.50.2
[1.50.1]: https://github.com/itechmeat/open-second-brain/compare/v1.50.0...v1.50.1
[1.50.0]: https://github.com/itechmeat/open-second-brain/compare/v1.49.0...v1.50.0
[1.49.0]: https://github.com/itechmeat/open-second-brain/compare/v1.48.0...v1.49.0
diff --git a/openclaw.plugin.json b/openclaw.plugin.json
index 7cab65d8..706da24d 100644
--- a/openclaw.plugin.json
+++ b/openclaw.plugin.json
@@ -2,7 +2,7 @@
"id": "open-second-brain",
"name": "Open Second Brain",
"description": "Second brain for AI agents using Obsidian-compatible Markdown vaults.",
- "version": "1.50.1",
+ "version": "1.50.2",
"activation": { "onStartup": true },
"skills": ["./skills"],
"contracts": {
diff --git a/package.json b/package.json
index 401d995f..3f3444f0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "open-second-brain",
- "version": "1.50.1",
+ "version": "1.50.2",
"private": false,
"description": "Second brain for AI agents using Obsidian-compatible Markdown vaults. Works with Hermes, Claude Code, Codex, and OpenClaw.",
"keywords": [
diff --git a/plugin.yaml b/plugin.yaml
index a75fdc7b..45293a55 100644
--- a/plugin.yaml
+++ b/plugin.yaml
@@ -1,5 +1,5 @@
name: open-second-brain
-version: "1.50.1"
+version: "1.50.2"
description: "Open Second Brain - native Hermes memory provider backed by an Obsidian-compatible Markdown vault."
author: "Open Second Brain contributors"
memory_provider: true
diff --git a/plugins/codex/.codex-plugin/plugin.json b/plugins/codex/.codex-plugin/plugin.json
index 731a84c4..eb036a91 100644
--- a/plugins/codex/.codex-plugin/plugin.json
+++ b/plugins/codex/.codex-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "open-second-brain",
- "version": "1.50.1",
+ "version": "1.50.2",
"description": "Plugin-first second brain package for Codex, Hermes, Claude Code, OpenClaw, and other agent runtimes.",
"author": {
"name": "Open Second Brain contributors",
diff --git a/plugins/hermes/plugin.yaml b/plugins/hermes/plugin.yaml
index a75fdc7b..45293a55 100644
--- a/plugins/hermes/plugin.yaml
+++ b/plugins/hermes/plugin.yaml
@@ -1,5 +1,5 @@
name: open-second-brain
-version: "1.50.1"
+version: "1.50.2"
description: "Open Second Brain - native Hermes memory provider backed by an Obsidian-compatible Markdown vault."
author: "Open Second Brain contributors"
memory_provider: true
diff --git a/plugins/hermes/provider.py b/plugins/hermes/provider.py
index 1bb953a7..fcaa84ff 100644
--- a/plugins/hermes/provider.py
+++ b/plugins/hermes/provider.py
@@ -561,7 +561,7 @@ class OpenSecondBrainMemoryProvider(MemoryProvider):
gate = self._structured(self._safe_call("brain_recall_gate", {"prompt": query}))
if gate.get("retrieve"):
pack = self._safe_call("brain_context_pack", {"max_tokens": _PREFETCH_MAX_TOKENS})
- recalled = self._text(pack)
+ recalled = self._context_pack_text(pack)
if recalled:
parts.append(recalled)
# Skill auto-attach (Agent Surface Suite): the TS side gates on the
@@ -717,6 +717,24 @@ class OpenSecondBrainMemoryProvider(MemoryProvider):
return first["text"]
return ""
+ @staticmethod
+ def _context_pack_text(result: Any) -> str:
+ """Recall text from ``brain_context_pack``: prefer structured bodies.
+
+ Structured item bodies are the budgeted recall payload; using them also
+ bypasses the MCP transport's preview envelope. Fall back to
+ ``content[0].text`` for older servers that only expose legacy text.
+ """
+ structured = OpenSecondBrainMemoryProvider._structured(result)
+ bodies = [
+ str(item.get("body"))
+ for item in (structured.get("items") or [])
+ if isinstance(item, dict) and str(item.get("body") or "").strip()
+ ]
+ if bodies:
+ return "\n\n".join(bodies)
+ return OpenSecondBrainMemoryProvider._text(result)
+
def _append_turn(self, user: str, assistant: str, session_id: str) -> None:
with self._lock:
self._buffer.append((user, assistant))
diff --git a/pyproject.toml b/pyproject.toml
index 6ac453cd..613767bc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
# CLI entry points (those moved to `package.json` `bin`).
[project]
name = "open-second-brain"
-version = "1.50.1"
+version = "1.50.2"
description = "Hermes Python shim for Open Second Brain. Most of the project (CLI, MCP server, OpenClaw plugin) is TypeScript on Bun; see package.json."
readme = "README.md"
requires-python = ">=3.11"
diff --git a/tests/python/test_memory_provider.py b/tests/python/test_memory_provider.py
index 5294c57a..06508b95 100644
--- a/tests/python/test_memory_provider.py
+++ b/tests/python/test_memory_provider.py
@@ -706,6 +706,47 @@ class ProviderLifecycleTests(unittest.TestCase):
self.assertIn("RECALLED", out)
self.assertIn("@pf-agent", out)
+ def test_prefetch_uses_structured_items_bodies_and_skips_preview_envelope(self):
+ # Regression: when brain_context_pack returns both structuredContent
+ # items[*].body AND a content[0].text envelope carrying the
+ # preview-truncation marker (preview_truncated + artifact_id +
+ # bytes_preview), prefetch must assemble recall from the structured
+ # bodies — the envelope is a transport artefact, not recall text.
+ os.environ["VAULT_AGENT_NAME"] = "pf-agent"
+ preview_text = json.dumps(
+ {
+ "preview_truncated": True,
+ "artifact_id": "art-deadbeef",
+ "full_chars": 44261,
+ "bytes_preview": "...truncated...",
+ }
+ )
+ bridge = FakeBrainBridge(
+ results={
+ "brain_recall_gate": {"structuredContent": {"retrieve": True, "reason": "hit"}},
+ "brain_context_pack": {
+ "structuredContent": {
+ "items": [
+ {"title": "note-a", "body": "BODY ALPHA from item A"},
+ {"title": "note-b", "body": "BODY BETA from item B"},
+ ]
+ },
+ "content": [{"type": "text", "text": preview_text}],
+ },
+ }
+ )
+ provider = self._init(bridge, hermes_home="/tmp/hh")
+ out = provider.prefetch("any query", session_id="sess-1")
+
+ # Both structured bodies must reach the prefetch output.
+ self.assertIn("BODY ALPHA from item A", out)
+ self.assertIn("BODY BETA from item B", out)
+ # The MCP preview envelope must NOT leak into the prompt.
+ self.assertNotIn("preview_truncated", out)
+ self.assertNotIn("artifact_id", out)
+ self.assertNotIn("bytes_preview", out)
+ self.assertNotIn("art-deadbeef", out)
+
def test_prefetch_appends_skills_attach_block_when_enabled(self):
os.environ["VAULT_AGENT_NAME"] = "pf-agent"
bridge = FakeBrainBridge(