mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Recovery arms an "AI provider quota" monitor when a run fails with `provider_quota` > - The monitor fires at the reset time, or when a board user clicks "Check now" > - It asks for another bounded retry of the failed source run, but that run used its retries before the monitor was armed > - The dispatcher then queues nothing and still logs `issue.monitor_triggered`, and recovery arms the same monitor again > - This pull request makes an exhausted quota retry fall back to a normal monitor wake > - The benefit is that a task waiting on a provider quota resumes at the reset without manual help ## Linked Issues or Issue Description Fixes: #16198 Refs #10374, #15613, #17015 (an automated fix for the same issue) ## What Changed - `server/src/services/heartbeat/scheduling.ts`: in `dispatchClaimedIssueMonitor`, a quota monitor whose bounded retry returns `retry_exhausted` now calls `enqueueWakeup` like every other monitor. The existing deferred-wake handling applies to it. - Tests: one database test in `issue-monitor-scheduler.test.ts` (conversation-continuation source run with `scheduledRetryAttempt: 2`). Rebased onto `master` on 2026-11-21. The earlier reset-parser change is dropped: `master` now parses reset times in `provider-quota-reset.ts`, whose `(?![\d:])` lookahead already stops an ISO year being read as an hour. ## Verification - `npx vitest run src/__tests__/issue-monitor-scheduler.test.ts` in `server`, after the rebase: 21 passed, 2 failed. - The new test fails with the source change reverted and passes with it. - The two failures (`lets the board check a scheduled monitor on an in_progress task` and `... on an blocked task`) fail identically with the source change reverted, so they are not caused by it. - The same change runs as a local patch on a self-hosted instance: a stuck task resumed after a manual wake, and the patched build starts cleanly. ## Risks Low. Only the `retry_exhausted` outcome of the quota branch changes. If the quota is still spent, the woken run fails again and recovery arms a new monitor at the next reset, so the loop is bounded by the provider reset times. Runs that need reconciliation still go to `terminalizeLegacyExecution` first, and native source runs are still refused before the retry is scheduled. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Anthropic Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits) and extended thinking. It traced the bug, wrote the change and the tests, rebased the branch, and ran them. A human reviewed and approved the change. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green (pending on the rebased push) - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups (pending on the rebased push) - [x] I will address all Greptile and reviewer comments before requesting merge