Skip to content

fix(loops): record disabled_reason on auto-pause - #73420

Merged
charlesvien merged 1 commit into
masterfrom
fix/loop-auto-pause-reason
Jul 24, 2026
Merged

fix(loops): record disabled_reason on auto-pause#73420
charlesvien merged 1 commit into
masterfrom
fix/loop-auto-pause-reason

Conversation

@charlesvien

Copy link
Copy Markdown
Member

Problem

Loops auto-pause after 5 consecutive failed fires (including usage-gate blocks), but unlike the lifecycle pauses (owner deactivated, GitHub disconnected) the kill-switch leaves disabled_reason null. A tripped loop reads as enabled=false with no recorded cause, so clients can't tell an auto-paused loop from one its owner paused, or say why it stopped.

Changes

The kill-switch now records why it paused the loop:

  • disabled_reason="usage_limited" when the pause was tripped by the cloud usage gate in fire_loop.
  • disabled_reason="repeated_failures" when tripped by a failed run reaching the threshold in handle_loop_run_terminal.

Re-enabling already clears the field and resumes schedules via facade/loops.py::update_loop, so recovery needs no changes. The field is already exposed by LoopSerializer; a companion desktop PR (PostHog/code#3779) renders the new values.

How did you test this code?

Extended the existing auto-pause tests in test_loop_runs.py to assert the recorded reason on both pause paths, and the below-threshold tests to assert the field stays null (the regression caught: a pause that flips enabled without recording a cause, or a reason written before the threshold). Ran test_loop_runs.py + test_loop_lifecycle.py locally: 50 passed. Ruff lint and format clean.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

N/A

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Authored with Claude Code (Fable 5). The session mapped the loops firing/kill-switch path and the existing lifecycle pause conventions, confirmed the usage gate and auto-pause already existed, and made the smallest change that lets clients render the pause cause: reuse the existing disabled_reason mechanism rather than adding a new status field or notification type. No repo skills were invoked.

@charlesvien charlesvien self-assigned this Jul 24, 2026
@charlesvien
charlesvien marked this pull request as ready for review July 24, 2026 03:45
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team July 24, 2026 03:46
@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "record disabled reason on loop auto-paus..." | Re-trigger Greptile

@posthog-bot-comment-resolver

Copy link
Copy Markdown

🔀 Tried to auto-resolve conflicts with master but this one needs a human.

I won't retry until the branch or master moves.

@charlesvien charlesvien added the stamphog Request AI approval (no full review) label Jul 24, 2026
@charlesvien
charlesvien force-pushed the fix/loop-auto-pause-reason branch from 7b81a6a to 92cbea8 Compare July 24, 2026 04:15

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Small, contained fix that records an existing disabled_reason field on two already-existing auto-pause paths; author owns the code with strong familiarity, tests cover both new and null cases, no unresolved concerns.

  • Author wrote 100% of the modified lines and has 9 merged PRs in these paths (familiarity STRONG).
  • 👍 on the PR from greptile-apps[bot], hex-security-app[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 19L, 1F substantive, 25L/2F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1b-small (25L, 2F, single-area, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ c711851 · reviewed head 92cbea8

@charlesvien
charlesvien enabled auto-merge (squash) July 24, 2026 04:18
@charlesvien
charlesvien disabled auto-merge July 24, 2026 04:18
@charlesvien
charlesvien enabled auto-merge (squash) July 24, 2026 04:18
@charlesvien
charlesvien merged commit ef89e7a into master Jul 24, 2026
236 of 237 checks passed
@charlesvien
charlesvien deleted the fix/loop-auto-pause-reason branch July 24, 2026 04:45
@deployment-status-posthog

deployment-status-posthog Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-24 05:12 UTC Run
prod-us ✅ Deployed 2026-07-24 05:25 UTC Run
prod-eu ✅ Deployed 2026-07-24 05:27 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant