mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-16 11:48:15 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - People talk to their agents in chat, and the chat directive tells the agent how to write replies > - #21081 added a rule that keeps raw IDs and internal codes out of replies. It names only tasks, cases, approvals and people as records to cite > - After #21081, agents stopped saying "revision 4" and stopped linking runs. In a full chat cohort, "revision N" mentions fell from 21 to 11, and run links fell from 9 to 5 > - A person needs the revision number that Paperclip shows and a link to the run that failed. The intended effect held: UUIDs in prose fell from 24 to 7 > - Separately, an agent that started a routine on a person's chat request sent `source: "api"`, so the run was not recorded as a manual run > - This pull request extends the same rule to name document revisions by number and to link runs, and records every agent-started run on the run-now route as manual > - The benefit is replies that point to the records the person can open, and truthful run sources ## Linked Issues or Issue Description Refs #21081 **What happened?** After #21081, a restore reply said "the version before the last edit" and did not name the new revision. A failed-run reply did not link the failed run. In a different case, the agent called `POST /api/routines/{id}/run` with `source: "api"` after two 400 responses. The run was recorded with source `api`, although a person asked for it in chat. **Expected behavior** The reply names the revision as Paperclip shows it ("revision 4") and links a run it discusses. A run that an agent starts on this route is a manual run. **Steps to reproduce** Run the chat-features OpenCode cases `documents-artifacts.restore-document`, `runs-adapters.inspect-failed-run` and `routines.run-now` on master9e910ff9ae, and read the replies and the routine run source. **Paperclip version or commit** `master` at9e910ff9ae. **Agent adapter(s) involved** Not adapter-specific. Seen with the Paperclip runner and OpenCode (`openrouter/deepseek/deepseek-v4.1-flash-1017`). **Deployment mode** The CI chat-eval runner (local server, embedded database). ## What Changed - `AGENT_CHAT_DIRECTIVE` (`server/src/services/agent-conversations.ts`): the "Write replies for the person" paragraph now also says to name a document revision by its number (such as revision 4), and to link a run it discusses, such as `[the failed run](/<prefix>/agents/<agentId>/runs/<runId>)`. The ban on raw IDs in prose does not change. - `POST /api/routines/:id/run` (`server/src/routes/routines.ts`): for an agent actor, the server ignores the `source` value in the body and records `manual`. Board callers keep their `source` value. - `routines.ts` service: for an agent manual run with an `idempotencyKey`, the replay lookup also returns that same agent's earlier `api` receipt (matched by its `routine.run_triggered` activity). A retry across the upgrade does not start the work twice. A board receipt is not matched. - `docs/api/routines.md`: documents the agent rule for the run-now source. ## Verification - Red/green: `server/src/__tests__/agent-conversations.test.ts` asserts the revision-number and run-link sentences and that the raw-ID ban stays. It failed before the directive change. - Red/green: `server/src/__tests__/routines-routes.test.ts` sends `source: "api"` as an agent and expects `manual`; a board caller keeps `api`. It failed with `source: "api"` before the route change. - Red/green: `server/src/__tests__/routines-service.test.ts` checks that a board `api` receipt with the same key does not satisfy an agent's manual request, and that the agent's own earlier `api` receipt is returned. - `server/src/__tests__/routines-e2e.test.ts` (agent routine-to-routine provenance) still passes. - `pnpm --filter @paperclipai/server typecheck` passes. - Paid OpenCode run on the five affected cases (with the companion eval PR): see the comment below. ## Risks - Low risk. The directive grows by two sentences. A model can still omit a revision number or a run link. - An agent can no longer record a run-now call as `api`. The documented contract for this route is a manual run, and provenance uses the caller run, not the source. > 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 - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used in Claude Code with tool use and code execution. ## 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 - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>