Skip to content

Bugfix: avoid stale tool-turn fallback on empty responses#9432

Closed
HiddenPuppy wants to merge 2 commits into
NousResearch:mainfrom
HiddenPuppy:codex/fix-empty-tool-fallback
Closed

Bugfix: avoid stale tool-turn fallback on empty responses#9432
HiddenPuppy wants to merge 2 commits into
NousResearch:mainfrom
HiddenPuppy:codex/fix-empty-tool-fallback

Conversation

@HiddenPuppy

Copy link
Copy Markdown
Contributor

Summary

  • only cache _last_content_with_tools when every tool call in the turn is housekeeping-only
  • clear that fallback cache for substantive tool turns so an empty follow-up cannot silently terminate unfinished work
  • add regression tests covering both the substantive-tool retry path and the housekeeping-only fallback path

Root Cause

Hermes cached visible assistant content from any turn that also contained tool calls. When the next model response came back empty, the loop could reuse that earlier content as the final answer even if the tool turn represented in-progress multi-step work.

Validation

  • git diff --check
  • python3 -m py_compile run_agent.py
  • python3 -m py_compile tests/run_agent/test_run_agent.py
  • Full pytest was not runnable locally in this environment because the machine does not currently have the repo's required Python 3.11 + dev test toolchain installed.

Closes #9400

@HiddenPuppy HiddenPuppy force-pushed the codex/fix-empty-tool-fallback branch from b3e48d1 to dbd90f6 Compare April 14, 2026 14:58
@teknium1

Copy link
Copy Markdown
Contributor

Closing — the core fix here (don't use substantive tool turn content as fallback) already exists on main via the _last_content_tools_all_housekeeping gate at the fallback check (line ~10894). Main takes a slightly different approach (gate on read rather than gate on write) but the net behavior is identical: only housekeeping-only tool turns provide fallback content.

Your regression tests were well-written — thanks @HiddenPuppy for the contribution.

@teknium1 teknium1 closed this Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Empty response after tool calls silently abandons incomplete multi-step tasks

2 participants