mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 23:06:17 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Agents ask each other questions with issue thread interactions (cards). A card can name an `addresseeAgentId`. > - When an agent creates a card for another agent, Paperclip wakes the addressee with the `interaction_pending` reason. The issue still belongs to the asker. > - The addressee's wake prompt says "Use this wake to continue the task". The task markdown ends with "Use this task context as the current assignment." > - The addressee follows the normal heartbeat procedure and checks the issue out. The checkout returns `409` because the asker owns the issue. The addressee stops, the card stays pending, and the asker waits. > - This pull request gives the addressee a correct instruction: answer the named card through its answer route, and do not check out, change status or continue the task. > - The benefit is that agent-to-agent questions get answers. This matters as soon as the run-dispatch fixes for the cancelled addressee wake (#15991, #16914, #17643) land. ## Linked Issues or Issue Description Fixes #16563 Refs #17643, #15991, #16914 (run-dispatch fixes that stop the addressee wake from being cancelled; this pull request fixes the instruction that the wake then gets). Refs #16409, #11932, #13518. ## What Changed - `buildPaperclipWakePayload` adds an `addressedInteraction` block when all of these are true: the wake reason is `interaction_pending`; the interaction is pending, in the same company and issue, and addressed to the woken agent; and the woken agent does not own the issue. The block holds the interaction id, kind, a prompt excerpt (1,000 characters maximum), the read path and the answer paths for the kind (`respond`, `accept`/`reject` or `verdicts`). The server reads the interaction from the database; it does not trust the run snapshot. - `renderPaperclipWakePrompt` renders a "Question addressed to you" section for that block, on fresh and resumed sessions. The section names the card and its answer route, and forbids checkout, status changes, progress comments and task work. The generic "continue the task" line changes to "answer the question card addressed to you". - The prompt renderer accepts the block only when every answer path is an interaction path of the same issue and card. Other values are ignored. - For that wake, `buildPaperclipTaskMarkdown` opens with an "Addressed question directive", keeps the issue, description and plan as reference only, and omits every owner-work directive (task question guidance, clarification, quality review, title, chat, ask, planning and skill test mode, accepted and rejected plan). It ends with "This task belongs to another agent. Use this context only to answer the question card ... addressed to you; it is not your assignment." for that wake, in place of "Use this task context as the current assignment." - Other wakes do not change. The owner of the issue, a resolved card, a card addressed to another agent and a card with no addressee all get the existing prompt. ## Verification - New PostgreSQL integration test `server/src/__tests__/heartbeat-addressed-interaction-wake.test.ts` (7 tests). It covers a pending question to a non-owner, a confirmation card (accept and reject paths), the wake payload, and the cases that must add nothing: an answered card, a card addressed to another agent, a card with no addressee, an addressee that owns the issue, another wake reason and another company. - New tests in `packages/adapter-utils/src/server-utils.test.ts` (fresh and resumed prompts, the ordinary prompt, and tampered answer paths) and in `server/src/services/heartbeat/task-markdown.test.ts` (the addressee gets no owner-work directive in planning, accepted plan, rejected plan, ask, skill test, chat and native-runner review combinations; the owner still does). - With the source changes removed, all new tests fail. With them, they pass. - Regression runs: `packages/adapter-utils/src/server-utils.test.ts` (139 passed); in `server/`, `heartbeat-task-context`, `run-preparation`, `run-preparation.review-path`, `task-markdown`, `heartbeat-context-summary`, `heartbeat-agent-session-message`, `heartbeat-reviewed-chat-binding.integration`, `agent-conversations`, `native-runtime/current-wake-comments` and the new integration test (10 files, 173 passed). - Typecheck: `packages/adapter-utils` has no errors. In `server/`, `tsc --noEmit` reports the same 250 errors as unchanged `master` in my local environment, from workspace packages that I could not build locally (`@paperclipai/paperclip-runner`). None is in a changed file. CI runs the full typecheck. - To check by hand: assign an issue to agent A. As A, create an `ask_user_questions` interaction with `addresseeAgentId` set to agent B. With a run-dispatch fix from the issues above applied, read B's rendered prompt. It names the card and the `respond` route and does not tell B to continue the task. ## Risks - Low risk. The change adds one database read per `interaction_pending` wake, by primary key, and it is limited to the company and issue of the wake. - Without a run-dispatch fix, the addressee wake is still cancelled before it runs, so this change has no visible effect until one of #15991, #16914 or #17643 lands. The two changes do not touch the same code. - An adapter that builds its own prompt without `renderPaperclipWakePrompt` does not get the new section. The payload carries the block for those adapters. > 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`), through the OpenCode agent harness with tool use and code execution. The model wrote the change, the tests and this description. The account owner requested the change and reviewed the result. ## 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 (no documentation describes this prompt text) - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green (53 passed; the external Snyk status has not reported) - [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: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com>