Skip to content

fix: surface non-FINISHED DelegateTool sub-agents as errors - #6498

Open
Christian-Sidak wants to merge 1 commit into
OpenHands:mainfrom
Christian-Sidak:fix/issue-6488
Open

Christian-Sidak wants to merge 1 commit into
OpenHands:mainfrom
Christian-Sidak:fix/issue-6488

Conversation

@Christian-Sidak

@Christian-Sidak Christian-Sidak commented Nov 5, 2026 •

Copy link
Copy Markdown

HUMAN:

This fix addresses silent error swallowing in DelegateTool where non-FINISHED sub-agent outcomes (ERROR, STUCK, PAUSED) were being silently reported as successful results with is_error=False, making it impossible for callers to detect that a delegated sub-agent had failed.


AGENT:

Why

DelegateExecutor._delegate_tasks never checked conversation.state.execution_status after running a sub-agent, so ERROR, STUCK, and PAUSED outcomes were silently reported as ordinary results with is_error=False. This meant callers had no way to detect that a delegated sub-agent had failed.

Summary

  • Added _run_stop_detail static method that extracts why a sub-agent stopped and preserves any partial output.
  • After _run_until_finished, only a FINISHED sub-agent goes into results; any other status goes into errors with the status name and detail included.
  • The final DelegateObservation now carries is_error=True when at least one delegated sub-agent did not finish.

Issue Number

Fixes #6488

How to Test

Run the new unit tests:

python -m pytest tests/tools/delegate/test_delegation.py -v

New tests:

  • test_delegate_finished_sub_agent_is_not_error: FINISHED sub-agent produces is_error=False
  • test_delegate_error_sub_agent_sets_is_error: ERROR sub-agent produces is_error=True with status named in output
  • test_delegate_stuck_sub_agent_sets_is_error: STUCK sub-agent produces is_error=True with status named in output
  • test_delegate_mixed_results_sets_is_error: one good + one errored sub-agent yields is_error=True

All 20 existing tests in tests/tools/delegate/test_delegation.py continue to pass.

Video/Screenshots

No visual changes. See test output above.

Design Doc

No design doc needed for this targeted bug fix.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

The _run_stop_detail helper mirrors the pattern from TaskManager._run_stop_detail (#3742) for consistency.

DelegateExecutor._delegate_tasks never checked conversation.state.execution_status,
so sub-agents that ended in ERROR, STUCK, or PAUSED were reported as ordinary
completed results with is_error=False. This brought it in line with the TaskManager
fix from e75b9c2 (OpenHands#3742).

Changes:
- Add ConversationErrorEvent import to delegate/impl.py
- Add _run_stop_detail static method (mirrors TaskManager) that extracts the
  reason a sub-agent stopped and preserves any partial output
- In run_task: check execution_status after _run_until_finished; only FINISHED
  goes into results, all other statuses go into errors with status name + detail
- Pass is_error=bool(errors) to the final DelegateObservation

Add four regression tests covering FINISHED, ERROR, STUCK, and mixed outcomes.

Fixes OpenHands#6488

Signed-off-by: Christian Sidak <christian@sentineltech.eu>
Signed-off-by: Christian-Sidak <61099993+Christian-Sidak@users.noreply.github.com>
@Christian-Sidak

Copy link
Copy Markdown
Author

Checking in on this. The fix ensures that when a DelegateTool sub-agent finishes in a non-FINISHED state (FAILED, REJECTED, CANCELLED, etc.) the caller sees an error result rather than an empty success. CI is green.

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]: DelegateTool reports errored, stuck or paused sub-agents as completed work

1 participant