Skip to content

fix(conversation_loop): invalidate stale housekeeping fallback on substantive tool-only turn - #64348

Merged
kshitijk4poor merged 3 commits into
NousResearch:mainfrom
kshitijk4poor:salvage/63888-stale-housekeeping-fallback
Jul 14, 2026
Merged

fix(conversation_loop): invalidate stale housekeeping fallback on substantive tool-only turn#64348
kshitijk4poor merged 3 commits into
NousResearch:mainfrom
kshitijk4poor:salvage/63888-stale-housekeeping-fallback

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Salvages #63888 (by @liuhao1024). Fixes #63860.

Original PR: clears stale _last_content_with_tools from a prior housekeeping-only turn when a substantive tool-only turn arrives. Without this, a cached housekeeping narration (e.g. 'I'll begin the work.') survived and was incorrectly surfaced as the final response, suppressing the post-tool nudge recovery.

Salvage fixes:

  • MEDIUM: also clear _mute_post_response when clearing stale fallback. A prior housekeeping turn may have set _mute_post_response=True, and without this reset, _vprint suppresses tool progress output until the no-tool-call branch at line ~4834 — after all tools have finished.
  • Added test: verify pure housekeeping turns (content + only housekeeping tools) still set the fallback correctly — the original use case the fallback was designed for.

Note: #64080 is a duplicate of #63888 with a slightly different implementation (elif approach). Both are functionally equivalent; #63888 was filed first and has green CI.

Verification: 2/2 focused tests pass, 416 broader tests pass, ruff clean.
Credit: original implementation by @liuhao1024 in #63888, preserved as feature commit author.

liuhao1024 and others added 3 commits July 14, 2026 01:32
…ool-only turns

A cached _last_content_with_tools response from a housekeeping-only turn
could survive a later substantive tool-only turn. When the model returned
an empty response, Hermes incorrectly finalized the older housekeeping
narration instead of invoking the post-tool empty-response nudge.

Production impact: scheduled cron jobs could return early without completing
their actual work (e.g., daily report job returning a housekeeping message
instead of producing the report artifact).

Root cause: The fallback state was only updated when a turn had both
content AND tool_calls. A turn with tool_calls but empty visible content
would skip state updates entirely, leaving stale fallback state intact.

Fix: Classify tools in every tool-call turn (regardless of visible content).
When any tool is substantive (non-housekeeping), clear the older fallback state
before processing later empty responses. This prevents two-turn-old housekeeping
narration from being treated as if it belonged to the immediately preceding
substantive tool turn.

Regression test added: tests/run_agent/test_conversation_fallback_state.py

Fixes NousResearch#63860
… turn

Salvage of NousResearch#63888. The original fix clears stale _last_content_with_tools
on substantive tool-only turns but doesn't clear _mute_post_response, which
a prior housekeeping turn may have set. This suppresses tool progress
output via _vprint until the no-tool-call branch resets it at line ~4834
— after all tools have finished executing.

Fix: also reset _mute_post_response = False when clearing stale fallback.

Added test: verify pure housekeeping turns (content + only housekeeping
tools) still set the fallback correctly — the original use case the
fallback was designed for.

Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
@kshitijk4poor
kshitijk4poor merged commit 3c2886f into NousResearch:main Jul 14, 2026
29 checks passed
@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Jul 14, 2026
@kshitijk4poor
kshitijk4poor deleted the salvage/63888-stale-housekeeping-fallback branch August 5, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P1 High — major feature broken, no workaround sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Stale housekeeping fallback survives a later substantive tool-only turn

3 participants