Skip to content

honcho: skip per-gateway-message disk read in _extract_cache_busting_config when honcho isn't the active memory provider #33382

@kshitijk4poor

Description

@kshitijk4poor

Background

PR #30077 added per-message Honcho identity-mapping cache-busting to GatewayRunner._extract_cache_busting_config(). The implementation calls HonchoClientConfig.from_global_config() on every gateway message:

https://github.com/NousResearch/hermes-agent/blob/main/gateway/run.py#L14677-L14695

try:
    from plugins.memory.honcho.client import HonchoClientConfig
    hcfg = HonchoClientConfig.from_global_config()
    ...

from_global_config() unconditionally does path.read_text() + json.loads() on ~/.hermes/honcho.json (or ~/.honcho/config.json) and reconstructs the full HonchoClientConfig dataclass — every parse rule, every alias merge, every dialectic field — every time.

Problem

  1. Disk read on every gateway message. Even for users who don't use Honcho. honcho.json is small so each call is microseconds, but the work is unconditional and runs in the hot path before agent dispatch.

  2. Full config reparse to extract 5 fields. The cache-bust block only reads peer_name, ai_peer, pin_peer_name, runtime_peer_prefix, user_peer_aliases — but from_global_config() parses ~40 fields including dialectic levels, write frequency, context tokens, save flags, observation config, etc.

Proposed fix

Two options, not mutually exclusive:

Option A: gate on active memory provider. Skip the block entirely when memory.provider != "honcho". This is the cheapest win and handles the largest cohort (non-Honcho users).

Option B: mtime-based memoization. Cache the parsed HonchoClientConfig keyed by (path, st_mtime_ns) of honcho.json. os.stat() is much faster than parsing JSON. Bust on mtime change. Lifetime = process lifetime; small dict, no eviction needed because the path set is bounded.

Both together gives Honcho users the mtime-fast-path and everyone else the no-op skip.

If #33381 lands first, this issue becomes a non-problem for non-Honcho users automatically (only the active provider's hook runs). In that case only Option B remains — memoize inside the plugin's cache_busting_signature().

Acceptance criteria

  • _extract_cache_busting_config() does not read honcho.json from disk when memory provider is not Honcho
  • When Honcho is the active provider, repeated calls within the same honcho.json mtime hit a memoized result
  • Existing TestAgentConfigSignatureUserId tests still pass
  • Optional: micro-benchmark in tests/perf/ showing the per-message overhead drop

Notes

This is low-priority — the disk read is genuinely microsecond-scale on a hot SSD, and most gateways are network-bound, not disk-bound. Filing for completeness so the architectural intent is preserved. Pairs naturally with #33381.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/gatewayGateway runner, session dispatch, deliverycomp/pluginsPlugin system and bundled pluginstool/memoryMemory tool and memory providerstype/perfPerformance improvement or optimization

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions