Skip to content

fix(hermes): accept passthrough kwargs in memory provider hooks (closes #249)#252

Merged
rohitg00 merged 1 commit intomainfrom
fix/249-hermes-sync-turn-kwargs
May 9, 2026
Merged

fix(hermes): accept passthrough kwargs in memory provider hooks (closes #249)#252
rohitg00 merged 1 commit intomainfrom
fix/249-hermes-sync-turn-kwargs

Conversation

@rohitg00
Copy link
Copy Markdown
Owner

@rohitg00 rohitg00 commented May 9, 2026

Closes #249.

What

Hermes calls memory provider hooks with extra context kwargs (e.g. session_id) that the existing strict signatures rejected with:

Memory provider 'agentmemory' sync_turn failed: AgentMemoryProvider.sync_turn() got an unexpected keyword argument 'session_id'

This kept the plugin "alive" but silently broke per-turn memory sync — every sync_turn invocation hit an exception and got skipped, so conversation observations were lost.

Fix

Add **kwargs: Any to every memory-provider hook so extra context fields are tolerated:

  • sync_turn
  • on_session_end
  • on_pre_compress
  • on_memory_write
  • prefetch
  • queue_prefetch
  • shutdown

Mirror the same change on the abstract MemoryProvider fallback used when agent.memory_provider is unavailable at import time, so the contract stays consistent across both paths.

Where Hermes passes session_id in kwargs, prefer it over the cached self._session_id so per-turn observations land on the correct session when Hermes routes a hook through a different conversation than the one the provider was initialized with. Same pattern applied to on_session_end and on_pre_compress.

Test plan

  • python3 -c "import ast; ast.parse(open('integrations/hermes/__init__.py').read())" — syntax clean.
  • Reproduce per @OptionalCoin's repro: install plugin, run normal CLI conversation turn, check ~/.hermes/logs/agent.log — no more unexpected keyword argument 'session_id' warnings, and sync_turn actually fires the observe POST.
  • @OptionalCoin reported they ran their local-patched version through a Hermes CLI smoke run and the warning disappeared. Asking them to confirm against this branch as well.

Credit to @OptionalCoin for the root-cause analysis and the local patch verification.

Summary by CodeRabbit

  • Chores
    • Updated memory provider interface signatures to support additional context parameters across core operations.

Review Change Stack

#249)

Hermes calls memory provider hooks with extra context kwargs (e.g.
session_id) that the strict signatures rejected with:

  Memory provider 'agentmemory' sync_turn failed: AgentMemoryProvider.
  sync_turn() got an unexpected keyword argument 'session_id'

Add **kwargs: Any to every hook so extra context fields are tolerated:
sync_turn, on_session_end, on_pre_compress, on_memory_write, prefetch,
queue_prefetch, shutdown. Mirror the same change on the abstract
fallback MemoryProvider used when `agent.memory_provider` is unavailable
at import time.

Where Hermes passes session_id, prefer it over the cached
self._session_id so per-turn observations land on the correct session
when Hermes routes a hook through a different conversation than the one
the provider was initialized with.

Reported and locally verified by @OptionalCoin.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agentmemory Ready Ready Preview, Comment May 9, 2026 10:13am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0cb90b01-1ab4-4b06-a0f5-23ae3871893d

📥 Commits

Reviewing files that changed from the base of the PR and between 989e9c0 and f50ad69.

📒 Files selected for processing (1)
  • integrations/hermes/__init__.py

📝 Walkthrough

Walkthrough

This PR updates the Hermes agentmemory memory provider to accept **kwargs in all hook methods, resolving a contract mismatch where Hermes passes additional context (e.g., session_id) at runtime. Three lifecycle methods now extract and use session_id from kwargs with fallback to the stored session, while other methods accept kwargs for interface compatibility.

Changes

Hermes Memory Provider Compatibility

Layer / File(s) Summary
Interface Contract
integrations/hermes/__init__.py
Fallback MemoryProvider ABC declares seven methods with **kwargs parameters: prefetch, queue_prefetch, sync_turn, on_session_end, on_pre_compress, on_memory_write, and shutdown.
Session-aware Context
integrations/hermes/__init__.py
AgentMemoryProvider.sync_turn, on_session_end, and on_pre_compress now extract session_id from kwargs.get("session_id", self._session_id) when emitting observe, session, and context requests.
Signature Compatibility
integrations/hermes/__init__.py
AgentMemoryProvider.prefetch, queue_prefetch, on_memory_write, and shutdown add **kwargs parameters; behavior remains unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • rohitg00/agentmemory#107: Introduced the Hermes integration classes; this PR updates the same MemoryProvider ABC and AgentMemoryProvider implementation to support the runtime interface contract.

Poem

A rabbit hops through method calls with glee,
Now kwargs flow where context used to be.
Session IDs dance in fallback's embrace,
No more surprises in Hermes' place! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately reflects the main change: adding **kwargs support to memory provider hooks in Hermes to fix TypeErrors when extra context is passed.
Linked Issues check ✅ Passed The PR successfully addresses all requirements from issue #249: adding **kwargs to sync_turn, on_session_end, on_pre_compress, on_memory_write, prefetch, queue_prefetch, and shutdown methods; using kwargs.get('session_id') for session context; and mirroring changes on the fallback MemoryProvider.
Out of Scope Changes check ✅ Passed All changes are focused on updating method signatures in integrations/hermes/init.py to accept **kwargs, directly addressing the issue. No unrelated modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/249-hermes-sync-turn-kwargs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rohitg00 rohitg00 merged commit 2c24c90 into main May 9, 2026
5 checks passed
@rohitg00 rohitg00 deleted the fix/249-hermes-sync-turn-kwargs branch May 9, 2026 10:18
rohitg00 added a commit that referenced this pull request May 9, 2026
Bug-fix patch focused on search recall correctness and plugin
compatibility. Pins iii-engine to v0.11.2 because v0.11.6 introduces
a new sandbox-everything-via-`iii worker add` model that agentmemory
hasn't been refactored for yet — pin lifts once that refactor lands.
Adds a hard guard against silent vector-index corruption, fixes BM25
indexing for memories saved via memory_save, and lands four Hermes
plugin fixes.

Per AGENTS.md release checklist:
- package.json version 0.9.4 -> 0.9.5
- src/version.ts VERSION constant
- src/types.ts ExportData version union
- src/functions/export-import.ts supportedVersions Set
- test/export-import.test.ts assertion
- plugin/.claude-plugin/plugin.json version
- CHANGELOG.md detailed entries with contributor shoutouts

Headlines (full detail in CHANGELOG):

Fixed:
- BM25 search now indexes memories saved via memory_save (#258, #257)
  Thanks @Nizar-BenHamida for the precise repro.
- Embedding providers no longer silently corrupt the vector index when
  an API returns wrong-dimension vectors (#248, #247, #256)
  Thanks @AmmarSaleh50 for issue + fix + tests.
- Hermes handle_tool_call returns JSON strings, not raw dicts (#255, #254)
  Thanks @KyoMio for the Anthropic-protocol repro.
- Hermes status reflects real service state on systemd installs (#253, #250)
  Thanks @OptionalCoin for tracing it to env-source divergence.
- Hermes hooks accept passthrough kwargs (#252, #249)
  Thanks @OptionalCoin again for the log analysis.
- agentmemory demo now seeds observations correctly (#251, #229)
  Thanks @seishonagon for root-cause analysis.
- LLM compression / summarization timeouts increased (#213)
  Thanks @xuli500177.
- Pi / OpenClaw / Hermes integration plugin fixes (#230)
  Thanks @deepmroot.

Changed:
- iii-engine pinned to v0.11.2 across every install path (#260).
  v0.11.6 introduces a new `iii worker add` sandbox model that
  agentmemory still pre-dates; pin lifts when we refactor agentmemory
  to register as a sandboxed worker. Override with
  AGENTMEMORY_III_VERSION=<version> for users who've migrated manually.
- README documents iii worker add extension surface (#242).
- README iii Console install/launch commands corrected (#243).

Validated: 852/852 tests pass, npm run build clean.
rohitg00 added a commit that referenced this pull request May 9, 2026
Bug-fix patch focused on search recall correctness and plugin
compatibility. Pins iii-engine to v0.11.2 because v0.11.6 introduces
a new sandbox-everything-via-`iii worker add` model that agentmemory
hasn't been refactored for yet — pin lifts once that refactor lands.
Adds a hard guard against silent vector-index corruption, fixes BM25
indexing for memories saved via memory_save, and lands four Hermes
plugin fixes.

Per AGENTS.md release checklist:
- package.json version 0.9.4 -> 0.9.5
- src/version.ts VERSION constant
- src/types.ts ExportData version union
- src/functions/export-import.ts supportedVersions Set
- test/export-import.test.ts assertion
- plugin/.claude-plugin/plugin.json version
- CHANGELOG.md detailed entries with contributor shoutouts

Headlines (full detail in CHANGELOG):

Fixed:
- BM25 search now indexes memories saved via memory_save (#258, #257)
  Thanks @Nizar-BenHamida for the precise repro.
- Embedding providers no longer silently corrupt the vector index when
  an API returns wrong-dimension vectors (#248, #247, #256)
  Thanks @AmmarSaleh50 for issue + fix + tests.
- Hermes handle_tool_call returns JSON strings, not raw dicts (#255, #254)
  Thanks @KyoMio for the Anthropic-protocol repro.
- Hermes status reflects real service state on systemd installs (#253, #250)
  Thanks @OptionalCoin for tracing it to env-source divergence.
- Hermes hooks accept passthrough kwargs (#252, #249)
  Thanks @OptionalCoin again for the log analysis.
- agentmemory demo now seeds observations correctly (#251, #229)
  Thanks @seishonagon for root-cause analysis.
- LLM compression / summarization timeouts increased (#213)
  Thanks @xuli500177.
- Pi / OpenClaw / Hermes integration plugin fixes (#230)
  Thanks @deepmroot.

Changed:
- iii-engine pinned to v0.11.2 across every install path (#260).
  v0.11.6 introduces a new `iii worker add` sandbox model that
  agentmemory still pre-dates; pin lifts when we refactor agentmemory
  to register as a sandboxed worker. Override with
  AGENTMEMORY_III_VERSION=<version> for users who've migrated manually.
- README documents iii worker add extension surface (#242).
- README iii Console install/launch commands corrected (#243).

Validated: 852/852 tests pass, npm run build clean.
rohitg00 added a commit that referenced this pull request May 9, 2026
Bug-fix patch focused on search recall correctness and plugin
compatibility. Pins iii-engine to v0.11.2 because v0.11.6 introduces
a new sandbox-everything-via-`iii worker add` model that agentmemory
hasn't been refactored for yet — pin lifts once that refactor lands.
Adds a hard guard against silent vector-index corruption, fixes BM25
indexing for memories saved via memory_save, and lands four Hermes
plugin fixes.

Per AGENTS.md release checklist:
- package.json version 0.9.4 -> 0.9.5
- src/version.ts VERSION constant
- src/types.ts ExportData version union
- src/functions/export-import.ts supportedVersions Set
- test/export-import.test.ts assertion
- plugin/.claude-plugin/plugin.json version
- CHANGELOG.md detailed entries with contributor shoutouts

Headlines (full detail in CHANGELOG):

Fixed:
- BM25 search now indexes memories saved via memory_save (#258, #257)
  Thanks @Nizar-BenHamida for the precise repro.
- Embedding providers no longer silently corrupt the vector index when
  an API returns wrong-dimension vectors (#248, #247, #256)
  Thanks @AmmarSaleh50 for issue + fix + tests.
- Hermes handle_tool_call returns JSON strings, not raw dicts (#255, #254)
  Thanks @KyoMio for the Anthropic-protocol repro.
- Hermes status reflects real service state on systemd installs (#253, #250)
  Thanks @OptionalCoin for tracing it to env-source divergence.
- Hermes hooks accept passthrough kwargs (#252, #249)
  Thanks @OptionalCoin again for the log analysis.
- agentmemory demo now seeds observations correctly (#251, #229)
  Thanks @seishonagon for root-cause analysis.
- LLM compression / summarization timeouts increased (#213)
  Thanks @xuli500177.
- Pi / OpenClaw / Hermes integration plugin fixes (#230)
  Thanks @deepmroot.

Changed:
- iii-engine pinned to v0.11.2 across every install path (#260).
  v0.11.6 introduces a new `iii worker add` sandbox model that
  agentmemory still pre-dates; pin lifts when we refactor agentmemory
  to register as a sandboxed worker. Override with
  AGENTMEMORY_III_VERSION=<version> for users who've migrated manually.
- README documents iii worker add extension surface (#242).
- README iii Console install/launch commands corrected (#243).

Validated: 852/852 tests pass, npm run build clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hermes agentmemory plugin: sync_turn() fails on unexpected keyword argument session_id

1 participant