Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions agent/conversation_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4884,8 +4884,15 @@ def _perform_api_call(next_api_kwargs):
)
agent._emit_status(
"⚠️ Model produced reasoning but no visible "
"response after all retries. Returning empty."
"response — surfacing reasoning as response."
)
# Surface reasoning/thinking content as the response
# instead of "(empty)". Models that put their entire
# reply inside <think>/<thinking> blocks or return
# content only via reasoning_content/reasoning_details
# API fields would otherwise show blank to the user
# and cause infinite retry loops (#58117).
final_response = reasoning_text

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also change the terminal reason or exempt this fallback from the completion explainer. On current main, empty_response_exhausted plus a non-punctuated response of 24 characters or fewer makes agent/turn_finalizer.py:338-366 append “⚠️ No reply”; a valid reasoning fallback such as Yes would therefore receive a contradictory failure footer.

else:
logger.warning(
"Empty response (no content or reasoning) "
Expand All @@ -4899,8 +4906,7 @@ def _perform_api_call(next_api_kwargs):
+ (" and fallback attempts." if agent._fallback_chain else
". No fallback providers configured.")
)

final_response = "(empty)"
final_response = "(empty)"
break

# Reset retry counter/signature on successful content
Expand Down
4 changes: 2 additions & 2 deletions tests/run_agent/test_run_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4211,9 +4211,9 @@ def test_reasoning_only_response_prefill_then_empty(self, agent):
):
result = agent.run_conversation("answer me")
assert result["completed"] is True
# #34452: explanation replaces the bare "(empty)" sentinel.
# #58117: reasoning content is surfaced as the response instead of "(empty)".
assert result["final_response"] != "(empty)"
assert "No reply:" in result["final_response"]
assert result["final_response"] == "structured reasoning answer"
assert result["api_calls"] == 6 # 1 original + 2 prefill + 3 retries

def test_reasoning_only_prefill_succeeds_on_continuation(self, agent):
Expand Down
Loading