Skip to content

fix: auto-disable unhealthy automations - #352

Open
malhotra5 wants to merge 3 commits into
mainfrom
auto-disable-unhealthy-automations
Open

fix: auto-disable unhealthy automations#352
malhotra5 wants to merge 3 commits into
mainfrom
auto-disable-unhealthy-automations

Conversation

@malhotra5

Copy link
Copy Markdown
Member

Summary

Implements Linear OSS-9472 by auto-disabling automations that repeatedly fail for permanent, user-actionable reasons and exposing the current blocking reason on the automation API response.

Changes include:

  • classify permanent automation failures from structured status_detail / SDK callback metadata (auth, config, quota, blocked, user_action=settings, non-retryable blocking factors)
  • auto-disable after a configurable consecutive permanent failure threshold (AUTOMATION_FAILURE_DISABLE_THRESHOLD, default 3; <=0 disables the behavior)
  • persist current disabled state on automations (disabled_reason, disabled_detail, disabled_at) for list/detail API consumers
  • add automation_disable_events history table to track each auto-disable occurrence over time
  • reject manual dispatch of disabled automations with 409 plus the blocking reason/detail
  • skip dispatcher polling for pending runs whose automation is disabled/deleted
  • preserve callback-reported blocking factors/task outcomes as run.status_detail

Validation

Passed:

  • uv run ruff check openhands/automation/models.py openhands/automation/config.py openhands/automation/dispatcher.py openhands/automation/router.py openhands/automation/schemas.py openhands/automation/utils/run.py openhands/automation/utils/run_status_detail.py openhands/automation/utils/unhealthy.py tests/test_unhealthy_automations.py tests/test_schemas.py tests/test_run_status_detail.py tests/test_dispatcher.py tests/test_router.py migrations/versions/017_add_automation_disabled_reason.py
  • uv run pyright openhands/automation/models.py openhands/automation/utils/run.py openhands/automation/utils/unhealthy.py tests/test_unhealthy_automations.py
  • uv run pytest tests/test_unhealthy_automations.py tests/test_run_status_detail.py tests/test_schemas.py -q

Not run successfully in this environment:

  • targeted dispatcher/router tests that use the shared Postgres testcontainer fixture, because Docker is unavailable (/var/run/docker.sock missing).

Notes

No PR template file was present in .github/, so this uses the repo's conventional Summary/Validation format.

This PR was created by an AI agent (OpenHands) on behalf of the user.

@malhotra5 can click here to continue refining the PR

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions github-actions Bot added the type: fix A bug fix label Aug 20, 2026
@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Coverage

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

Copy link
Copy Markdown
Contributor

🔍 Review in progress…

We are performing the review through OpenHands Cloud Automation. You can log in and view the conversation here.

@malhotra5
malhotra5 marked this pull request as ready for review August 21, 2026 13:26
Co-authored-by: openhands <openhands@all-hands.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants