Files
PaperClipAI/docs/api/attention.md
T
627d59c5aa 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>
2026-11-24 18:33:27 -08:00

7.3 KiB
Raw Blame History

title, summary
title summary
Attention inbox Personal request routing, close actions, and decision history

The attention API projects pending requests and operational alerts into an inbox. All routes require a board user with access to the company. Task and approval privacy checks apply to cards, counts, history, and receipts. Agents cannot use these board routes.

Read the inbox

GET /api/companies/{companyId}/attention
GET /api/companies/{companyId}/attention/summary
GET /api/companies/{companyId}/attention/tasks

The feed accepts these query parameters:

Parameter Meaning
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.
limit, cursor Page size and opaque continuation cursor. Default size: 50; maximum: 100.
sort activity or decide.
activitySince, activityUntil Inclusive activity bounds in ISO date-time format.
queue Filter by a decision queue key.

The response includes items, totalCount, countsBySourceKind, viewCounts, deskBadgeCount, and nextCursor. Related evidence shares one obligation lead 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 request that waits 30 days escalates to the configured decision owner or Company. Task privacy still applies. Escalation keeps the request pending and its gate closed.

view=mine also includes receipts when someone else handles the viewer's request. Receipts expire after seven days. They do not count as decisions or in the badge. Every approval-linked task must remain readable to return an approval receipt.

Claim or transfer

POST /api/companies/{companyId}/attention/{sourceKind}/{sourceId}/claim
POST /api/companies/{companyId}/attention/{sourceKind}/{sourceId}/transfer

Claim has no body. Transfer takes { "userId": "<user ID>", "reason": "optional" }. These operations support issue_thread_interaction sources. Claim assigns an ownerless request to the caller. Changing an addressed request requires its current addressee or an active company owner/administrator (or an instance administrator). Transfer assigns it to a writer who can read the task and satisfy the interaction creator exclusions and the task review policy. Viewers cannot claim or transfer requests. A chat question stays with its chat owner. A request to an agent that can still answer stays with that agent.

The addressee is part of resolution authorization, so routing validates authority and the recipient under task and interaction row locks before updating it. Inbox view placement alone grants no authority. Concurrent claims and transfers retain their compare-and-set checks. An identical repeated assignment returns alreadyClaimed or alreadyTransferred. Changes record attention.claimed or attention.transferred activity.

Close a card

POST /api/companies/{companyId}/attention/{sourceKind}/{sourceId}/close

Use one of these bodies:

{ "mode": "archive", "fingerprint": "<changeFingerprint from the card>" }
{ "mode": "snooze", "until": "2099-01-01T12:00:00.000Z", "fingerprint": "<changeFingerprint>" }
{ "mode": "withdraw", "reason": "The proposal is no longer needed" }

Archive and snooze affect only the caller. The source stays pending. Hiding obligation evidence hides its lead and all related evidence. The returned itemKey identifies the personal dismissal. Restore it through the existing inbox-dismissal restore endpoint. A content change or a new assignment to the viewer can make a hidden card return. A snoozed card also returns when time expires.

Withdrawal affects everyone. It cancels an interaction, approval, or decision through that source's existing lifecycle. Review policy and execution checks still apply. A hire request must be rejected through approvals instead. The card's closeModes lists its supported actions. A successful close records attention.closed activity and returns the source, mode, dismissal key, and time.

Decision history

GET /api/companies/{companyId}/attention/history

History includes resolved interactions, decisions, and approvals. scope=mine shows work handled by or for the caller. scope=all shows accessible company history. handledForMe=true narrows it to work handled for the caller. Filters include search, outcome, agentId, projectId, since, sort=newest|oldest, limit (maximum 100), and cursor. Withdrawn requests, expired requests, and requests closed with their task have separate outcomes. Personal archive and snooze do not record consent.

Recent run history

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
400 Invalid source kind, UUID, filters, cursor, or request body; a snooze needs a future time.
403 No company access, no board user context, read-only membership, or a denied review policy.
404 Missing source or a source the caller cannot read.
409 Another person claimed, routed, or answered first; the request is already closed; or execution prevents withdrawal.
422 Unsupported operation, unavailable recipient, recipient without task access, or a chat ownership constraint.

A closed-source conflict includes code: attention_already_closed and the recorded resolver when known. Clients should refresh the feed and show that outcome instead of retrying a decision automatically.