Skip to content

Improve external context engine plugin support#8416

Closed
Tosko4 wants to merge 5 commits into
NousResearch:mainfrom
Tosko4:fix/external-context-engine-host-support
Closed

Improve external context engine plugin support#8416
Tosko4 wants to merge 5 commits into
NousResearch:mainfrom
Tosko4:fix/external-context-engine-host-support

Conversation

@Tosko4

@Tosko4 Tosko4 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • improves Hermes as a host for external context-engine plugins
  • does not vendor any plugin code into Hermes core
  • keeps the built-in compressor as the default unless context.engine explicitly selects something else

What changed

  • load plugin-registered context engines only when context.engine explicitly asks for one
  • make the fallback path actually discover installed plugins before checking the active plugin engine
  • pass live model/context information into the selected engine during init
  • restart context-engine lifecycle cleanly across /new, /resume, and /branch
  • keep /compress <focus> backward-compatible with engines that do not accept a focus_topic argument
  • surface an installed plugin-registered context engine in hermes plugins so it can be selected from the provider UI

Non-goals

  • no bundled hermes-lcm
  • no vendored engine code under plugins/context_engine/
  • no change to the default behavior for users who stay on the built-in compressor

Validation

Passed:

  • python -m pytest tests/run_agent/test_context_engine_plugin_init.py tests/run_agent/test_session_reset_fix.py tests/cli/test_cli_new_session.py tests/hermes_cli/test_plugins_cmd.py tests/agent/test_context_engine.py -q
    • result: 93 passed

That slice includes explicit coverage for:

  • default compressor stays active when no external engine is selected
  • missing external engine falls back cleanly to the built-in compressor
  • external plugin engine init/discovery paths
  • session reset / resume / branch lifecycle handling

@Tosko4

Tosko4 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor Author

Stephen just confirmed on X that hermes-lcm should be treated as the standalone deliverable/plugin:

  • install hermes-lcm
  • set the context engine to lcm
  • no Hermes core bundling needed

Given that, I think the right framing for this PR is:

  • not a prerequisite for hermes-lcm to exist or be usable
  • but a Hermes-side host/plugin ergonomics + robustness improvement for external context-engine plugins

So from my side, this PR is still intended as host-support cleanup:

  • plugin discovery/init path
  • lifecycle handling across /new, /resume, and /branch
  • backward-compatible compression hook behavior
  • surfacing installed plugin-registered engines more cleanly in Hermes

In other words: hermes-lcm stands on its own, and this PR is about making Hermes a cleaner/more reliable host for external context-engine plugins when people do use them.

@stephenschoettler @teknium1

@Tosko4

Tosko4 commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

Pulled one more small host-support commit into this PR.

What it adds

  • richer session-boundary hook context for external plugins on /new / reset-style boundaries
  • on_session_finalize can now receive:
    • old_session_id
    • previous_messages
    • previous_message_count
  • on_session_reset can now receive:
    • old_session_id
    • new_session_id
    • carry_over_context

Why
This keeps Hermes' normal built-in behavior unchanged, but makes Hermes a nicer host for external context-engine plugins that need to handle rollover boundaries safely.

In particular, it helps close the gap we hit while working on external hermes-lcm lifecycle handling: plugins could already see the session boundary, but they did not have enough context to finalize old-session state cleanly.

Validation

  • python -m pytest tests/cli/test_session_boundary_hooks.py tests/gateway/test_session_boundary_hooks.py -q
  • python -m pytest tests/run_agent/test_context_engine_plugin_init.py tests/run_agent/test_session_reset_fix.py tests/cli/test_cli_new_session.py tests/hermes_cli/test_plugins_cmd.py tests/agent/test_context_engine.py tests/cli/test_session_boundary_hooks.py tests/gateway/test_session_boundary_hooks.py -q

Tagging for visibility: @stephenschoettler @teknium1

@Tosko4

Tosko4 commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

Quick correction: I accidentally left vendored repo-shipped LCM files in this branch. That's now removed.

Current scope is back to generic host support only:

  • external context engine plugin init/fallback improvements
  • session-boundary hook context improvements for plugins

No bundled plugins/context_engine/lcm payload remains in this PR.

Validation rerun after cleanup:

  • python -m pytest tests/run_agent/test_context_engine_plugin_init.py tests/run_agent/test_session_reset_fix.py tests/cli/test_session_boundary_hooks.py tests/gateway/test_session_boundary_hooks.py tests/hermes_cli/test_plugins_cmd.py tests/cli/test_cli_new_session.py -q
  • 83 passed

Sorry for the noise. @stephenschoettler @teknium1

@Tosko4 Tosko4 force-pushed the fix/external-context-engine-host-support branch from 8f4dd82 to b5a3f9b Compare April 15, 2026 19:33
@Tosko4

Tosko4 commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

Rebased this cleanly onto current main and kept the scope strictly generic host support for external context-engine plugins.

What stayed true after the rewrite:

  • no vendored hermes-lcm or other plugin implementation under plugins/context_engine/*
  • only host-side lifecycle/discovery/compatibility changes remain in the diff
  • the PR is mergeable again; GitHub is currently recalculating checks/state on the refreshed head

Local validation on the rewritten branch:

  • python -m pytest tests/run_agent/test_context_engine_plugin_init.py tests/run_agent/test_session_reset_fix.py tests/cli/test_session_boundary_hooks.py tests/gateway/test_session_boundary_hooks.py tests/hermes_cli/test_plugins_cmd.py tests/cli/test_cli_new_session.py tests/agent/test_context_engine.py -q
    • 102 passed

@Tosko4

Tosko4 commented Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up pushed to this PR to close the biggest remaining host-side session-boundary gaps.

What changed in this extension:

  • compression-driven session splits now go through the same context-engine lifecycle seam instead of rotating session_id silently
  • background process notifications now carry the logical Hermes conversation session id they were created under
  • the gateway drops stale watch/completion notifications after /new or /reset instead of injecting them into the fresh session
  • CLI /new no longer waits on the old-session memory flush before the fresh session becomes visible; the flush/commit work is dispatched in the background

Why this helps:

  • external context engines no longer see /new//resume//branch as one contract and compression rollover as a different contract
  • a fresh session is less likely to feel "sticky" or "half alive" because old background-process follow-up events are fenced at the session boundary
  • /new feels more immediate in CLI because old-session cleanup is no longer on the critical path

Validation run on the updated branch:

  • pytest tests/run_agent/test_context_engine_plugin_init.py tests/run_agent/test_session_reset_fix.py tests/cli/test_cli_new_session.py tests/hermes_cli/test_plugins_cmd.py tests/agent/test_context_engine.py tests/cli/test_session_boundary_hooks.py tests/gateway/test_session_boundary_hooks.py tests/gateway/test_background_process_notifications.py tests/tools/test_process_registry.py tests/tools/test_notify_on_complete.py tests/tools/test_watch_patterns.py -q
  • result: 215 passed

@Tosko4 Tosko4 closed this by deleting the head repository Apr 20, 2026
@Tosko4

Tosko4 commented Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

This PR could not be reopened because its original head repository disappeared. Recreated as replacement PR #13370: #13370

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.

1 participant