Open
Conversation
ba083f7 to
5f20c49
Compare
5f20c49 to
35975da
Compare
35975da to
504ddc0
Compare
504ddc0 to
a5c18cb
Compare
a5c18cb to
af1aeca
Compare
af1aeca to
e515e53
Compare
e515e53 to
260ec59
Compare
260ec59 to
6ac9053
Compare
6ac9053 to
8194452
Compare
8194452 to
8b12cf9
Compare
8b12cf9 to
343952b
Compare
343952b to
014dfb0
Compare
added 2 commits
May 6, 2026 18:37
…dkg_memory in system prompt Two fixes for the remaining issues blocking PR #389 validation. Issue B (contextGraphId not reaching Hermes for some turns): - The Node UI body builder used a ternary that omitted contextGraphId entirely when activeProjectId was null/undefined. On chat-reset / state- race paths where activeProjectId briefly went null while the visible badge still indicated a project, follow-up turns shipped without the field; the daemon's buildHermesOpenAiUserMessage early-returned plain text; the <dkg-node-ui-context> marker never made it to Hermes; passive recall silently scoped to agent-context-only. - buildLocalAgentChatBody now always includes contextGraphId (as null when not selected) so the daemon can distinguish "no project" from "field accidentally omitted". optionalTrimmedString already resolves null to undefined downstream, so no daemon parser changes needed. - routes/hermes.ts adds a bounded per-session contextGraphId cache (200-entry LRU). When a turn arrives with no contextGraphId but has a sessionId that previously carried one, the cache restores the value before payload forwarding. This fixes the symptom regardless of which UI path drops the field — Hermes' passive recall now stays scoped to the operator's selected project across turns. - New test in daemon-hermes.test.ts exercises the cache fallback across five send calls (prime → recover-from-cache → isolated-session → switch-projects → recover-from-cache-after-switch). Issue A mitigation (dkg_memory.context_graph_id schema visibility): - Adds one targeted line to the Hermes Node UI system prompt when a contextGraphId is present: "When persisting project-scoped notes for this session, call dkg_memory with context_graph_id: '<id>'." - This is a live, in-prompt signal that competes with stale <recalled-memory> snippets describing the older 4-field dkg_memory shape. Doesn't fix the underlying recall-pollution but gives the LLM a fresh reason to pick up the new field each turn. - New test asserts the system prompt contains "dkg_memory" + the context_graph_id name + the project id when contextGraphId is supplied. Tests: - 68 daemon-hermes tests pass (was 66, +2 new — cache fallback + dkg_memory nudge). - 87 hermes-adapter tests still pass. - Node UI tsc --noEmit clean. Out of scope (separate follow-ups if confirmed): - The React-state root cause that lets activeProjectId go null while the UI shows a project selected. - A recalled-memory filter that excludes stale tool-introspection text. - Equivalent per-session cache for OpenClaw's uiContextGraphId (OpenClaw has no passive recall so the symptom is less acute, but the same pattern would apply for parity).
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Source issue
Closes #385
Summary
main(0af092fb) after PR Codex/issue 396 private policy swm gate #420 merged; current head isf9d67b2888c863202263fcac8482597239ba744a.prefetch()assertion-only recall with six-layer DKG fan-out behavior aligned withmemory_search.dkg_memory.context_graph_idsupport while keeping unscoped simple memory writes defaulted toagent-context/memory.OpenClaw parity notes
agent-contextWM/SWM/VM.memory_searchquery project WM/SWM/VM only when the calling surface supplies a selected project viacontext_graph_id/target_context_graphor the Node UI selected-project marker; staticcontext_graphconfig does not count as current selection.agent-context-wm,agent-context-swm,agent-context-vm,project-wm,project-swm,project-vm.Files changed
packages/adapter-hermes/hermes-plugin/__init__.pypackages/adapter-hermes/test/hermes-adapter.test.tspackages/cli/src/daemon/routes/hermes.tspackages/cli/test/daemon-hermes.test.tspackages/adapter-hermes/README.mddocs/setup/SETUP_HERMES.mdpackages/cli/skills/dkg-node/SKILL.mdBehavioral details
memory_searchfor query planning, fan-out, ranking, dedupe, and provenance.agent-contextrecall always runs across WM/SWM/VM. A selected project graph is included only when supplied by the current calling surface.<dkg-node-ui-context ... />marker to the forwarded user message when a project is selected. The Hermes provider parses that marker for prefetch scope and strips it before chat persistence.<recalled-memory data-source="dkg-auto-recall">with escaped snippet text and untrusted-context framing.dkg_memory.context_graph_idstores scoped notes under separate cache buckets and queues writes with the target graph id. Unscoped writes continue to targetagent-context/memory.context_graph_idvalues ondkg_memoryandmemory_searchfail closed before cache/query/write routing. Optional JSONnullis treated as omitted.context_graphare read only as a legacy fallback after a successful emptyagent-contextprovider-memory read. Failure-shaped default reads do not widen recall to the legacy graph.memory_searchno longer filters out short literals with a hardSTRLEN >= 20cutoff.memory_searchdedupe keys include context graph, URI, predicate, and literal content so multipledkg_memorynotes under one assertion subject are preserved.Test evidence
Final local validation after updating onto
mainat0af092fb:python -m py_compile packages/adapter-hermes/hermes-plugin/__init__.py packages/adapter-hermes/hermes-plugin/client.pypassed.git diff --checkpassed.pnpm --filter @origintrail-official/dkg-adapter-hermes test -- hermes-adapter.test.tspassed: 87 tests. This includes Node UI context marker parsing/stripping, unique-token SPARQL ranking coverage, selected-project crowding regression coverage, and OpenClaw-style hook recall log coverage.pnpm --filter @origintrail-official/dkg test -- test/daemon-hermes.test.ts --reporter=verbosepassed: 66 tests. The command still prints the known post-run Windows message,The system cannot find the path specified., after exiting successfully.pnpm --filter @origintrail-official/dkg buildpassed.Earlier parity/rebase evidence retained from prior rounds:
pnpm --filter @origintrail-official/dkg-adapter-openclaw test -- dkg-client.test.tspassed: 58 tests after the prior main refresh touched that OpenClaw test path.pnpm --filter @origintrail-official/dkg-core buildpassed after pulling main to refresh workspace exports.pnpm --filter @origintrail-official/dkg-adapter-openclaw test -- before-prompt-build-hook.test.ts memory-integration.test.ts memory-search-tool.test.ts ChatTurnWriter.test.ts ChatTurnWriter.sanitize.test.ts plugin.test.ts dkg-client.test.tspassed: 7 files, 451 tests.pnpm --filter @origintrail-official/dkg-agent... buildpassed.pnpm --filter @origintrail-official/dkg-epcis buildpassed.Manual verification status
prefetch(), generic query words could crowd out unique IDs before adapter ranking, and selected-project WM hits could still be omitted from the final top-5 injected snippets when stale agent-context matches were abundant.Security / persistence notes
sync_turn()persistence./api/hermes-channel/persist-turnstrips adapter-generated recalled-memory blocks before chat storage, transition recording, and extraction import.data-sourceattributes, malformed unmatched adapter-generated openings, and Node UI context markers so recalled/routing context does not boomerang or cause data loss.dkg_memory.context_graph_idavoids cache and queue bleed between default personal memory and project notes.dkg_memorywrites still useagent-contextunlesscontext_graph_idis explicit.Known risks or follow-ups