mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-09 13:21:42 +00:00
fix(gateway): re-baseline agent-cache message_count before in-band queued follow-up turn
The cross-process cache-coherence guard (#45966) re-baselines the cached agent's message_count only on the external-turn boundary (#46237, at _handle_message_with_agent). The in-band queued (/queue) follow-up recurses into _run_agent mid-chain with the stale build-time snapshot, so the follow-up's guard sees the first turn's own writes as a mismatch and rebuilds the agent -- re-introducing the every-turn rebuild / prompt-cache destruction #46237 set out to prevent, on the in-band path. Re-baseline before the recursion, symmetric with the accepted external-path fix.
This commit is contained in:
parent
22a137ed40
commit
b4cacba6ae
1 changed files with 16 additions and 0 deletions
|
|
@ -18206,6 +18206,22 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
# Re-baseline the cached agent's message_count snapshot before
|
||||
# recursing into the in-band queued (/queue) follow-up turn.
|
||||
# The first turn has completed and flushed its own user +
|
||||
# assistant rows to the SessionDB, so the cross-process
|
||||
# coherence guard (#45966) — which this recursive _run_agent
|
||||
# call re-enters — would otherwise see the grown on-disk count
|
||||
# against the stale build-time snapshot and rebuild the agent
|
||||
# on THIS process's OWN writes, destroying the prompt-cache
|
||||
# prefix #46237 was merged to preserve. The existing
|
||||
# re-baseline in _handle_message_with_agent only runs after the
|
||||
# whole _run_agent chain unwinds — too late for the in-band
|
||||
# follow-up. Use the same (session_key, session_id) the
|
||||
# recursive call runs under so the snapshot matches exactly
|
||||
# what the follow-up's guard will consult. Fail-safe in helper.
|
||||
self._refresh_agent_cache_message_count(session_key, session_id)
|
||||
|
||||
followup_result = await self._run_agent(
|
||||
message=next_message,
|
||||
context_prompt=context_prompt,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue