Repository navigation
fix(hermes): stop queued prefetch work that recall never reads - #2781
Merged
Merged
Conversation
Hermes queues a background prefetch after turn N with that turn's text and prefetches turn N+1 with the next prompt. The provider cached the queued result under the exact query, so real turns almost never hit it: each turn paid an extra prepare request, and nonempty results stayed in the cache until a Scope or session change. Turn-start prefetch already prepares the current prompt synchronously, the behavior the README documents and other hosts share. Make queue_prefetch an explicit no-op, as Hermes' ByteRover provider does, and remove the cache, its lock, its cleanup and the trace's "cache" status. Recalled content on real turns is unchanged. Rewrite the tests that relied on the cache, cover that a queued prefetch sends nothing and the next prefetch prepares its own prompt, drop the queue_prefetch in-process entry, and update the user-facing docs and the plugin manifest's hook list.
…l in RFC 1489 The Scope-binding test asserts the recalled text again comes from the newly bound Scope. The RFC 1489 Hermes row and cache-identity paragraph describe per-turn preparation instead of a prefetch cache.
Fengzdadi
requested review from
Alanxtl,
PsiACE and
zhanghuidinah
as code owners
November 23, 2026 03:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue or RFC does this PR close?
No tracking issue. This fixes a defect in the Hermes provider's background prefetch and updates the Hermes row of RFC 1489 (
docs/en/rfcs/1489_prepared_context_text_assembly.md) to match.Rationale for this change
Hermes calls
queue_prefetchafter turn N with turn N's text (run_agent.py) andprefetchat the start of turn N+1 with the next prompt (agent/turn_context.py). The provider cached the queued result under the exact query, so the cache almost never hit: every turn paid one backgroundprepare_contextwhose result was never read, and_prefetch_cachekept growing until the Scope or session changed.What changes are included in this PR?
queue_prefetchinintegrations/hermes/plugins/powercontext/provider.pyis now an explicit no-op, as in Hermes' own ByteRover provider. The prefetch cache, its lock, its cleanup and thecachetrace status are removed. Turn-start recall stays synchronous and prepares the current prompt.plugin.yamldropsqueue_prefetchfrom the advertised hooks. Hermes reads that list only for its plugin catalog and validation, not for loading.integrations/hermes/README.md,docs/{en,zh}/docs/integrations/hermes.mdanddocs/{en,zh}/rfcs/1489_prepared_context_text_assembly.md(the Hermes row and the cache-identity paragraph) describe the new behavior.tests/integrations/test_hermes_provider.pygains a regression test:queue_prefetchsends nothing, and the nextprefetchprepares only its own prompt. The Scope-binding test now blocks a capture and checks that the recalled content comes from the new Scope.tests/inprocess_adapter_turns.pydrops the Hermesqueue_prefetchentry, which no longer sends a request.Are there any user-facing changes?
Hermes users see one fewer
prepare_contextrequest per turn, and recall still uses each turn's current prompt. A prompt that repeats the previous turn's text is now prepared fresh instead of being served from the result queued after that turn. Withevaluation_traceenabled, recall trace records no longer use thecachestatus. There are no configuration, API or persisted-format changes.How was this change tested?
UV_OFFLINE=1 UV_NO_SYNC=1 uv run pytest -q tests/integrations/test_hermes_provider.py tests/integration_conformance tests/test_recall_query_bound.py tests/test_integration_manifest.py: 294 passed, 1 skipped (the real-manager test without a Hermes checkout).tests/integration_conformance/hermes/test_real_manager.py) passed against a Hermes checkout at the pinned 4131fd95 on Python 3.14.7.provider.pymakes the new regression test fail.ruff check,ruff format --checkandty checkon the changed paths are clean.prek run --from-ref upstream/master --to-ref HEADpasses every hook exceptty-check, whose 20 unresolved-import diagnostics are in master's deepagents and Gemini CLI code, because the offline environment predates those dependencies.AI usage statement
Claude Code (Claude Opus 5.5) wrote the code, tests and this description; the diff and test results were reviewed before submission.