Skip to content

fix: preserve Discord lane metadata in LCM - #292

Merged
stephenschoettler merged 1 commit into
stephenschoettler:mainfrom
Tosko4:fix/discord-multichannel-lanes
Jun 29, 2026
Merged

stephenschoettler merged 1 commit into
stephenschoettler:mainfrom
Tosko4:fix/discord-multichannel-lanes

Conversation

@Tosko4

@Tosko4 Tosko4 commented Jun 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Persist the Hermes gateway conversation_id on raw LCM messages so Discord channel/thread/forum-topic lanes can be attributed and filtered.
  • Add a conversation_id filter to raw-message search and lcm_grep, alongside the existing source, session_id, role, and time filters.
  • Make post-turn ingest prefer the active LCM context-engine clone when the host passes it, while preserving the legacy singleton fallback path for older Hermes Agent hosts.

Why

Hermes Agent already routes Discord conversations with lane-specific gateway session keys, but LCM raw message rows only carried coarse source=discord metadata. That makes multi-channel retrieval and debugging too broad: different Discord channels, threads, and forum topics become hard to distinguish after ingest.

This keeps the existing source behavior intact and adds conversation_id as a narrower optional attribution/filter. Existing rows remain valid with conversation_id=''.

Newer Hermes Agent hosts clone context engines per agent/session. For short turns that never trigger compression, the post-turn ingest hook should follow the active LCM clone when available instead of assuming the plugin singleton is the live session engine.

Validation

  • Focused validation: python -m pytest tests/test_packaging_install.py::test_post_llm_hook_prefers_active_lcm_clone tests/test_packaging_install.py::test_post_llm_hook_rebinds_legacy_singleton_between_gateway_lanes tests/test_lcm_engine.py::test_discord_short_turn_ingest_preserves_conversation_id tests/test_lcm_engine.py::TestEngineABC::test_lcm_grep_filters_live_discord_history_by_conversation_id tests/test_lcm_core.py::TestMessageStore::test_conversation_id_stored_and_filterable_for_discord_lanes tests/test_lcm_core.py::TestMessageStore::test_like_fallback_filters_by_conversation_id -q -o addopts= -> 6 passed.
  • Default validation:
    • python -m pytest tests/test_lcm_core.py tests/test_lcm_engine.py tests/test_packaging_install.py -q -o addopts= -> 688 passed, 3 dependency deprecation warnings.
    • python -m pytest tests -q -o addopts= -> 1053 passed, 3 dependency deprecation warnings.
    • bash -lc 'ulimit -n 1024 && pytest -q' -> 1053 passed, 3 dependency deprecation warnings.
    • python -m compileall -q .
    • python -m py_compile scripts/import_lossless_claw.py
    • bash -n scripts/install.sh scripts/update.sh
    • git diff --check
  • CI validation on PR head 97add7b:
    • workflow-lint
    • test (3.11)
    • test (3.12)
    • test (3.13)
    • test (3.14)
  • Duplicate check: searched open/closed PRs and issues for conversation_id lcm_grep discord lane metadata; no matching existing PR/issue found.
  • Workflow validation: not applicable; no workflow files changed.

Notes

  • Companion Hermes Agent host PR: fix(agent): pass lane metadata to post-llm hooks NousResearch/hermes-agent#54452. That PR passes the active context engine and gateway lane metadata into post_llm_call hooks. This LCM PR consumes that metadata when available and remains backward-compatible when the host does not pass it.
  • Telegram/backward compatibility is preserved. Existing rows get conversation_id='', source filters keep their old behavior, and the legacy singleton path explicitly rebinds between lanes such as Discord topics and Telegram DMs.
  • This PR does not vendor LCM into Hermes Agent and does not change Hermes Agent core. The host-side change stays in the companion PR as generic plugin-hook metadata.
  • No issue number yet.

@Tosko4
Tosko4 force-pushed the fix/discord-multichannel-lanes branch from 973af51 to 97add7b Compare June 28, 2026 21:45
@stephenschoettler

Copy link
Copy Markdown
Owner

Thanks for the PR. Could you update the description to match the repo template before I review?

Please add:

  • Validation

The code can stay as-is. This just makes review, release notes, and future archaeology easier.

@Tosko4

Tosko4 commented Jun 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

Updated the PR body to match the repo template and replaced the ad-hoc Tests section with a full Validation section. I also added the companion Hermes Agent PR link in Notes, since this LCM change consumes the generic host metadata from that PR when available.

@stephenschoettler

@stephenschoettler stephenschoettler left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Focused maintainer pass on 97add7b.

Verdict: approved.

What I checked:

  • PR metadata, body, changed files, CI, comments, and review threads.
  • Clean simulated merge onto current origin/main (428f83c), no conflicts.
  • Post-turn ingest now prefers the active LCM context-engine clone when supplied and falls back to the plugin singleton for older hosts.
  • conversation_id is migrated/stored/indexed on raw message rows and threaded through Discord-lane ingest, MessageStore.search, lcm_grep, and lcm_expand(store_id=...) output.
  • lcm_grep(conversation_id=...) stays raw-message-only rather than mixing unscoped summary hits.
  • Companion Hermes Agent PR metadata shape matches the expected hook keys, with private lane attrs preferred and public fallback kept.

Validation I ran on a clean merge-check worktree:

  • focused PR tests: 6 passed
  • python -m pytest tests/test_lcm_core.py tests/test_lcm_engine.py tests/test_packaging_install.py -q -o addopts=: 689 passed
  • python -m pytest tests -q -o addopts=: 1053 passed
  • python -m compileall -q .: passed
  • git diff --check --cached: passed

No blockers found on the LCM side. The companion Agent PR is still separately responsible for delivering the new host metadata in production; this plugin PR remains backward-compatible without it.

@stephenschoettler

Copy link
Copy Markdown
Owner

Thanks, this is approved, checks are green, and the current policy gates pass. I am merging this now.

@stephenschoettler
stephenschoettler merged commit aab6afd into stephenschoettler:main Jun 29, 2026
5 checks passed
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.

2 participants