Skip to content

Conversation

@enyst
Copy link
Collaborator

@enyst enyst commented Dec 11, 2025

Summary

When the LLM returns a content-only assistant message (no tool calls), yield control back to the user instead of marking the conversation finished or continuing the loop.

Changes

  • Agent.step: after emitting the MessageEvent for a content-only reply, set execution_status=IDLE
  • LocalConversation.run: treat IDLE as a terminal condition for the current run (break)
  • Tests: update unit tests to expect IDLE instead of FINISHED on content-only turns

Rationale

  • Avoids repeated LLM calls and monologue stuck detection after content-only replies
  • Semantics: text-only reply hands the turn back to the user; the task is not necessarily complete
  • Keeps FINISHED for explicit completion paths (e.g., FinishAction)

Notes

  • This PR targets the existing PR branch fix-premature-conversation-termination-clean as requested
  • Follow-up: CLI will be updated to gracefully handle IDLE in confirmation mode loops (non-confirmation mode already fine)

Co-authored-by: openhands openhands@all-hands.dev

@enyst can click here to continue refining the PR

enyst and others added 3 commits December 11, 2025 21:23
- Set execution_status=IDLE in Agent.step() when LLM returns content without tool calls
- Break run() loop on IDLE in LocalConversation
- Update tests to expect IDLE (instead of FINISHED) for content-only turns

Co-authored-by: openhands <openhands@all-hands.dev>
- confirmation_mode: message-only and confirm-path now expect IDLE
- pause_functionality: finished assertions updated to IDLE for content-only

Co-authored-by: openhands <openhands@all-hands.dev>
- Add _new_user_message flag to LocalConversation
- send_message() sets the flag; run() clears it per-iteration
- Break on IDLE only if no new user message arrived; never break on FINISHED
- Preserves race fix for TestMessageWhileFinishing while yielding IDLE on content-only

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions
Copy link
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/agent
   agent.py1674970%85, 89, 147, 151–152, 161–162, 178–180, 187–189, 191, 195, 198–199, 201, 219, 246, 251, 262, 301, 306, 317, 320, 343, 353–354, 375–377, 379, 391–392, 397–398, 418–419, 424, 436–437, 442–443, 475, 482–483, 511, 518
openhands-sdk/openhands/sdk/conversation/impl
   local_conversation.py2217366%134, 136–137, 176–177, 200, 205, 221, 228, 240, 248–250, 254–255, 300, 308, 326–327, 330, 337, 355, 361–362, 365, 374, 390, 392, 394, 398, 400–402, 404, 406, 412–413, 426–427, 429, 431, 435–438, 455–456, 461, 466, 468, 473, 475–477, 495, 497, 501, 506, 511, 516–519, 525, 528, 532, 535, 537–539, 541, 559, 561
TOTAL12419564354% 

enyst and others added 4 commits December 11, 2025 22:29
- confirmation_mode: append finish branch after message-only scenarios
- pause_functionality: append finish branch after content-only scenarios
- agent_status_transition: re-add LLM call-count assertion when already finished

Co-authored-by: openhands <openhands@all-hands.dev>
- confirmation_mode: combine message-only then finish via side_effect
- validate finish ActionEvent and ObservationEvent, and no pending actions

Co-authored-by: openhands <openhands@all-hands.dev>
…ith call-counts

- Remove duplicate IDLE assert
- First turn: content-only -> IDLE
- Second turn: finish -> FINISHED; assert LLM call counts

Co-authored-by: openhands <openhands@all-hands.dev>
…guarded promotion

- Do not promote IDLE->RUNNING when no new user message
- Let run() always enter try/finally for proper span/end and error wrapping

Co-authored-by: openhands <openhands@all-hands.dev>
@openhands-ai
Copy link

openhands-ai bot commented Dec 12, 2025

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • Run tests

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #1385 at branch `feature/idle-on-content-break`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

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.

2 participants