Skip to content

fix: alert on every failure streak of a watch, not just the first - #60

Merged
davidmckayv merged 1 commit into
CopilotKit:mainfrom
asasemahmed:fix/watch-alert-episodes
Sep 26, 2026
Merged

davidmckayv merged 1 commit into
CopilotKit:mainfrom
asasemahmed:fix/watch-alert-episodes

Conversation

@asasemahmed

Copy link
Copy Markdown
Contributor

What changed

A failing watch sends two alerts: "retry scheduled" on the first failure, and "paused" after five failures. The notification ID is hash("watch-error:<task>:<retry|paused>"), stored with insertIfAbsent, and notifications are only marked read, never deleted.

That key never changes for the life of the watch. So after the watch is resumed, or recovers, and later fails again, both alerts dedupe against the first streak's. The owner is never told that the watch paused a second time.

Now the task state keeps a failureStreak counter. It increases when failures goes from 0 to 1 (after a success or a resume, both of which already reset failures), and it is part of the alert key: watch-error:<task>:<streak>:<retry|paused>. Each failure streak alerts once for the retry and once for the pause. Replaying the same outcome still dedupes, because the key comes from the saved state.

Verification

  • A new test in tests/workflows.test.ts fails a watch until it pauses, resumes it with controlMonitor(resume), and fails it until it pauses again. It expects 4 distinct alerts, and 4 after one more replayed tick.
    • main: 2 alerts.
    • This branch: 4.
  • The existing backoff/pause test still passes.
  • pnpm typecheck and pnpm build:server pass. Biome reports no issues for the changed files.
  • pnpm test: 171 passed, 1 failed. The failure is Docker subprocess uses literal argv…, which fails on Windows with or without this change.

Integration limits

Tasks saved before this change have no failureStreak, so their next failure alert uses the new key format and may notify once more than before.

@davidmckayv

Copy link
Copy Markdown
Contributor

Approved to merge, but it now conflicts with main in apps/server/src/engine/service.ts after #41 landed. Rebase onto main and it will be merged once CI is green.

A failing watch notifies once when a check fails and once when it
pauses after five failures. The notification ID is derived from
watch-error:<task>:<retry|paused>, and notifications are only marked
read, never deleted. So after the watch is resumed (or recovers) and
starts failing again, both alerts dedupe against the old ones and the
owner is never told the watch paused again.

Track a failureStreak counter in the task state that increases when
failures goes from 0 to 1, and include it in the alert key. Each
streak alerts once for the retry and once for the pause, and
replaying the same outcome still dedupes.

@davidmckayv davidmckayv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The rebase preserves the accepted failure-streak fix and its recovery regressions. All seven CI checks pass on the reviewed head.

@davidmckayv
davidmckayv merged commit 60fdd35 into CopilotKit:main Sep 26, 2026
7 checks passed
markhiltonapps pushed a commit to markhiltonapps/openmuse that referenced this pull request Sep 27, 2026
Brings in five fixes from CopilotKit/OpenMuse main:
- keep browser evidence identity separate from session identity (CopilotKit#29)
- suggest the openai/ prefix for gateway model IDs (CopilotKit#55)
- alert on every failure streak of a watch, not just the first (CopilotKit#60)
- show the browser as offline when its worker is unreachable (CopilotKit#64)
- keep completed reviewed actions terminal on replay (CopilotKit#37)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MfTjvNDS5CdhPPisYxjwAv
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