Skip to content

fix(agent): clear stale failure state when resuming runner iterations - #5995

Merged
Re-bin merged 1 commit into
HKUDS:mainfrom
KailBug:fix/clear-recovered-runner-errors
Oct 2, 2026
Merged

Re-bin merged 1 commit into
HKUDS:mainfrom
KailBug:fix/clear-recovered-runner-errors

Conversation

@KailBug

@KailBug KailBug commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix successful recovery being reported as a failed run after a late follow-up message, which can suppress the final WebSocket reply.

Root Cause

The model-error and empty-response paths assign stop_reason and error before checking for late follow-up messages.

When a follow-up resumes execution, these values survive into subsequent iterations. A successful response replaces the content but retains the previous failure state.

For model errors, this causes TurnDelivery to skip the final WebSocket reply and publish a failed completion. The runner also invokes on_error despite having recovered successfully.

Changes

  • Reset stop_reason and error at the start of each runner iteration.
  • Add parameterized regression coverage for recovery after model errors and exhausted empty-response retries.
  • Verify final reply delivery, successful completion, and absence of a stale run-level error callback.

Result

Recovered runs return stop_reason="completed" and error=None. The final WebSocket reply is queued, and turn completion reports success.

Failures that terminate execution continue to retain their failure state.

Test

  • Before the fix, both new regression cases failed:
    • Model-error recovery produced no final outbound reply.
    • Empty-response recovery retained empty_final_response.
  • After the fix: 239 tests passed across runner, injection, hooks, delivery, loop recovery/integration, SDK streaming, and facade tests.
  • Ruff passed for both changed files.
  • BasedPyright passed for nanobot/agent/runner.py.
  • git diff --check passed.

@chengyongru chengyongru added bug Something isn't working fix priority: p2 Normal backlog: minor bug, enhancement, docs, cleanup, edge case, or unvalidated proposal. regression test labels Sep 30, 2026
@Re-bin
Re-bin force-pushed the fix/clear-recovered-runner-errors branch from 7293b7c to aea1740 Compare October 2, 2026 15:07
@Re-bin
Re-bin force-pushed the fix/clear-recovered-runner-errors branch from aea1740 to 30960fa Compare October 2, 2026 16:54

@Re-bin Re-bin left a comment

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.

LGTM. Resets iteration-local failure state so a recovered run is not reported as failed, while preserving real terminal errors. Current-head CI and focused runner tests pass; request assembly and runtime ownership are unchanged.

@Re-bin
Re-bin merged commit 5825e15 into HKUDS:main Oct 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix priority: p2 Normal backlog: minor bug, enhancement, docs, cleanup, edge case, or unvalidated proposal. regression test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants