fix(inbox): group repeated provider failures and clear recovered tasks (#22846)

## Thinking Path

> - Paperclip helps people manage work that agents do.
> - The inbox tells a person which tasks need a decision.
> - A provider usage limit can stop several attempts on one task or
affect several tasks.
> - Separate failure cards made it hard to tell which tasks still needed
attention.
> - This change groups failures using the account, reset time, or retry
links that Paperclip can verify.
> - A person can now see which task to retry, which tasks are waiting,
and which ones recovered.

## Linked Issues or Issue Description

**What existing behavior does this improve?**

It improves the Coordinator inbox when a provider limits usage.

**Current behavior**

Repeated run failures can fill the inbox. Resolved failures can still
appear beside open decisions.

**Proposed behavior**

Show personal actions in Needs you, automatic retries and snoozes in
Waiting, and past events in History. Keep an archived retry chain hidden
during automatic attempts. Return it to Needs you when a person must
act.

**Additional context**

Related work includes #18020 on completed tasks, #9704 on archive
behavior, and #21570 on usage limits in chat.

## What Changed

- Group verified account and reset windows. When that evidence is
missing, count linked attempts per task and show the tasks in a
collapsible group.
- Separate the reported reset time from each task’s retry schedule. Keep
unresolved ownership recoveries visible after task closure. Use
persisted native retry requests to preserve the original archive and
increment the attempt count.
- Keep personal archive in the card menu. Put decision receipts and run
logs in History.
- Align inbox filters, tabs, and history. Share empty-state artwork and
placement across Inbox, Goals, Routines, and Secrets.
- Index run-history pages and resumed-work lookups, and rate-limit
history requests per company and viewer. Add synthetic fixtures for both
grouping paths and a manual walkthrough.

## Verification

- The author and a human tester completed the synthetic retry-chain
walkthrough. Chromium also verified archive, repeat failure, exhaustion,
and recovery.
- The 64 focused server tests and the UI and server typechecks passed
before rebasing. See `doc/testing/coordinator-inbox-test-drive.md` to
repeat the manual checks.
- The shared SDK input check and all 64 focused server tests passed
after rebasing. The OpenAPI suite (59 tests), API catalog suite (2,309
tests), and both demo seed paths passed locally after the CI fixes.
- The affected inbox and native-runtime suites passed locally after
merging the upstream conformance test fix in #22854. The browser
access-denial scenarios passed three runs each for 403 and 404.
- The migration checks and 79 focused tests passed, including an
index-plan regression with 5,000 unrelated runs. The migration and query
plan were reverified after renumbering. [Full CI on
`cf52b80161`](https://github.com/paperclipai/paperclip/actions/runs/45529834793)
passed after rerunning a timed-out server shard.

## Risks

The attention feed reads retry ancestry. Long chains can increase query
cost. Task and company checks bound the traversal, and cycle detection
stops repeated visits. Providers that omit the reset time leave the card
with an unknown reset. Migration 0508 adds two indexes concurrently.
Each run-history page returns at most 100 records.

## Model Used

OpenAI Codex, GPT-6 family, with repository editing, local test
execution, and browser verification.

## 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
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Scott Tong <scott@scotts-mbp-m5-max.local>
Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
authored and GitHub committed 2026-11-24 18:33:27 -08:00
1 parent f961287949
commit 627d59c5aa
50 files changed
+1759 -234

No files matched your search

+29 -1
View File
@@ -20,7 +20,7 @@ The feed accepts these query parameters:
| Parameter | Meaning |
| --- | --- |
| `view` | `mine`, `unassigned`, `company`, `archived`, or `all`. The API default is `all`. |
| `view` | `mine`, `unassigned`, `company`, `waiting`, `archived`, or `all`. The API default is `all`. |
| `includeDismissed` | Include personally hidden cards. Default: `false`. |
| `archived` | Read retained source archives instead of current sources. This differs from personal `view=archived`. |
| `all` | Return a complete snapshot instead of a page. |
@@ -35,6 +35,15 @@ and counts once. `deskBadgeCount` counts requests assigned to the viewer.
Summary returns the same current counts without card bodies. Tasks also returns
unique `taskIds` for visible requests. Neither endpoint returns card bodies.
`view=waiting` returns automatic provider retries visible to the caller and
cards the caller has snoozed. The optional `waitingCount` counts waiting cards.
The optional `nextSnoozeAt` gives the earliest active snooze expiry.
A provider-limit card carries `providerLimit`. Its `grouping` is
`account_window` for a verified account and reset, or `retry_chain` for
linked attempts on one task. Its `state` is `scheduled`, `retry_requested`,
or `needs_retry`. The provider's `resetAt` and Paperclip's scheduled
`retryAt` can each be null.
Routing uses explicit recipients, chat ownership, review participants, task
assignees, human instigators, and configured decision owners. A card with no
owner enters Unassigned. After seven days it moves to Company. A required
@@ -113,6 +122,25 @@ for the caller. Filters include `search`, `outcome`, `agentId`, `projectId`,
Withdrawn requests, expired requests, and requests closed with their task have
separate outcomes. Personal archive and snooze do not record consent.
## Recent run history
```text
GET /api/companies/{companyId}/attention/run-history
```
Returns a JSON array of up to 100 failed, timed-out, or provider-held runs
on tasks the board user can read. Each entry includes `runId`, `agentId`,
`agentName`, `taskId`, `taskTitle`, `identifier`, `recordedAt`, `reason`,
and `outcome`. Rows are ordered by run creation time, newest first, then by
run ID descending when times match.
Omit query parameters for the first page. For the next page, pass the last
row’s exact `recordedAt` string as `at` and its `runId` as `id`. Keep the
timestamp’s fractional seconds. The next page starts after that row. A page
with fewer than 100 rows is the last page. A partial or invalid cursor returns
HTTP 400. Each company and board user can make up to 60 run-history
requests per minute. HTTP 429 includes a `Retry-After` header in seconds.
## Errors
| Status | Meaning |