Skip to content

Fix/honcho local mode gateway session#832

Closed
adavyas wants to merge 10 commits intoNousResearch:mainfrom
adavyas:fix/honcho-local-mode-gateway-session
Closed

Fix/honcho local mode gateway session#832
adavyas wants to merge 10 commits intoNousResearch:mainfrom
adavyas:fix/honcho-local-mode-gateway-session

Conversation

@adavyas
Copy link
Contributor

@adavyas adavyas commented Mar 10, 2026

What does this PR do?

This PR is a focused follow-up to pr-736 that corrects two runtime integration issues in the current Honcho changes.

First, it enforces memoryMode=local at runtime. In the current PR branch, local mode is described as disabling Honcho, but Hermes can still initialize remote Honcho state, create sessions, and prewarm memory paths. This change makes local mode behave consistently with that contract when both active peers resolve to local.

Second, it fixes gateway ownership of session-scoped Honcho state. The gateway currently creates short-lived AIAgent instances per request, but writeFrequency="session" requires a Honcho manager that survives across requests within the same gateway session. This PR moves that ownership to the gateway session layer so the same Honcho manager is reused across messages and flushed at real session boundaries.

This change is intentionally narrow. It does not add new configuration, change public schemas, or bundle unrelated cleanup. It keeps the PR aligned with the Hermes contributing guidance by focusing on one logical bug-fix area: making the current Honcho integration behave correctly.

Related Issue

Follow-up to #736

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Security fix
  • Documentation update
  • Tests (adding or improving test coverage)
  • Refactor (no behavior change)
  • New skill (bundled or hub)

Changes Made

  • Updated run_agent.py to:
    • prevent remote Honcho activation when both active peers are configured as local
    • allow the gateway to inject an existing Honcho manager and config instead of always creating a new one
    • keep the first-turn Honcho warmup path compatible with prompt-prefix caching by avoiding dynamic dialectic prewarm in the cached prompt path
  • Updated gateway/run.py to:
    • persist Honcho managers per gateway session key
    • reuse those managers across short-lived request handlers in the same session
    • shut them down at actual gateway session boundaries rather than at request boundaries
  • Added regression tests in tests/test_run_agent.py covering:
    • memoryMode=local skipping Honcho activation
    • injected Honcho managers bypassing fresh client initialization
  • Added regression tests in tests/gateway/test_honcho_lifecycle.py covering:
    • gateway Honcho manager reuse across requests
    • local mode skipping gateway Honcho manager creation
    • session reset shutting down the persistent gateway Honcho manager

How to Test

  1. Configure Hermes with Honcho enabled and set both active peers to memoryMode=local.
  2. Run a Hermes session and verify that remote Honcho is not initialized or prewarmed.
  3. Start the gateway and send multiple messages in the same session.
  4. Verify that the same Honcho manager is reused across requests for that session.
  5. Reset or end the session and verify that the persistent Honcho manager is shut down at that boundary.

Validation performed for this branch:

  1. pytest tests/test_run_agent.py -q
  2. pytest tests/gateway/test_honcho_lifecycle.py -q
  3. pytest tests/ -q
  4. python -m hermes_cli.main doctor
  5. python -m hermes_cli.main config check
  6. python -m hermes_cli.main chat -q "test message"

Test result summary:

  • pytest tests/ -q -> 2692 passed, 5 skipped, 23 deselected

Checklist

Documentation & Housekeeping

  • N/A: no user-facing documentation changes were required
  • N/A: no config keys changed, so cli-config.yaml.example did not require updates
  • N/A: no contributor workflow or architecture guide changes were required
  • I've considered cross-platform impact per the compatibility guide
  • N/A: no tool schema or description changes were required

Screenshots / Logs

Commits included:

  • 7ffaaa0 fix(honcho): enforce local mode and cache-safe warmup
  • 353a9e7 fix(gateway): persist Honcho managers across session requests

erosika and others added 10 commits March 9, 2026 16:13
…allMode

Adds full Honcho memory integration to Hermes:

- Session manager with async background writes, memory modes (honcho/hybrid/local),
  and dialectic prefetch for first-turn context warming
- Agent integration: prefetch pipeline, tool surface gated by recallMode,
  system prompt context injection, SIGTERM/SIGINT flush handlers
- CLI commands: setup, status, mode, tokens, peer, identity, migrate
- recallMode setting (auto | context | tools) for A/B testing retrieval strategies
- Session strategies: per-session, per-repo (git tree root), per-directory, global
- Polymorphic memoryMode config: string shorthand or per-peer object overrides
- 97 tests covering async writes, client config, session resolution, and memory modes
Tell users to go to app.honcho.dev > Settings > API Keys.
Updated in setup walkthrough, setup prompt, and client error message.
Explain what context vs dialectic actually do in plain language:
context = raw memory retrieval, dialectic = AI-to-AI inference
for session continuity. Describe what user/AI peer cards are.
Matches the mental model: hybrid = context + tools,
context = context only, tools = tools only.
New tool lets Hermes persist conclusions about the user (preferences,
corrections, project context) directly to Honcho via the conclusions
API. Feeds into the user's peer card and representation.
Consistent naming: all honcho tools now prefixed with honcho_
(honcho_context, honcho_search, honcho_profile, honcho_conclude).
Optional 'peer' parameter: "user" (default) or "ai". Allows asking
about the AI assistant's history/identity, not just the user's.
@erosika
Copy link
Contributor

erosika commented Mar 10, 2026

Consolidated into feat/honcho-async-memory — cherry-picked both fix commits (7ffaaa0, 353a9e7) on top of the rebased feature branch. This PR can be closed once the feature branch lands.

@teknium1
Copy link
Contributor

Closing this PR — the branch is 258 commits behind main, and merging it would delete ~27,000 lines of current code (skin engine, email gateway, skills, dozens of test files, etc.).

Additionally, the parent PR #736 (Honcho integration) is still open and hasn't been merged, so there's no Honcho code on main to fix yet.

If these Honcho fixes are genuinely needed, they should be applied to PR #736's branch directly rather than submitted as a separate PR targeting main. Thanks for the contribution!

@teknium1 teknium1 closed this Mar 11, 2026
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.

3 participants