hindsight icon indicating copy to clipboard operation
hindsight copied to clipboard

Hermes plugin: forward prefer_observations from plugin config to recall (drop raw facts their observations already cover)

Open kumaxs opened this issue 1 month ago • 5 comments

Use Case

I run a Hermes agent backed by a Hindsight bank with the integration's broad recall enabled — "recall_types": "observation,world,experience" in ~/.hermes/hindsight/config.json. In that mode every consolidated observation comes back together with the raw world / experience facts it was built from, so recall budget is spent on the same content twice. On a small bank of lessons this measured 18 results that were exactly 9 fact+observation pairs (measured in vectorize-io/hindsight#5131); with prefer_observations: true the same query returned the 9 observations only, no duplicates, at roughly half the tokens.

Problem Statement

The Hindsight recall API already handles this: prefer_observations=true makes the server drop raw facts that a consolidated observation supersedes, deduplicating before truncation so freed slots backfill (#5131). But the Hermes integration (hindsight-integrations/hermes 1.2.1, inspected at upstream main = 9269b884) cannot reach it: there is no prefer_observations config key, and the provider's _recall() builds its arecall kwargs only from the configured knobs (bank, budget, max_tokens, tags/tags_match, types, min_scores) — the flag never lands on the wire. This is the same gap openclaw's integration reports for its tool path in vectorize-io/hindsight#5057.

How This Feature Would Help

  • Broad-recall users get each fact once instead of twice; on a duplicate-heavy bank that is about 2× the distinct content inside the same recall_max_tokens budget.
  • It is opt-in with zero default behavior change: the plugin's recall_types default is observation-only, so unless you opted back into raw facts this key changes nothing — no silent surprise for existing setups.
  • Both recall paths benefit at once (the auto-recall prefetch and the hindsight_recall tool share one _recall()), and the server already implements the semantics — no Hindsight core change is requested.

Proposed Solution

Three small additions to hindsight-integrations/hermes, mirroring how every other recall knob already works:

  1. get_config_schema(): a prefer_observations bool field, default False.
  2. _apply_recall_settings(): read it once — self._prefer_observations = bool(cfg.get("prefer_observations", False)).
  3. _recall(): append it only when opted in — if self._prefer_observations: kwargs["prefer_observations"] = True (absent entirely when unset, so a default config's request keeps its exact shape).

Plus a README row under Recall noting it only takes effect when recall_types includes raw facts, and tests covering: forwarding on both the tool path and the prefetch path when set, and the kwarg staying off the wire when unset.

Alternatives Considered

  • A server/bank-level default (HINDSIGHT_API_RECALL_PREFER_OBSERVATIONS=true, with per-bank override, explicit request still winning) — that is exactly vectorize-io/hindsight#5131's request and the better long-term home for the default. This issue only asks for the client-side opt-in in the meantime and does not propose closing #5131.
  • Proxying the MCP/tools call to rewrite arguments — heavy, fragile, and unnecessary when the client already forwards typed config to the same API.

Priority

Nice to have

Additional Context

  • Policy respect: we know and respect that this repository no longer accepts pull requests from outside the team (CONTRIBUTING.md, effective 2026-10-05); we are submitting this per the official channel as a feature request. The implementation referenced below is a reference branch on our fork — no PR has been or will be opened against this repository from it.
  • Provenance: original implementation was contributed in NousResearch/hermes-agent#64914 by @kumaxs, which was closed after the integration moved upstream; carryover of the closed hermes-agent PRs is tracked in vectorize-io/hindsight#4662.
  • Scope of the port (deliberate): this issue takes only the prefer_observations part of #64914. The PR's other half (min_scores) is not re-requested — vectorize-io/hindsight#5087 already covers per-stage score floors, and the integration now ships them (recall_min_scores).
  • Reference implementation: https://github.com/kumaxs/hindsight/tree/hermes-prefer-observations (branch hermes-prefer-observations, single commit b3e5e634, based on upstream main @ 9269b884 — a working reference for the approach, not a merge-ready patch: the deliverable is the hindsight-integrations/hermes directory on that branch). Tests in that branch: uv run pytest tests -v → 120 passed (8 new for this feature; all pre-existing tests green).
  • Related: vectorize-io/hindsight#5131 (server default + measured dedup benefit), vectorize-io/hindsight#5057 (integration:openclaw variant of the same gap), vectorize-io/hindsight#5087 (already-shipped score floors — no overlap with this).

Checklist

  • [x] I would be willing to contribute this feature (the reference implementation already exists on our fork; happy to refine it in this issue discussion — no PR will be opened, per policy)

kumaxs avatar Oct 07 '26 08:10 kumaxs

+1, with numbers from a self-hosted bank (server 1.0.0, ~5.7k active units) and one catch about #5617.

Why it matters. With recall_types: observation,world,experience (needed here: observation-only recall missed 2 of 5 facts retained earlier the same day), each auto-recall of ~55 results carried a raw fact next to the observation consolidated from it for about 20-25% of the slots. Sending prefer_observations: true straight to /memories/recall on the same 5 queries brought unique results from ~80% to ~97%, and the target facts still ranked in the top 15.

Why #5617 alone doesn't fix this for Hermes. The bank-level recall_prefer_observations default applies only when the request omits the field. The Hermes plugin pins hindsight-client>=0.10.1,<1, and the 0.10.x generated RecallRequest defaults prefer_observations to False; to_dict() uses exclude_none=True, so False is always serialized and overrides the bank default. Hermes users only get the bank default once the plugin can install a client whose default is None (or forwards the setting itself).

Suggested change (mirrors recall_min_scores; tested against current main, pytest tests -> 143 passed):

--- a/hindsight-integrations/hermes/__init__.py
+++ b/hindsight-integrations/hermes/__init__.py
@@ get_config_schema
+            {
+                "key": "recall_prefer_observations",
+                "description": "Drop raw world/experience facts that a returned observation was consolidated from, so recall with recall_types 'observation,world,experience' does not ship the same content twice; the freed slots backfill with the next results (Hindsight's prefer_observations). Applies to auto-recall and the hindsight_recall tool. No effect unless recall_types includes 'observation' and a raw type. Default off",
+                "default": False,
+            },
@@ settings
         self._recall_min_scores = _normalize_min_scores(cfg.get("recall_min_scores"))
+        self._recall_prefer_observations = bool(cfg.get("recall_prefer_observations", False))
@@ recall kwargs
         if self._recall_min_scores:
             kwargs["min_scores"] = self._recall_min_scores
+        if self._recall_prefer_observations:
+            kwargs["prefer_observations"] = True

Plus a README row and two tests in tests/test_provider.py: the flag reaches both the hindsight_recall tool and prefetch, and it is left out of the call by default.

WilliamMiceli avatar Oct 19 '26 18:10 WilliamMiceli

Hey, just pushing on this because it's been two weeks, it still isn't fixed and the issue is ongoing. I'll add my "Independent reproduction" on a much larger bank, plus one important detail.

Full disclosure: this was written with the help of an LLM, but I read every word, and I hope a human on your side looks into this, because we can't fix it without the Hindsight team.

Scale.

  • Self-hosted Hindsight, API 0.10.1-slim, plugin hindsight-integrations/hermes 1.2.3.
  • Bank: 33,908 nodes / 11,639 observations, recall_types: observation,world,experience, budget: high.
  • Same symptom: with the broad type set the raw world/experience facts come back next to the observation that consolidated them, so a recall budget of 15-25 results carries a large share of restated content.
  • Sending prefer_observations: true to /memories/recall directly removed ~88% of near-duplicate pairs (98 -> 12 on a 16-question set) with no coverage loss (hit@5 13/16 -> 16/16).
  • Observation-only recall was strictly worse (hit@5 12/16), so narrowing recall_types is not an alternative.

#5617 still will not help Hermes, and not only because the plugin omits the flag.

The flag is not omitted on the wire. In the pinned client (hindsight-client 0.10.1) the parameter itself defaults to False:

async def arecall(..., prefer_observations: bool = False, ...)

And the generated request model serializes that default rather than dropping it:

>>> RecallRequest.model_fields["prefer_observations"]
Annotated[bool, Strict(strict=True)] | None   default=False
>>> RecallRequest(query="test").to_dict()["prefer_observations"]
False
>>> RecallRequest(query="test", prefer_observations=None).to_dict()
# key absent

So a plugin that simply passes nothing sends an explicit false, which wins over the bank-level recall_prefer_observations introduced in #5617. Users who set the bank default (the natural place for it, and the one the control plane exposes) still get the old behaviour, with no warning.

Rather than hardcoding a plugin-side bool default, forward the setting as tri-state so the hierarchy from #5617 is honoured:

  • config unset -> pass prefer_observations=None (field dropped, bank default applies);
  • config true/false -> pass the bool explicitly.

That keeps the config key from the patch already proposed, but leaves the server-side default as the single source of truth, and it makes the plugin agree with the bool | None contract #5617 shipped. Worth a test for each of the three states, plus one asserting the key is absent from to_dict() when unset, the assertion most likely to catch a regression when the pinned client is upgraded.

We run this as a local overlay (the repo does not accept external PRs), so this is filed as evidence for the maintainers' own implementation rather than a patch we can carry upstream. Please look into this or give a way to help us improve the plugin so it looks as good as the ones i use in claude code, codex and opencode :/

atostivint avatar Oct 21 '26 16:10 atostivint

(withdrawn)

Eldsjal avatar Oct 26 '26 17:10 Eldsjal

I have a focused implementation for this request. It forwards both explicit boolean values so a profile can opt in or opt out independently of the shared bank default.

In our tested Linux environment, the Hermes profile recalls observations together with world and experience facts and requests prefer_observations: true. The bank default is false for clients that leave the preference unset. This illustrates why a profile-level override is useful when clients sharing a bank want different behavior.

The candidate forwards an explicit boolean to Hindsight's existing recall API. With SDK v1.1.0 or later, an unset profile preference leaves the bank default in control. The setting applies to mixed recall and deduplicates raw facts already represented by a recalled observation. All 192 plugin tests passed.

Focused patch

prmartinow avatar Nov 21 '26 10:11 prmartinow

Covered by recall_prefer_observations (#5617), a server-wide and per-bank setting. The Hermes plugin leaves it out of its recall calls, so the bank's value applies. Set it on the bank via PATCH /v1/default/banks/{bank_id}/config.

nicoloboschi avatar Nov 24 '26 14:11 nicoloboschi