mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
1cd359408dc08aa668723bba5ddd20f67b37df3e
9012
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1cd359408d |
fix(chat): keep a turn's progress messages apart in the conversation view (#20818)
# Branch Nevysha:fix/task-chat-progress-message-breaks → paperclipai:master # Body ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The task chat shows an agent's live run, including the short progress messages that the agent writes between tool calls > - The paperclip runner streams a whole provider turn under one assistant item, so all progress messages in a turn have the same `itemId` > - For a run that started before the page opened, the task page loads the conversation event view (#17593). This view returns only the text deltas, without the tool calls that normally separate the messages > - The transcript adapter joins consecutive deltas with the same `itemId`, so the whole turn becomes one block with no space between sentences > - This pull request starts a new paragraph when a delta comes from a different provider message than the delta just before it > - The benefit is that the live task chat stays readable for runs that started before the page opened ## Linked Issues or Issue Description Fixes #20812 Refs #17593 ## What Changed - `nativeRunEventsToTranscript()` reads the provider message id of each assistant delta (`providerItemId`, at the top level or in `update`). - When a delta continues the same item directly after the previous assistant delta, but comes from a different provider message, the delta text starts with a paragraph break (`\n\n`). - The change does not apply when another entry (for example a tool call) is between the two deltas. The adapter already shows those messages as separate rows. - The change does not apply when the delta has no provider message id. Those deltas join as before. - Added three tests to `native-run-events.test.ts`: the conversation-only case, the case with a tool call between the messages, and deltas without a provider message id. ## Verification - `cd ui && npx vitest run src/components/transcript/native-run-events.test.ts`: 86 tests pass. The new conversation-only test fails without the fix. - `cd ui && npx vitest run src/components/transcript/ src/components/task-chat/ src/lib/issue-chat-messages.test.ts src/components/TaskChatThread`: 76 files, 1618 tests pass, 1 skipped. - `cd ui && pnpm typecheck` passes. - I ran the projection on the events of a real run (paperclip_runner with Claude Code, about 35 progress messages in one turn): - Conversation view: before the fix, 1 message with no breaks. After the fix, 1 message with the progress messages as separate paragraphs. - Full event list: 36 message rows before and after the fix. No row starts with a line break. - I did not run the full `pnpm -r typecheck`, `pnpm test:run` and `pnpm build`. The CI gates run them. ## Risks - Low risk. The change applies only to assistant deltas that continue the same item and come from a different provider message. - The first delta of each new message now starts with `\n\n`. Markdown shows this as a new paragraph. `flattenSelfTalk()` changes it to one space. - Runners and adapters that do not send a provider message id keep the current behavior. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`, Anthropic), in Claude Code with tool use (shell commands, file reads and edits). It found the cause, wrote the change and the tests, and ran the checks. A human reviewed 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 (no documentation change is necessary) - [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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
65614fa87e |
fix(issues): tell a reviewer to decide again when a reply to it is queued (#20745)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Execution policies route an issue through review and approval
stages, and agents can be stage participants
> - The issue update route refuses an agent handoff to review while a
human reply to that agent is still queued
(`interaction_response_queued`)
> - The refusal protects the reply: if the issue gets a new assignee
first, the dispatcher cancels the queued continuation with
`issue_assignee_changed` and the reply is never delivered
> - A reviewer agent that approves an intermediate stage also hits this
refusal, because the policy moves the issue to the next participant and
keeps it `in_review`
> - The error tells the reviewer to "keep the current assignee". The
reviewer did not choose the assignee, and the error does not say that
the decision was dropped
> - This pull request keeps the refusal and gives stage decisions a
message the reviewer can act on: the decision was not saved, read the
reply in the next run, then decide again
## Linked Issues or Issue Description
No issue exists for this bug. I searched issues and PRs for
`interaction_response_queued`, "queued response stage approval", "review
stage approve 409 queued" and "queued interaction response handoff".
- Refs #19376. That closed PR changed which queued receipts count as
delivered. It did not change this check.
- Refs #20264. That open PR reworks stage decisions into explicit
operations. Its description does not mention this check. If it lands
first, this change needs a rebase onto its decision path.
**What happened?**
A two-stage policy has a review stage (agent A) and an approval stage
(agent B). Agent A is the active reviewer and the assignee. A human
reply to agent A is queued, for example an answer to a question that
agent A asked. Agent A sends `PATCH /api/issues/:id` with `status:
"done"` and an approval comment. The policy turns this into an approval
of the review stage, which would set `status: "in_review"` and assign
agent B. The route returns 409 `interaction_response_queued`: "Keep the
current assignee so the queued response can continue after this run".
The update, the decision row and the comment are not saved, and the
message does not say so.
**Expected behavior**
The reply still reaches agent A, so the refusal stays. The error tells
agent A that the decision was not saved and that it should read the
reply in its next run and submit the decision again.
I first tried to let the decision through. That loses the reply: the
queued continuation for agent A is a resolved-interaction continuation,
and `decideQueuedRunStaleness` cancels it with `issue_assignee_changed`
once agent B is the assignee
(`server/src/modules/run-dispatch/domain/policy.ts:538-556`). The human
input would also not inform the decision. So this change keeps the
refusal.
**Steps to reproduce**
1. Configure an execution policy with a review stage (agent A) and an
approval stage (agent B).
2. Move the issue into the review stage with agent A as the current
participant and assignee.
3. Queue a resolved interaction response for agent A on the issue.
4. As agent A, send `PATCH /api/issues/:id` with `{ "status": "done",
"comment": "Approved." }`.
5. The response is 409 with the generic "keep the current assignee"
message.
**Paperclip version or commit**
`master` at
|
||
|
|
7bd424d50f |
fix(issues): preserve PATCH result when unblock wake fails (#20425)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The issue API commits status changes before it sends some follow-up notifications. > - A blocked transition can therefore commit before the control plane wakes the named unblock owner. > - A wake failure currently escapes the route and changes the HTTP response to 500. > - The client then sees a failure even though the issue is already blocked. > - This pull request contains failures from that post-commit notification path. > - The benefit is an HTTP result that stays consistent with the committed issue update. ## Linked Issues or Issue Description Refs #3824 Related pull request: #19209 The related pull request maps a routine-slot constraint to HTTP 409. This change covers a different boundary. The target issue update has already committed when the unblock notification starts. The route must not replace that successful result with a notification error. ## What Changed - Catch wake and delivery-marker failures in the unblock notification helper. - Log the post-commit notification failure at the route boundary. - Persist `blockedOwnerNotifiedAt` only after the wake succeeds. - Keep the marker empty when delivery fails so a later attempt can use the same idempotency key. - Add regression tests for wake failures and marker failures. ## Verification - Before the service change, the two new failure tests rejected with their injected errors. - `HOST=127.0.0.1 node_modules/.bin/vitest run server/src/__tests__/routable-blocked.test.ts` passes 5 tests. - `HOST=127.0.0.1 node_modules/.bin/vitest run server/src/__tests__/routable-blocked.test.ts server/src/__tests__/issue-agent-mutation-ownership-routes.test.ts` passes 233 tests. This includes HTTP PATCH regressions for wake and marker-write failures. - `pnpm --filter @paperclipai/plugin-sdk build` passes. - `git diff --check` passes. ## Risks - Risk is low. This change does not add a migration or change the issue transaction. - A failed notification no longer changes the PATCH result. The route emits a warning with the issue and owner context. - A failed notification keeps `blockedOwnerNotifiedAt` empty. The existing idempotency key limits duplicate wake delivery during a later attempt. > This is a focused bug fix. It does not duplicate planned roadmap work. ## Model Used - OpenAI Codex with GPT-5, extended reasoning, tool use, and code execution. The context window size was not exposed to the agent. ## 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 - [ ] I have updated relevant documentation to reflect my changes (no documentation change is needed for this internal error path) - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green (59 checks on `21ad144`: 56 success, 3 skipped, 0 failures; `ci / verify`, `ci / e2e`, and `review` passed) - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups (`Greptile Review` success on `21ad144`; 0 open review threads) - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Builder <builder@nublo.net> Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
cfabfc8ff4 |
fix(adapters): bound external adapter loading at startup (#20131)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - External adapters are npm packages that the server imports at
startup through `buildExternalAdapters` in the plugin loader
> - Startup recovery waits for the full external adapter load pass
before the server reports healthy
> - If the import of one package never settles, for example because of a
top-level `await` that never resolves, the pass never returns
> - Then startup recovery stays in the `recovering` phase for the life
of the process, and `/health` keeps reporting `starting`
> - This pull request gives each package a wall-clock load budget and
skips a package that goes over it
> - The benefit is that one broken adapter package cannot keep the whole
server from becoming healthy
## Linked Issues or Issue Description
No issue exists.
**What happened?**
After installing an external adapter package whose import never settled,
the server stayed in `starting` on `/health` and never finished startup
recovery.
**What did you expect?**
The server skips the package with a warning and finishes startup.
**Steps to reproduce**
1. Install an external adapter package whose entry module has a
top-level `await new Promise(() => {})`.
2. Start the server.
3. `/health` keeps reporting `starting`.
**Paperclip version**
`master` at the time of this PR.
## What Changed
- `server/src/adapters/plugin-loader.ts`:
- `DEFAULT_EXTERNAL_ADAPTER_LOAD_TIMEOUT_MS` (10 s) and an
`ExternalAdapterLoadTimeoutError`.
- `loadFromRecord` races the package import against the budget. A
package that goes over the budget is skipped with a warning, and the
pass continues with the next package.
- A late failure of a skipped import is consumed, so it does not become
an unhandled rejection.
- A skipped import that finishes later does not write its UI parser to
the cache, so it cannot replace a parser that was loaded or reloaded in
the meantime.
- `buildExternalAdapters` takes an optional `{ timeoutMs }`. The
cloud-managed early return does not change.
- `server/src/__tests__/external-adapter-load-timeout.test.ts`: a
healthy package still loads, the pass returns when a package import
never resolves, and an import that finishes after the budget leaves no
UI parser in the cache.
## Verification
- `cd server && npx vitest run
src/__tests__/external-adapter-load-timeout.test.ts
src/__tests__/plugin-loader-error-retry.test.ts`: passes.
- `pnpm --filter @paperclipai/server typecheck`: passes.
## Risks
- A package that needs more than 10 s to import is now skipped at
startup. That is very slow for an import; a caller can pass a larger
`timeoutMs`.
- The import that went over the budget keeps running in the background,
because a dynamic import cannot be cancelled. Its result, including its
UI parser, is ignored.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, git, test runs). Extended reasoning on.
## 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>
|
||
|
|
f7c1bf1797 |
fix(issues): reject a monitor sent with a status that forbids it (#20124)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - An issue can have a monitor in its execution policy, and only some statuses allow a monitor > - `PATCH /api/issues/:id` checks this through `monitorExplicitlyUpdated`: when the body explicitly sets a monitor and the new status does not allow one, the route returns 422 > - The route counted the monitor as explicit only when it differed from the stored monitor > - A body with a status change and the same monitor as stored was accepted, and the transition dropped the monitor without an error > - This pull request counts a monitor that is present in the body as an explicit monitor update, also when the value did not change > - The benefit is that the client gets a 422 instead of losing the monitor without notice ## Linked Issues or Issue Description No issue exists. Related, but a different case: #12149 (monitors on provider-quota holds). **What happened?** A PATCH with `status: "todo"` and an `executionPolicy.monitor` equal to the stored monitor returned 200, and the issue lost its monitor. **What did you expect?** A 422 with "Monitor can only be scheduled ...", as for a monitor that differs from the stored one. **Steps to reproduce** 1. Create an issue in `in_review` with a monitor in its execution policy. 2. Send `PATCH /api/issues/:id` with `status: "todo"` and the same monitor in `executionPolicy`. 3. The response is 200 and the monitor is gone. **Paperclip version** `master` at the time of this PR. ## What Changed - `server/src/routes/issues.ts`: a new `monitorPresentInBody` is true when the body has an `executionPolicy` whose normalized form has a monitor. `monitorExplicitlyUpdated` is now `monitorPresentInBody || monitorChanged`. - `server/src/__tests__/issue-execution-policy-routes.test.ts`: a new test sends a status change with an unchanged monitor and expects a 422 and no update. ## Verification - `cd server && npx vitest run src/__tests__/issue-execution-policy-routes.test.ts`: passes, including the new test. - `pnpm --filter @paperclipai/server typecheck`: passes. ## Risks - A client that sends the full execution policy with a status change to a status that does not allow a monitor now gets a 422 where it got a 200 before. In that case the monitor was dropped before, so the 422 shows a real conflict. The client can remove the monitor from the body or send a status that allows it. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, git, test runs). Extended reasoning on. ## 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> |
||
|
|
f5ed369805 |
fix(issues): give a reason when a route cancels a run (#20123)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Issue routes can cancel a heartbeat run as a side effect, for
example when a comment supersedes a scheduled retry or when the issue is
set to `cancelled`
> - Other cancel paths pass a reason, an error code and a run event to
`heartbeat.cancelRun`
> - These two route paths called `cancelRun` without a reason, so the
run showed `cancelled` with no error code and no run event that says why
> - An operator who looks at the run, or a recovery path that reads the
error code, cannot tell these cancels apart from other cancels
> - This pull request passes a reason, an error code, an event message
and the issue id to both calls
> - The benefit is that every route-driven cancel explains itself in the
run record and the run events
## Linked Issues or Issue Description
No issue exists.
**What happened?**
A run that was cancelled because a comment superseded its scheduled
retry, or because its issue was set to `cancelled`, had no `error`, no
`errorCode` and no run event with a cancel reason.
**What did you expect?**
The run record and the run events say why the run was cancelled, like
other cancel paths do.
**Steps to reproduce**
1. Let a run fail so that it gets a scheduled retry (`scheduled_retry`).
2. Post a comment on the issue before the retry starts.
3. Open the cancelled retry run. It has no error code and no event that
explains the cancel.
4. Do the same with a running issue that you set to `cancelled`.
**Paperclip version**
`master` at the time of this PR.
## What Changed
- `server/src/routes/issues.ts`:
- The scheduled-retry cancel passes `"Cancelled because a comment
superseded the scheduled retry"`, `errorCode:
"scheduled_retry_superseded"`, an event message and `eventPayload: {
issueId }`. The `expectedStatus: "scheduled_retry"` guard does not
change.
- The cancel on a status change to `cancelled` passes `"Cancelled
because the issue was set to cancelled"`, `errorCode:
"issue_cancelled"`, an event message and `eventPayload: { issueId }`.
- `server/src/__tests__/issue-comment-reopen-routes.test.ts`: six
expectations now check the reason, the error code, the event message and
the event payload.
## Verification
- `cd server && npx vitest run
src/__tests__/issue-comment-reopen-routes.test.ts`: passes.
- `pnpm --filter @paperclipai/server typecheck`: passes.
## Risks
- Low risk. Only the arguments of two existing `cancelRun` calls change.
The cancel decision, the expected status guard and the activity log
entries do not change.
- The two error codes are new values. Code that matches on known cancel
error codes sees them as unknown codes, as before when the code was
empty.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, git, test runs). Extended reasoning on.
## 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>
|
||
|
|
a2abe16e50 |
docs(skills): fix typos in fix-slow-queries skill (#20093)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents use skills in `.agents/skills/` as working instructions > - The `fix-slow-queries` skill has three spelling and grammar errors on lines 175 to 177 > - Errors in instructions make the text harder to read for people and agents > - This pull request corrects the three errors > - The benefit is clearer instructions with no change to their meaning ## Linked Issues or Issue Description **Issue type** Typo or grammar error. **Where is the issue?** `.agents/skills/fix-slow-queries/SKILL.md`, lines 175 to 177. **What's wrong?** Line 175 has "non starter". Line 176 has "dont'". Line 177 has "a sense on the time". **Suggested fix** Change them to "non-starter", "don't" and "a sense of the time". ## What Changed - Corrected three spelling and grammar errors in `.agents/skills/fix-slow-queries/SKILL.md`. ## Verification - Read lines 175 to 177. Each sentence has the same meaning as before. - This change touches one Markdown file only. No code changes. ## Risks - Low risk. Text-only change to one Markdown file. ## Model Used - Claude (Anthropic), model ID `claude-opus-5-5`, with tool use. The model found the errors with a spell-check scan and suggested the fixes. A human made and reviewed the edit. ## 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 - [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 |
||
|
|
5fb030f59f |
fix(heartbeat): keep the newest comments when a wake window is cut (#19969)
Fixes #19198 ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A heartbeat builds a wake payload so the agent can read the latest issue comments > - The inline window holds at most 8 comments and 12000 characters of comment text > - The builder walked comments from the oldest and stopped when a cap was reached > - The newest comment, which the prompt asks the agent to acknowledge, was left out > - This pull request keeps the newest comments that fit and names the older ones that were cut > - The benefit is that a busy agent answers the comment that woke it ## Linked Issues or Issue Description Fixes: #19198 No open pull request mentions this issue. ## What Changed - `buildPaperclipWakePayload` fills the inline comment window from the newest comment back. The caps stay the same: 8 comments, 4000 characters per body, and 12000 characters in total. The kept comments still render oldest first. - The payload records `commentWindow.cutCount`, `cutCommentIds` (at most 20, oldest first), and `cutAttachmentCount`. - Attachments keep the newest 20. When nothing is cut, their order stays oldest first. A count query runs only when more than 20 attachments match. - The wake prompt prints one `cut comments` line, and one `cut attachments` line when needed, after `latest comment id`. A wake that cuts nothing renders the same prompt as before. - A generic wake still tells the agent to read the cut comments with `GET /api/issues/<id>/comments`. A native external-chat turn that already requires `read_current_wake_comments` and zero other Paperclip API calls names that reader in the cut line instead. That reader pages every comment id accepted for the run. The full-thread GET stays out of that prompt. - The redaction test that checks an exact comment window now expects the new fields at zero when nothing is cut. ## Verification Run this command in `server`: `pnpm exec vitest run src/services/heartbeat/run-preparation.wake-window.test.ts --testTimeout 60000` Before this change, all 7 tests failed. An 11-comment wake listed comments 1–8 and omitted comment 11. Five comments of 4000 characters kept the first three and dropped the two newest. After this change, all 7 tests pass. The seventh checks that a native external-chat cut names `read_current_wake_comments` and does not name a `GET`, while the same payload without the native reader still names the thread `GET`. The test fixture now derives its row type from the builder input and uses the schema-valid `comment` origin. Attachment assertions validate the array shape before reading ids. `pnpm exec tsc --noEmit -p .` in `server` reports no errors in the new test file or the changed source files. ## Risks A wake that already fits in the caps keeps the same prompt text. A wake that used to cut now shows the newest comments instead of the oldest ones. The cut line names the omitted comment ids. A generic wake tells the agent to read `GET /api/issues/<id>/comments`. A native external-chat wake tells the agent to read those same ids with `read_current_wake_comments`. An attachment list longer than 20 now keeps the newest 20 instead of the oldest 20. ## Model Used xAI Grok 4.7, with tool use, prepared the original change and test evidence. OpenAI GPT-6 (Codex), with repository and shell tools, corrected the test fixture types. Context window size was not exposed to the agent. ## 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 `#<number>` / `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 - [ ] 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 - [ ] I will address all Greptile and reviewer comments before requesting merge This change was prepared with the assistance of an AI coding agent. |
||
|
|
f78519ebb8 |
Clarify unavailable run context for issue writes (#19788)
## Thinking Path > - Paperclip manages AI agents and their work. > - The issue API attributes agent writes to a heartbeat run. > - A valid run with no source issue and an unavailable run are different denial cases. > - The old response used one code and could tell an agent to resend a header that was already present. > - This pull request gives an unavailable or mismatched run its own denial code. > - The response tells the agent to inspect the run and stop affected writes. > - The benefit is a clear audit boundary and a useful recovery instruction. ## Linked Issues or Issue Description Refs #18450. Related PRs #18743 and #18275 address run context copy and checkout binding. **What happened?** An agent issue write with a supplied run ID can fail when the run row is absent, in another company, or owned by another agent. The API returned the same denial as a run without a source issue. The response could tell the agent to resend a header it already sent. **Expected behavior** The API returns a distinct 403 denial for an unavailable or mismatched run. The response tells the agent to check the run lookup, stop affected writes, and report the result. A run with no source issue keeps its separate denial. **Steps to reproduce** 1. Send an agent issue write with a run ID that has no matching run row for that agent and company. 2. Observe the denial code and response text before and after this change. 3. Send a write from a registered run with no source issue and confirm that it keeps the separate run-context-required code. **Paperclip version or commit** Base behavior: `a708a133363a73bd6ad0491cf38dbddfd54c180e`. This PR is based on a newer `master` commit with unchanged base blobs in the four affected files. **Deployment mode** Agent issue writes in local and self-hosted deployments. No live installation was tested. ## What Changed - Add `issue_write_run_context_unavailable` to the shared denial contract. - Return that code when the supplied run is absent, belongs to another company, or belongs to another agent. - Clarify the separate denial text for a run that has no source issue. - Add focused shared and server regression tests. ## Verification - The reviewed four-file patch has SHA256 `d90722aef44d211d57a728e40d435ea4d2b5b15fa9271d9aceab6f254a18e4c7` as a binary Git diff against its original base. - Each changed blob in this PR matches the reviewed local commit byte for byte. The newer base has the same four pre-change blobs. - `pnpm --filter @paperclipai/shared exec vitest run src/issue-write-denial.test.ts` passed locally. - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/cross-issue-influence-limit.test.ts` passed locally. - `pnpm --filter @paperclipai/shared typecheck` passed locally. - `git diff --check` passed. Node 22.23.1 emitted an engine warning because the repository requests Node 24.11.0 or newer. - Full CI and Greptile review are pending. No live runtime verification was performed. ## Risks - Clients that branch on denial codes will see a new code for unavailable or mismatched runs. - The status remains 403. This change does not grant issue write scope or alter the cross-issue limit. - A run lookup may return 403 or 404 for reasons other than missing registration. The response does not treat that result as proof that the run is absent. - Rollback: revert this commit. No database migration or configuration change is required. ## Model Used - OpenAI GPT-6 Codex assisted with source acceptance and PR preparation. The exact serving model ID and context window were not exposed in this run. Reasoning, shell, and GitHub tools were used. - The reviewed source candidate was AI assisted. Its original model ID was not recorded with the review evidence. ## 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 --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
eb7546d913 |
fix(wake-queue): do not queue a second run for a new assignee that already has one (#19437)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The wake queue lets one run hold a task, and other wakes for the
task wait as `deferred_issue_execution`
> - #19354 lets the release of a run that was stopped for a reassignment
promote the new assignee's waiting wake
> - Before the drain, the release looks for a live successor run, but
only for the stopped run's agent
> - The new assignee can already have a queued run for the task, because
enqueue sets `executionRunId` only at dispatch
> - Then the release promotes another wake and queues a second run for
the same agent and task
> - This pull request adds the new assignee to that successor check,
only for a handoff release
> - The benefit is that a reassigned task gets one run for its new
owner, not two
## Linked Issues or Issue Description
Follow-up to #19354. Supersedes the duplicate-run part of #19032.
- Greptile found this case on #19032 (P1, "New owner gets duplicate
runs"). #19354 merged a general version of the #19032 handoff, so #19032
is closed as superseded. This pull request keeps only the duplicate-run
fix, on the `handoffAssigneeAgentId` path from #19354.
- #16019 also changes this successor check, for a stale queued run of
the releasing agent. The two changes touch the same query. #16019 checks
ownership for the releasing agent, so with this change it must check the
agent of each queued run. Otherwise the new assignee's queued run stops
counting, and the new `queued` test case fails. I will rebase after
whichever merges first.
**What happened?**
Agent A runs a task, and agent B has a deferred mention wake for it. The
task is reassigned to B. A's run is already `cancelled` by the Stop, but
its release has not run yet. So the assignment wake for B finds no live
lock holder and queues a run for B. It does not adopt the mention wake.
If B is busy, the run stays queued, and `executionRunId` stays empty.
Then the release of A's run takes the #19354 handoff path. The successor
check looks only for runs of A, so the drain promotes B's mention wake
into a second run. Both runs can do the same work.
**Expected behavior**
When the new assignee already has a `queued`, `running` or
`scheduled_retry` run for the task, the release promotes nothing. The
deferred wake stays for that run. This is the same rule that the release
already uses for a successor of the stopped agent.
**Steps to reproduce**
1. Seed a native run of agent A that holds the task lock, cancelled with
an acknowledged reassignment Stop (`reassignmentStopRequested`).
2. Assign the task to agent B. Seed a queued run of B for the task and a
deferred `issue_comment_mentioned` wake of B.
3. Release A's run.
4. The release returns `promoted` and queues a second run for B.
The new embedded-PostgreSQL test does these steps.
**Paperclip version or commit**
master
|
||
|
|
1afac2fd30 |
fix(recovery): do not abort startup recovery on one bad blocking pair (#19193)
<!-- Write all pull request text in Simplified Technical English (ASD-STE100): short sentences, one instruction per sentence, simple approved vocabulary, and the active voice. --> ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - At startup, the recovery service reconciles the active recovery actions > - When a source issue has healthy child issues, recovery adds the children to the blocked-by list of the source issue > - If a child already blocks its source issue, this creates a cycle and `issuesSvc.update` throws an error > - The error stops the whole sweep, so recovery does not reach any later issue > - This pull request catches the error for one source issue, logs a warning, and goes on with the next action > - The benefit is that one bad pair of issues no longer stops startup recovery for all other issues ## Linked Issues or Issue Description Refs #11853 **What happened?** During startup recovery, one bad pair of a source issue and a child blocker created a cycle. The update threw an error. The error stopped the recovery sweep for all remaining issues. **What did you expect to happen?** One bad pair must not stop startup recovery for every issue. The sweep must skip the bad pair and continue. ## What Changed - `reconcileActiveRecoveryActions` wraps the `issuesSvc.update` call that blocks a source issue on its healthy children in a `try`/`catch`. - On failure, it logs a warning and counts the action as skipped. It also reports a retry time 5 minutes later, through `blockerStallRetryAt`, so the recovery worker schedules another pass. The sweep continues with the next action. - A new test seeds two source issues with a healthy child each. The first source issue also blocks its own child, so blocking it on that child creates a cycle. The test checks that the first action stays active, is counted as skipped, and sets a retry time. It also checks that the second source issue becomes blocked and its action resolves. ## Verification - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/startup-recovery-update-failure.test.ts` (embedded PostgreSQL, 2 tests pass). - `pnpm --filter @paperclipai/server typecheck` passes. ## Risks - The `catch` handles any error from `issuesSvc.update`. If the cause is a real data or permission problem, the action is skipped and the warning log is the only signal. - A skipped action stays active. The retry time makes the worker try it again after 5 minutes. If the cycle still exists, the warning repeats every 5 minutes. > 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 - Provider and model: Anthropic Claude Opus 5.5 (model ID `claude-opus-5-5`) - Context window: 1M tokens (128K maximum output) - Capabilities: adaptive thinking, tool use, and code execution, used through Claude Code ## 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 - [ ] 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 mergecanary/v2026.1205.0-canary.900200 |
||
|
|
fdbd586130 |
fix(hermes): keep inline diff gutter lines out of the run result (#18947)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The `hermes_local` adapter runs the Hermes CLI and reads its stdout > - The adapter uses the stdout before `session_id:` as the run result. Paperclip posts this result as an auto-comment when the agent does not post its own comment. > - The Hermes gateway client prints the inline diff of each edit behind a `│` gutter. It does this also in quiet mode (`-Q`) and with `display.inline_diffs: false`. > - `cleanResponse()` does not remove these lines. The run summary and the auto-comment then contain only code diffs, cut at 2,000 characters. > - The live issue chat uses `parseHermesStdoutLine()`. This parser shows the same lines as assistant text, so the agent appears to "speak" diffs. > - This pull request removes the gutter lines from the result and classifies them as stdout in both UI parsers (TypeScript and `ui-parser.cjs`). > - The benefit is that auto-comments and the issue chat show what the agent wrote, not raw diffs. ## Linked Issues or Issue Description No issue exists. I searched open and closed issues and PRs for "hermes diff", "hermes cleanResponse" and Hermes adapter PRs. I found no duplicate. **What happened?** An agent on `hermes_local` ran through the Hermes gateway client. When a run ended without an agent comment (timeout or interrupted run), Paperclip posted an auto-comment (`authorizationReason: internal_agent_write`). The comment contained only diff lines such as `│ apps/web/... │`, `│ @@ -1,2 +1,3 @@`, `│ +...`. The live issue chat showed the same lines as assistant messages. **Expected behavior** The auto-comment contains the agent's final text only. The issue chat shows diff lines as tool output, not as assistant speech. **Steps to reproduce** 1. Configure an agent with `hermes_local` and a Hermes setup that uses the gateway client. 2. Give the agent a task that edits files. 3. Let the run end without an agent comment (for example, a timeout). 4. Look at the auto-comment and at the live issue chat during the run. **Agent adapter(s) involved** Hermes ## What Changed - `packages/adapters/hermes/src/server/execute.ts`: `cleanResponse()` removes lines that start with `│` after ANSI codes are removed. - `packages/adapters/hermes/src/ui/parse-stdout.ts`: `parseHermesStdoutLine()` returns `stdout` for lines that start with `│`. Before, they became `assistant`. - `packages/adapters/hermes/ui-parser.cjs`: the same rule for the CJS parser. Externally installed adapters load this file. - New test `src/ui/ui-parser-cjs.test.ts`: tests the exported `parseStdoutLine` from `ui-parser.cjs`. - New test `src/server/execute.response.test.ts`: runs `execute()` with Hermes stdout that has gutter diff lines. It checks `summary` and `resultJson.result`. - New tests in `src/ui/parse-stdout.test.ts` for plain and colored gutter lines. ## Verification - `pnpm --filter @paperclipai/hermes-paperclip-adapter test`: 12 files, 180 tests pass. - `pnpm --filter @paperclipai/hermes-paperclip-adapter typecheck`: pass. - The five new parser and execute tests fail without the source change and pass with it. - Manual: I applied the same change to the built adapter on a live instance (2026.1023.0). After a restart, auto-comments from a Hermes agent contained the final text only. The issue chat stopped showing diff lines as assistant text. ## Risks - Low risk. The change affects only lines whose first visible character is `│` (U+2502). - If an agent writes a final answer line that starts with `│`, the adapter now removes that line from the result. This is unlikely in normal prose. The `┊` (U+250A) tool lines are not affected. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits, test runs). The model found the cause, wrote the change and the tests, and wrote this description. A human reviewed and approved the work. ## 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 - [ ] I have updated relevant documentation to reflect my changes (not applicable: no documented behavior 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Thomas Venturini <4708070+tjventurini@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
7612e79215 |
fix(heartbeat): tell a non-owner addressee to answer the card, not take the task (#18907)
## 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> |
||
|
|
960ed4b3ae |
docs: document multiple Hermes profiles via /p/<profile> base URLs (#18732)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The subsystem is the Hermes gateway adapter onboarding doc (`doc/HERMES_GATEWAY_ONBOARDING.md`) > - The doc does not mention Hermes profiles at all > - Users who run one Hermes profile per role (coder, reviewer, researcher) cannot see that one Paperclip agent per profile is possible > - This pull request adds a "Multiple Hermes Profiles" section to the onboarding doc > - It documents the `/p/<profile>` base-URL route, the shared-listener auth rule, and the dashboard-port gotcha > - The benefit is that users can wire one Paperclip agent per Hermes profile from the doc alone ## Linked Issues or Issue Description - Fixes: #18697 (docs: document routing to a specific Hermes profile via the `/p/<profile>` base URL) ## What Changed - Add a "Multiple Hermes Profiles" section to `doc/HERMES_GATEWAY_ONBOARDING.md`. - The section covers the four points from #18697: enable `gateway.multiplex_profiles`, one agent per profile with `apiBaseUrl` set to `<gateway>/p/<profile>`, the API key rule, and the port `9119` path-rewrite gotcha. - The section also documents the two routing outcomes: unknown prefix returns `404`, no prefix runs as the default profile. ## Verification - The `/p/<profile>` route contract is verified against the Hermes gateway source (`gateway/platforms/api_server.py`: the module docstring lists `GET /p/<profile>/v1/models`; `_resolve_request_profile` returns the reject sentinel for unknown profiles; the profile-prefix middleware answers `404 {"error": "Unknown or unconfigured profile"}`). - The base-URL claim is verified against `packages/adapters/hermes/src/gateway/server/execute.ts`: `apiUrl()` appends `/v1/runs...` to the configured URL and keeps its path; `normalizeBaseUrl()` rewrites the path to `/api` only when the port is the Hermes dashboard port. - One correction to #18697: the issue says each multiplexed profile has its own `API_SERVER_KEY`. The source shows one listener with one key (`self._api_key` is set once in the api_server platform init from `API_SERVER_KEY`). The profile prefix scopes the request home; it does not change the auth key. The doc text follows the source. Please correct me if a per-profile key path exists that I missed. - The issue asks for a maintainer smoke test (a full Paperclip run against a `/p/` URL) before documenting. I did not run that smoke test. The doc describes static source behavior only. If you prefer, switch the link to `Refs: #18697` and run `doc/HERMES_GATEWAY_SMOKE.md` first. - Docs-only change. No tests apply. No code paths change. ## Risks Low risk. Docs only. The new section is additive and isolated. ## Model Used - Hermes Agent (Nous Research) with mimo-v2.6-pro (Xiaomi), 2026-11-03 - Tool-assisted: `gh` CLI for API reads; local Hermes source (`/usr/local/lib/hermes-agent`) for the verification above ## 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 (open PRs scanned; none touches profile routing docs) - [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 (`docs/hermes-profiles`) - [x] I have run tests locally and they pass (docs-only; no test suite applies) - [x] I have added or updated tests where applicable (no tests apply to markdown docs) |
||
|
|
8f6cf8b0d7 |
fix(auth): ignore comment-only Codex project settings (#18559)
## Thinking Path > - Paperclip lets agents use managed AI connections. > - The server checks project files for conflicting authentication settings. > - Codex stores project settings in TOML. > - A full-line TOML comment can contain an example authentication setting. > - The current text check rejects that comment as an active override. > - This pull request excludes full comment lines in local and remote checks. > - Active overrides and file-read errors still block execution. ## Linked Issues or Issue Description **What happened?** A project or scanned ancestor `.codex/config.toml` containing only `# model_provider = "example"` can cause `ai_connection_incompatible`. The worker is rejected before provider execution. **Expected behavior** Ignore full TOML comment lines, including indented comments. Continue to reject active authentication and provider overrides. **Steps to reproduce** 1. Create a disposable project and a `.codex/config.toml` in its scanned ancestry. 2. Add `# model_provider = "example"` without an active provider override. 3. Call the managed OpenAI project-auth guard for that project. 4. The original guard rejects the comment. The new tests reproduce both local and shell-backed remote checks. **Paperclip version or commit** Originally checked against upstream `e1224783685405eb7d987ece2446962920ee0cf5`. Before publication, rebased cleanly onto `c0550e7010b5b733b745f60433788db3e6fd2e2e`. The two intervening commits do not change either fix's source or regression files. **Deployment mode** Source checkout on macOS arm64. Node 24.21.0 and pnpm 9.15.4. Disposable filesystem fixtures and a real local POSIX shell stand in for remote transport. No provider call or live remote host was used. Refs #17421. That open PR changes the scanned project boundary and probe preparation. This patch handles full-line comments inside the existing scan. The shared guard will need reconciliation if that PR lands first. A public search found no separate comment-filtering repair. ## What Changed - Exclude full comment lines before applying the existing local TOML conflict pattern. - Use a POSIX awk check for remote Codex TOML, preserving conflict and read-error exit codes. - Leave Claude JSON checking and explicit argument rejection in place. - Add 23 filesystem and shell regression cases. Cover LF/CRLF, active overrides, ancestor checks, read failures, argument rejection and Claude settings. Skip POSIX-only checks on Windows and permission-denial checks when running as root. ## Verification - Publication recheck on the rebased branch: auth filesystem/shell and Codex environment checks passed, **31 tests with one existing skip**. Full workspace build/typecheck and broader-suite results below were recorded before that rebase, at the original base. They were not rerun after the two intervening upstream changes. - Focused filesystem/shell and existing Codex environment tests: **31 passed, one existing Windows-only skip**. - Complete connection, routing and hiring test files: **263 passed**. Combined focused evidence: **294 passed and one conditional skip in five files**. ```sh pnpm exec vitest run --project @paperclipai/server server/src/__tests__/ai-connection-project-auth.test.ts server/src/__tests__/codex-local-adapter-environment.test.ts --maxWorkers=1 pnpm exec vitest run --project @paperclipai/server server/src/__tests__/ai-connections.test.ts server/src/__tests__/ai-connection-router.test.ts server/src/__tests__/agent-hire-ai-connections.test.ts --maxWorkers=1 ``` - Full workspace typecheck passed: `pnpm -r --workspace-concurrency=1 typecheck`. - Full workspace build passed: `pnpm build`. - Module-boundary, runtime Git-push guard and diff-whitespace checks passed. - Initial pre-fix regressions: 4 failed and 19 passed cases. All four failures were comment-only settings. The original failures were retained. - **Broader run:** all six chat shards and 22 of 24 general server shards executed, selecting 1,229 general files (including platform-conditional skips). Results: **27,547 passed, one failed**, plus 180 conditional skips outside chat. Completed chat evidence was reused unchanged when switching from the serial path to the standard 24-shard modes. The inventory check verified the full planned cover; this partial execution is not a complete pass. The final two general shards, five native suites, 20 workspace projects and 164 serialized suites did not run after the failure. - The failed Git-scan load case observed 126 joins instead of 498. The identical failure reproduced in the focused case on unchanged upstream at the stated base. Refs #17536 for the existing host-dependent fixture repair. No load-test assertion was changed here. - An initial incomplete dependency installation omitted the embedded PostgreSQL library symlinks. Running its existing install hook restored PostgreSQL 18.1 startup and the focused integration tests. This also cleared the earlier misleading chat-discovery failure. Original failure logs were retained. - One parallel server group left a Node child beyond 30 seconds after a successful test exit. It was stopped. The identical 59 files later passed all 1,238 cases and drained normally on unchanged upstream. The original orphan remains unattributed; a clean overall lifecycle run is not claimed. - Remote tests run a real POSIX shell locally with transport replaced. No real remote host, live provider turn or installed production service was qualified. Upstream CI, Greptile and merge readiness remain pending. ## Risks This is a limited correction to the existing text guard, not a TOML parser rewrite. It ignores only full comment lines. It does not change project scanning boundaries or credentials. Remote checks require POSIX awk and retain bounded subprocess timeouts. Windows was not exercised. PR #17421 touches the same guard and can require rebasing. ## Model Used OpenAI `gpt-6.1-sol` through Codex. Saved session metadata identifies medium reasoning for the upstream adaptation and verification. Capabilities used: source inspection, shell tools, patch editing, regression testing, and build verification. The session-reported context window is 475,000 tokens. This is the recorded model ID; no unrecorded build version or nominal model maximum is asserted. The local-tests, CI and Greptile completion boxes remain unchecked because a complete repository pass is not claimed. ## 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 - [ ] 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 Additional local test limitation: final cleanup found a detached sibling-directory HTTP fixture from `workspace-runtime.test.ts`. Its ownership was verified from its temporary-root cwd and exact fixture command; it was stopped individually. This separate observation remains outside the proposed changes. Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
ed262f2e9a |
fix(adapter-utils): protect nested clone .git directories during workspace copy-back (#18534)
## Thinking Path > - Paperclip runs agents in local, SSH and sandbox environments. > - A remote run uploads the agent workspace to the execution host. At the end the adapter copies the workspace back. > - The upload excludes Git metadata with the `.git` archive exclude list. > - The copy-back uses the same list to decide what it may delete. The list only matched the top-level `.git` directory. > - The upload left out nested clones' `.git` data. The copy-back treated that data as deleted in the sandbox. > - The copy-back then removed `repo/.git` on the host. Unpushed commits and branches were lost. > - This pull request adds the nested patterns that the heavy-directory excludes already use. > - The benefit is that a copy-back never deletes Git data that the upload left out. ## Linked Issues or Issue Description Fixes: #18299 Refs: #15959 (the same exclude list inconsistency for SSH workspaces) ## What Changed - Add `*/.git` and `*/.git/*` to `GIT_ARCHIVE_EXCLUDES`. The restore baseline exclude now matches a nested `.git` at any depth, like the tar upload already does. - Add a regression test. The test captures a baseline that contains `repo/.git` and asserts that the nested `.git` is excluded. ## Verification - `pnpm vitest run packages/adapter-utils/src/workspace-restore-merge.test.ts` -> the new test passes; 47 passed. - Before the change, the same test fails with `expected true to be false` because the baseline contained `repo/.git/config`. - `pnpm --filter @paperclipai/adapter-utils exec tsc --noEmit` -> pass. - `pnpm vitest run packages/adapter-utils/src/remote-managed-runtime.test.ts` -> 7 passed. - `git-workspace-sync.test.ts` and `sandbox-managed-runtime.test.ts` show the same environment failures with and without the change (8 and 40; local Node 23.11 `node:sqlite` `Incomplete workspace manifest`). This change adds no failure. - A live sandbox copy-back is not available locally. After merge, run one sandbox run with a nested clone in the workspace and confirm that `repo/.git` stays on the host. ## Risks - The copy-back no longer removes nested `.git` data. This is intended: the upload does not send that data to the sandbox. - The tar upload now names the nested patterns explicitly. The tar behavior does not change because the old `.git` pattern already matched at any depth. - `workspaceFileMode: "all"` keeps the old behavior; it does not use these excludes. ## Model Used - DeepSeek V4.1 Flash (model id: `deepseek-v4.1-flash`). Provider: DeepSeek. - Capabilities: extended reasoning, tool use, shell command execution, file edits and test execution. - No other AI model was used for this 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 - [x] My branch name describes the change (`fix/sandbox-nested-git-exclude`) and contains no internal ticket id - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] I have updated relevant documentation to reflect my changes — no docs page describes this internal exclude list - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green — CI starts after this PR - [ ] Greptile is 5/5 with no open P2s — review starts after this PR - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
32e80f80fe |
fix(codex-local): accept newer prerelease CLI versions (#18508)
## Thinking Path > - Paperclip manages AI agents and checks their execution environment. > - The Codex adapter checks the installed CLI against the selected model's minimum version. > - The parser rejects prerelease builds shipped with Codex Desktop, including builds newer than that minimum. > - This stops the hello probe and can leave an approved agent in verification. > - This change accepts valid prerelease versions and compares their release numbers with the stable minimum. > - A prerelease of the minimum release stays below the minimum. ## Linked Issues or Issue Description Fixes: #18498 Refs #15399, which introduced the version check, and #15053, which reports the original model compatibility problem. Related open #15534 adds model catalog discovery; this change addresses version parsing. ## What Changed - Parse one stable or prerelease `codex-cli` version line. Keep malformed and ambiguous output invalid. - Accept `0.164.0-alpha.11.1` against `0.157.0`. Keep `0.157.0-alpha.1` below `0.157.0`. - Cover the parser, stable minimum comparison, CLI hello-probe admission, and ACP environment check. - Document this version rule in the Codex adapter guide. The change stays in the adapter that owns this rule. ## Verification Tested source commit `d8e2e2e` on Windows x64, Node 24.16.0 and pnpm 9.15.4, with isolated test homes. - Seven affected assertions fail with the original production code and pass with this change. The three affected test files report 58 passed and one existing Windows path-separator failure. The same path failure occurs on the original source. - The real `checkCodexCliVersionForModel` launches the installed `codex.exe --version`, which reports `0.165.0-alpha.1.2`. Checks for `gpt-6-luna`, `gpt-6-sol`, and `gpt-6.1-sol` fail on the original source and pass after this change. This probe makes no model request. - `pnpm --filter @paperclipai/adapter-codex-local typecheck` passes. The package build passes with Git Bash as the script shell. - The complete Codex adapter suite reports 530 passed, 65 failed, and one skipped. All 65 failure names also fail on the original production source. That comparison reports 522 passed and 73 failed: seven failures are this regression, and one independent auth-lock timing test changes result between runs. Existing failures include Windows symlink permissions, POSIX file modes/signals, and path expectations. - Full workspace checks remain incomplete on this host. `pnpm -r typecheck` stops at the unchanged Grok launcher digest check in the CRLF checkout. `pnpm test:run` stops at `spawnSync pnpm ENOENT`. `pnpm build` stops at the shared package's POSIX shell command under Windows cmd. Initial install/preflight symlink errors were resolved for local workspace links with directory junctions; those earlier failures remain recorded. - `git diff --check` passes. Greptile reports 5/5 on this commit, and Codex code review completed with no findings. On November 20, GitHub reported 55 passing checks and three skipped checks for this commit. To run the focused tests: ```sh pnpm exec vitest run --config packages/adapters/codex-local/vitest.config.ts packages/adapters/codex-local/src/index.test.ts packages/adapters/codex-local/src/server/test.remote.test.ts packages/adapters/codex-local/src/server/acp.cli-version.test.ts ``` The hello responses in the adapter tests use transport fixtures. Live model execution, lifecycle completion, and native Runner qualification were not exercised. ## Risks The check now admits prereleases whose release numbers exceed a verified stable floor. The hello probe still checks the selected model after version admission. Equal-release prereleases, invalid versions, and ambiguous output stay incompatible. The verified model floors are unchanged. ## Model Used OpenAI GPT-6 through Codex, with reasoning, tool use, and local code execution. This session does not expose its exact deployment model ID or context-window limit. ## 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 - [ ] 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 With assistance from Astra. |
||
|
|
0110436ab6 |
fix(server): keep an existing grant scope when re-ensuring without one (#18116)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Permission grants can carry a scope that narrows what the grant allows > - One function re-ensures a grant: it creates the grant when missing and updates it when present > - The scope parameter defaults to null, and the update path writes it unconditionally > - Most callers omit scope because they only mean to ensure the grant is enabled > - Each such call therefore clears a previously stored scope, including on every server boot through the built-in-agent grant pass > - This pull request makes scope optional: an omitted scope leaves the stored scope alone > - The benefit is that re-ensuring a grant no longer silently widens or narrows it ## Linked Issues or Issue Description Fixes #17992 ## What Changed - `server/src/services/access.ts`: `setPrincipalPermission` now takes `scope?` instead of defaulting it to null. The update path writes scope only when the caller provided one. The insert path still writes null for a new grant without a scope. - `server/src/__tests__/access-service.test.ts`: new test grants a scope, re-ensures without one and expects the scope kept, then clears with an explicit null and expects null. ## Verification - The access-service suite loads and registers the new test, but the embedded-Postgres suite self-skips in this sandbox because Postgres refuses to run as root. The new test therefore has not run locally. CI is the arbiter for it. - Caller audit, done by reading every call site: the six scope-omitting callers (built-in-agent defaults, both agent-copy paths, both invitation acceptances, the permissions tab, and the default task-assign grant) all intend "ensure enabled" and gain the keep behavior. The two scope-passing callers are unchanged: the portability copy passes the source scope or an explicit null, and the bulk grant setter passes an explicit null, so both keep their clear semantics. ## Risks - Low risk. The only behavior change is for update calls that omit scope, which previously reset it to null. No caller was found that relies on that reset. A caller that wants to clear a scope still can, by passing null explicitly. ## Model Used Meta Muse Spark 1.3, 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) - [ ] 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 - [ ] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] 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 Signed-off-by: Josh Cox <joshuacox@users.noreply.github.com> Co-authored-by: Review <review@local>canary/v2026.1205.0-canary.899500 |
||
|
|
e31445b43a |
fix(claude-local): recognise hyphenated 5-hour limit wording as provider quota (#18110)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The claude_local adapter classifies Claude CLI failures as provider quota, transient upstream, or other errors > - Provider quota classification arms the quota monitor and schedules a retry at the reset time > - The quota regexes use `(?:\w+\s+)?limit` for the limit name > - `\w` stops at a hyphen, so "You've hit your 5-hour limit" does not match > - The run then records as transient upstream, spends its bounded retries, and parks the issue blocked with no retry at the reset > - This pull request allows a hyphen in the limit name in both regexes > - The benefit is that 5-hour limit messages classify as provider quota and resume after the reset ## Linked Issues or Issue Description Fixes #18057 Refs #16785 (the same regex family misses the "org's monthly spend limit" wording; that wording needs multi-word names and stays a separate issue) Refs #15797 (other quota wordings this regex family misses) ## What Changed - `packages/adapters/claude-local/src/server/parse.ts`: `CLAUDE_PROVIDER_QUOTA_RE` and `CLAUDE_EXTRA_USAGE_RESET_RE` now use `(?:[\w-]+\s+)?limit` for the limit name. - `packages/adapters/claude-local/src/server/parse.test.ts`: new test classifies the exact reported message as provider quota, not transient, and extracts the 16:30Z retry time. ## Verification - `packages/adapters/claude-local`: `vitest run src/server/parse.test.ts` passes 49/49. - Negative control: with only the `parse.ts` change stashed, the new test fails; with the change restored, it passes. - Full server typecheck and CI are the arbiters for anything beyond this package. They were not run locally in this sandbox. ## Risks - Low risk. The change widens one character class in two match patterns. A limit name with a hyphen now matches where it did not match before. No other wording changes classification: the existing suite passes unchanged. ## Model Used Meta Muse Spark 1.3, 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) - [ ] 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 - [ ] 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 Signed-off-by: Josh Cox <joshuacox@users.noreply.github.com> Co-authored-by: Review <review@local> |
||
|
|
c1c2f7e73d |
fix(cli): check the effective database target in doctor (#17847)
<!-- entire-trail-link-start --> https://entire.com/gh/paperclipai/-/trails/51/changes/paperclip/51 <!-- entire-trail-link-end --> ## Thinking Path > - Paperclip runs with embedded or external PostgreSQL. > - The CLI checks the database before it starts the server. > - The server uses `DATABASE_URL` before the saved connection string. > - Doctor checked only the saved database configuration. > - A valid environment-only setup could fail before startup. > - This change probes the effective server target instead. > - Operators can keep database credentials in the environment. ## Linked Issues or Issue Description Fixes: #11598 Refs: #11612. That predecessor is closed and unmerged. The defect remains on current master at `0cb3fc7db5`. This PR adds current precedence coverage, including a saved embedded mode and explicitly empty environment values. ## What Changed - Resolve the effective URL with the same nullish environment-first rule as the server. - Probe external PostgreSQL when the environment selects it, even if the saved mode is embedded. - Keep an explicitly empty environment value distinct from an unset value. Do not trim or replace the selected URL. - Add eight mocked transport regressions. Keep the three embedded storage checks. ## Verification - `node node_modules/vitest/vitest.mjs run --config cli/vitest.config.ts cli/src/__tests__/database-check.test.ts` — 11 passed. - Six new cases failed before the original fix. - Review exposed one ambient worktree-mode failure in the new embedded fallback test. That test now sets its worktree flag explicitly. - Both `env -u PAPERCLIP_IN_WORKTREE node node_modules/vitest/vitest.mjs run --config cli/vitest.config.ts cli/src/__tests__/database-check.test.ts` and `PAPERCLIP_IN_WORKTREE=true node node_modules/vitest/vitest.mjs run --config cli/vitest.config.ts cli/src/__tests__/database-check.test.ts` pass all 11 cases. - Tests cover environment-only configuration, environment precedence, embedded override, saved fallback, empty values, unchanged URL forwarding, and a failed effective-target probe. - The database factory and transport are mocked. No database is started or contacted. - PR CI passed full typecheck, build, and broad tests on the exact reviewed head. Broad local checks were not repeated while a separate live qualification run owned local resources. - Fresh Greptile review is 5/5 at `a042fb4a28f2e1574972798ed80de2e616daf9fc`. All review threads are resolved. All 55 successful checks for this exact head are green. Two conditional checks are skipped, and one review check is neutral. No checks are pending or failed. ## Risks - Doctor now probes the database that server startup will use, instead of an ignored saved target. - Empty `DATABASE_URL` follows the existing server rule. It masks a saved URL in Postgres mode and leaves embedded mode selected when no effective URL exists. - No schema, migration, startup resolver, or provider behavior changes. Existing environment support is already documented in the implementation spec and developing guide. ## Model Used OpenAI `gpt-6.1-sol`, with repository inspection, code editing, and offline test tools. No model or provider call was used in the regression. ## 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: Paperclip <noreply@paperclip.ing>canary/v2026.1205.0-canary.899300 |
||
|
|
0da786fdc3 |
fix(issues): clear the compact issue-list cache when an issue changes (#17828)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The board reads task lists through `GET
/api/companies/:companyId/issues?view=compact`
> - The server keeps compact list responses in a short in-memory cache
(`ISSUE_LIST_SERVER_CACHE_TTL_MS = 2000`), keyed by actor and query, to
absorb request storms (#9190)
> - The board refetches its issue lists when it receives an
`activity.logged` live event for an issue
> - But a create, update or delete does not clear the cache, so the
refetch gets the cached list from before the change. The board shows the
old value for up to two seconds, and a quick edit seems to snap back
> - This pull request clears the cached compact lists of a company when
the server publishes an `activity.logged` event for an issue in that
company
> - The benefit is that a list fetched after a change shows the change,
and the cache still absorbs request storms between changes
## Linked Issues or Issue Description
**What happened?**
I changed the title of a task, and the board refetched the task list
immediately. The response had the old title and the header
`x-paperclip-request-cache: hit`. The list showed the old title until
the board fetched the list again more than two seconds later. The same
thing happens for other changes that the compact list shows, for example
status, priority and assignee.
**Expected behavior**
A compact list request that the server receives after a change returns
the changed values. The cache can answer repeated requests only while no
issue in the company changes.
**Steps to reproduce**
1. Start Paperclip with a company and one task.
2. Send `GET /api/companies/<companyId>/issues?view=compact`.
3. Within two seconds, send `PATCH /api/issues/<issueId>` with
`{"title":"After"}`.
4. Within two seconds of step 2, send the request from step 2 again.
5. Before this change, the response has the old title and
`x-paperclip-request-cache: hit`.
**Paperclip version or commit**
`master` at
|
||
|
|
66b97fb490 |
fix(plugin-sdk): do not stamp a finished invocation on a worker-to-host call (#17797)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Plugins run in a worker process. The host issues an invocation for each request or event it delivers, and the SDK stamps that invocation id on every worker-to-host call so the host can resolve the call's company. > - Node propagates the ambient AsyncLocalStorage context into a timer callback. A `setTimeout` or `setInterval` armed inside a handler therefore still sees the invocation after the handler returned. > - The SDK stamped it anyway. The host looked the id up, missed it, and refused the call as "a missing, expired, or unknown invocation scope". > - The host resolves a call that carries no id by the company the call names. So a call that claimed nothing would have been allowed. A call that claimed a dead invocation was not. > - The symptom is quiet. The plugin's feature still works, but every host call from its timer fails, and the work arrives late or not at all. > - This pull request stops the stamp at the moment the handler returns. The worker is the only side that knows when that happened. > - The benefit is that a plugin author does not have to discover this trap. Scheduled and deferred work in a plugin now behaves as the specification describes. ## Linked Issues or Issue Description Fixes: #17532 Related issues, each a different cause behind the same error string. This change does not fix them: - Refs #15765 — the host-side mirror. There the call carries **no** id, and the `activeInvocations.size > 0` rule refuses it. Here the call carries a **dead** id, and the lookup refuses it. Each fix leaves the other bug standing. - Refs #8633 — a polling loop started in `setup()`, which has no invocation to inherit. - Refs #9310 — `runJob` carries no scope. - Refs #7897 — an SDK version that never echoes the id. Related pull requests. I read all three before writing this one: - Refs #10580 — the opt-in form of this fix. It adds `ctx.runtime.runProactively(cb)` so an author can detach deliberately. The two compose: that API lets an author drop the stamp *inside* a live handler, and this change drops it only after the handler returned. This one needs no plugin change, which matters because the trap is invisible to the author. - Refs #15925 — retires an event invocation scope when the worker handlers settle. It is complementary, and it makes this fix more necessary. Today a notification registers its scope with the maximum RPC timeout and clears it only if the send throws, so a timer armed in an event handler is admitted for up to 15 minutes. #15925 closes that window. The dead-stamp refusal then appears on the event path too, and this change is what prevents it. The two also work together in code: this change marks the invocation finished before the notification settles, so the settlement notification that #15925 sends goes out unstamped and carries its id in the parameters, as it already does. - Refs #8159 — a 5 second grace period after a scoped RPC settles. It answers a different question. That window covers a nested request already in flight when the response lands. It does not cover a timer that fires seconds or minutes later. It also carries an unrelated transaction change in `server/src/services/environments.ts`, and it has conflicted since June. ## What Changed - `packages/plugins/sdk/src/worker-rpc-host.ts`: a `WeakSet` of finished invocation contexts, plus `liveInvocation()` at the two stamp sites and `runInInvocationScope()` at the two scope-entry sites. - The guard is keyed on the invocation context object, not on the id string. Each delivery deserializes its own object. A second delivery that carries the same id keeps its own stamp while its own handler runs. - Both scope-entry sites are guarded. A host-to-worker notification also runs its handler inside the invocation scope, and an event handler is a normal place to arm a timer. - `doc/plugins/PLUGIN_SPEC.md` gains §12.3.1. The contract said that a call with no invocation is attributed by the company it names. It never said which calls have no invocation, and not being able to tell is the whole trap. - No host change. No manifest change. No new dependency. ## Verification ```bash cd packages/plugins/sdk pnpm vitest run # 178 passed, 14 files pnpm tsc --noEmit -p tsconfig.json # clean ``` Red before green, which is the part worth checking: - With the three new tests in place and `src/worker-rpc-host.ts` restored to `master`, **two of the three fail**. The in-handler call keeps its stamp and the timer's call keeps it too, which is the bug. - The third test passes either way by design. It asserts that a live invocation still stamps, and it is there to prove the guard does not over-reach. - The tests drive a real worker over a pair of pipes. The host side answers every worker-to-host request and records the id on each `state.get` request and each `execute.log` notification. One case enters through a request, one through an event notification, and one runs two deliveries that share an id. ## Risks Low. - The behaviour change is narrow. A worker-to-host call made after its handler returned now goes out with no invocation id, where before it went out with a finished one. - The host already handles a call with no id. It resolves the company the call names against the plugin's proactive company scopes, and it refuses the call when that company is not configured. So a call that was refused for a missing scope can now succeed, but only where the operator already authorized that company. Where the operator did not, the call is still refused. The line that refuses it changes; the answer does not. - A call made inside a handler is unaffected. The stamp is dropped only after the handler settles. - The `WeakSet` holds no strong reference, so a finished invocation context is still collected. ## Model Used Claude Opus 5 (`claude-opus-5`), with extended thinking and tool use. The model wrote the change and the tests, ran the verification above, and read the three related pull requests before positioning this one. A human reviewed all of it. ## 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 mergecanary/v2026.1205.0-canary.899100 |
||
|
|
d61877761a |
fix(docker): install lsof for listener ownership checks (#17770)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Paperclip can start and supervise local runtime services for a workspace > - `local-service-supervisor` finds the process that listens on a service port with `lsof -nP -iTCP:<port> -sTCP:LISTEN -t` > - The Docker image is based on `node:24-trixie-slim`, which does not include `lsof`, and the Dockerfile does not install it > - In the container, the lookup always fails and `readLocalServicePortOwner` returns `null` > - It also runs `ps -o command= -p <pid>` and `ps -o pgid= -p <pid>` for its command and process-group checks, and the slim image has no `ps` either > - This pull request installs `lsof` and `procps` in the base stage of the image > - The benefit is that port-owner adoption, command matching and stop checks have process evidence in Docker deployments too ## Linked Issues or Issue Description No public issue exists for this. I searched open and closed issues and pull requests for `lsof`, "listener" and changes to `Dockerfile`. I found no related change. **What happened?** In the Docker image, `readLocalServicePortOwner` always returns `null`, because `lsof` is not installed and the call fails with `ENOENT`, which the function catches. Callers then act without listener evidence: - `findLocalServiceRegistryRecordByRuntimeServiceId` removes a registry record whose original PID is gone, even when another process of the service still listens on the port. - `adoptLocalServiceFromPortOwner` cannot adopt a running listener. - The stop path (`targetIsGone`) treats the port as free when the target PID is gone, even if a child process still listens on it. The same applies to `ps`, which comes from `procps` on Debian: `isLikelyMatchingCommand` catches the `ENOENT` and treats any live PID as the recorded service, and `readLocalServiceProcessGroupId` returns `null`, so `isLocalServiceProcessOwnedBy` cannot confirm group ownership. **Expected behavior** The image contains the tools that the server calls at runtime. The port-owner lookup returns the listening PID in Docker as it does on a host with `lsof`. **Steps to reproduce** 1. Run `docker run --rm node:24-trixie-slim sh -c 'command -v lsof || echo missing; command -v ps || echo missing'`. Both print `missing`. 2. The Dockerfile `base` stage installs `ca-certificates gosu curl gh git wget ripgrep python3 tini` and no `lsof`. The `production` stage starts from `base`. 3. In a container with `lsof` installed, start a listener on a port and run `lsof -nP -iTCP:<port> -sTCP:LISTEN -t`. It prints the listener PID. **Paperclip version or commit** Seen on v2026.1023.0. The patch base is current `master` (`a52f622be8`). **Deployment mode** Docker image. ## What Changed - Add `lsof` and `procps` to the `apt-get install` list in the `base` stage of `Dockerfile`. The `production` stage starts from `base`. - `container-init-reaping.test.ts` asserts that the `base` stage installs both packages. `procps` was suggested in review. ## Verification - `node:24-trixie-slim` has no `lsof`. After `apt-get install lsof` in that image, `lsof -nP -iTCP:43117 -sTCP:LISTEN -t` printed the PID of a Node listener on port 43117. - In `node:24-trixie-slim` with every package that the current `master` Dockerfile installs (`base` and `production` stage apt lists), `ps` and `lsof` are both missing and `procps` is not installed. After adding `lsof procps`, `ps -o command= -p <pid>` and `ps -o pgid= -p <pid>` work as the unprivileged `node` user. - `npx vitest run src/__tests__/container-init-reaping.test.ts` in `server`: 16 tests passed. With `procps` removed from the Dockerfile, the new `procps` case fails. - I did not build the full image locally, because the build includes the Rust runner stages. The CI Docker jobs cover the build. ## Risks - Low risk. Two small Debian packages in the base stage. The image grows by the size of `lsof`, `procps` and their dependencies. > 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 AI-assisted with Claude Code and OpenAI Codex coding agents; exact model versions are not listed. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [ ] 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 (none needed: no documented behavior or setup 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
20ffa6b0a3 |
fix(prompt): reference the exact plan revision on resumed turns (#17769)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Each heartbeat run gives the agent task Markdown, and a task can have a revisioned plan document > - A resumed session gets a compact variant of that Markdown, because the session already received the assignment brief > - The compact variant already leaves out the issue description, but it still repeats the full plan body on every resumed wake > - A long plan therefore grows every resumed prompt, although the session already has the plan > - This pull request keeps the exact plan document and revision pointer in the compact variant and drops the body > - The benefit is smaller resumed prompts without a weaker plan contract: the agent reads that exact revision when it does not have it ## Linked Issues or Issue Description No public issue exists for this. I searched open and closed issues and pull requests for the task plan in resumed prompts and for changes to `server/src/services/heartbeat/task-markdown.ts` and `task-context.ts`. Related prompt-size work: #17584 (skip static notes on resumed ACPX sessions), #17342 and #16645 (bound the execution continuation). **What existing behavior does this improve?** `buildPaperclipTaskMarkdown` with `includeDescription: false` builds the compact task Markdown for resumed sessions. It still writes the full `Task plan document …` body in a fenced block on every resumed wake. **Subsystem affected** Heartbeat task context (`server/src/services/heartbeat/task-markdown.ts`, `server/src/services/heartbeat/task-context.ts`). **Current behavior** Every resumed wake repeats the full plan body, even when the plan did not change and the session already holds it. **Proposed behavior** The compact variants keep the line `Task plan document <id>, revision <n> (<revisionId>):` and the work-mode rule. In place of the body, they tell the agent to read that exact revision through `GET /api/issues/{id}/documents/plan` (or its `/revisions` list) when the session does not have it, and not to use a later draft or infer approval. The full variants do not change. **Reason and benefit** Resumed prompts stay smaller. A changed plan still shows a new revision id, so the agent can see that it must read the new revision. ## What Changed - `buildPaperclipTaskMarkdown` accepts `includePlanBody`. When it is `false`, the plan section keeps the document and revision pointer and replaces the fenced body with the read instruction. - `prepareHeartbeatTaskContext` passes `includePlanBody: false` only for `paperclipTaskMarkdownCompact` and `paperclipTaskMarkdownAssignmentCompact`. Fresh attempts and assignment-shaped wakes use the full variants and still get the body. - A quarantined low-trust plan seen by a higher-trust agent keeps its withheld-body notice in the compact variants instead of the read instruction, because the issue document routes return the stored body without the quarantine filter. - Add unit tests for the compact plan section in all work modes, for a changed revision and for rejected-plan rules. - Add a database-backed test that runs a real heartbeat with a plan document and checks all four task Markdown variants. Another one checks all four variants for a quarantined plan. ## Verification On the head rebased onto `master` `7e8901aa60` (the later rebase onto `7cd5558e41` did not change any file this PR touches): - `npx vitest run src/__tests__/heartbeat-context-summary.test.ts src/__tests__/heartbeat-task-context.test.ts` in `server`: 2 files, 70 tests passed (with embedded PostgreSQL). - Without the source change, the two new plan tests fail (checked before the rebase). Without the quarantine change, the quarantined-plan test fails. - `pnpm --filter @paperclipai/server typecheck` (all layers, including the test trees): no errors. `pnpm check:tokens` and `pnpm check:module-boundaries` pass. ## Risks - A resumed session that lost the plan from its context must call the API to read it. The prompt names the exact endpoint and revision. - Approval and work-mode rules do not change. The rejected-plan text stays in the compact variant. > 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 AI-assisted with Claude Code and OpenAI Codex coding agents; exact model versions are not listed. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [ ] 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 (none needed: no documented behavior or setup 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: a-vasyliev <1255946+a-vasyliev@users.noreply.github.com> |
||
|
|
bfbe2e3a7f |
fix(issues): refuse execution policy stage removal by non-board actors (#17503)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Issues carry an execution policy with review and approval stages
> - `PATCH /api/issues/:id` replaces the policy, and the assigned agent
can send `{ stages: [] }` or `null`
> - The stages go away, a pending review is dissolved, and the issue can
then go `done` unreviewed
> - #16431 locks a policy that has a user participant. It does not cover
a policy with only agent stages.
> - This pull request refuses stage removal by non-board actors for any
staged policy
> - The benefit is that an agent cannot remove the gate that exists to
check its work
## Linked Issues or Issue Description
Fixes #17301
Refs #16431
This change extends the #16431 lock to the agent-only gap that #16431
does not cover. Both PRs add a check at the same place in the PATCH
handler. The PR that merges second needs a small rebase.
## What Changed
- `server/src/routes/issues.ts`: a non-board PATCH that sends
`executionPolicy` gets `403 { code: "execution_stage_removal_locked" }`
if a stage id in the current policy is not in the new policy. This
includes `null` and `{ stages: [] }`. Board actors are not affected.
- `server/src/__tests__/issue-execution-policy-routes.test.ts`: four
tests. An agent that removes an agent-only stage is refused. An agent
that sets the policy to `null` is refused. A board user can remove
stages. An agent can change only the monitor when it sends the stages
again.
## Verification
- `pnpm exec vitest run
server/src/__tests__/issue-execution-policy-routes.test.ts`: 41 pass (37
existing and 4 new).
- Without the route change, the two refusal tests fail.
- The 13 route test files that send agent PATCHes with
`executionPolicy`: 500 pass.
- `tsc --noEmit` in `server` reports no errors in the changed files.
## Risks
- An agent that sends only `{ monitor }` on an issue with stages now
gets 403. Before this change, that request removed the stages without a
warning. The 403 message tells the agent to send every current stage
with its id together with the monitor.
- The check compares stage ids only. An agent can still change the
participants of a stage and keep its id. #16431 covers this for user
participants.
> 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), used in Claude Code with
tool use (file reads, shell, test runs).
## 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
- [ ] 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
|
||
|
|
6a62ccdba5 |
fix(hermes): allow keyless local inference endpoints (#17477)
## Thinking Path > - Paperclip is an open-source application for managing AI agents. > - Paperclip uses adapters to connect to agent runtimes. > - The Hermes adapter checks the local Hermes configuration. > - Hermes can use Ollama on a local HTTP endpoint without a cloud API key. > - The adapter reports `hermes_no_api_keys` even when this local configuration is valid. > - This warning can mislead users during environment validation. > - This pull request recognizes configured loopback inference endpoints. > - The change reduces false warnings and keeps warnings for remote endpoints. ## Linked Issues or Issue Description ### Related pull requests No existing public issue has been identified for this specific bug. The following pull requests cover related Paperclip capabilities: - #4654 — Related Hermes local-script functionality. - #10260 — Native Ollama adapter support. - #15565 — Model gateway documentation. - #14154 — Hermes home-directory resolution. These pull requests provide related context. None is a confirmed duplicate of this fix. This PR addresses the Hermes adapter's API-key validation for local inference endpoints. I reviewed `ROADMAP.md`. The roadmap lists Hermes as a supported adapter, but it does not identify planned work for local inference API-key validation. **What happened?** The Hermes adapter reports `hermes_no_api_keys` when Hermes uses a local Ollama inference endpoint without cloud API credentials. The warning appears during Paperclip's Hermes environment validation. **Expected behavior** Paperclip should not report missing cloud API keys when the requested model uses a configured loopback inference endpoint. Paperclip should continue to warn when the endpoint is remote or the requested model does not match the detected model. **Steps to reproduce** 1. Configure Hermes to use Ollama at `http://127.0.0.1:11434/v1`. 2. Configure Hermes to use a locally available model. 3. Do not configure cloud LLM API keys. 4. Run the Hermes adapter environment validation in Paperclip. 5. Observe the `hermes_no_api_keys` warning. **Paperclip version or commit** The bug was identified in the upstream Hermes adapter. The fix is based on the upstream `master` branch and is available in commit `cc34b2119`. The exact upstream base commit has not been recorded in this description. **Deployment mode** Local development. **Agent adapter(s) involved** Hermes. **Database mode** Not database-related. **Relevant logs or output** Before the fix: `hermes_no_api_keys`. After the fix: `hermes_local_endpoint_no_api_key`. **Relevant config (if applicable)** The affected configuration uses: - Inference provider: Ollama - Inference endpoint: `http://127.0.0.1:11434/v1` - Model: A locally available Ollama model - Cloud LLM API keys: Not configured The endpoint is a loopback address. Ollama serves the model locally. This configuration does not require a cloud inference API key. ## What Changed - Added exact loopback hostname checks for `localhost`, `127.0.0.1`, and `[::1]`. - Limited accepted endpoint schemes to HTTP and HTTPS. - Added an informational validation result for matching local model configurations. - Preserved existing cloud API-key checks. - Preserved warnings for remote endpoints and model mismatches. - Added eight regression tests for valid and invalid endpoint configurations. ## Verification - Hermes adapter targeted tests: 15/15 passed. - Hermes adapter TypeScript typecheck: passed. - Repository-wide typecheck (`pnpm typecheck`): passed across all 35 participating workspace projects. - Rust runner compilation: passed with non-blocking compiler warnings. - Database migration safety checks: passed. - `git diff --check`: passed. - Repository-wide tests: server test failures occurred outside the changed Hermes files. Their causes are not yet confirmed. The targeted Hermes adapter tests and repository-wide typecheck passed. The repository-wide test suite did not fully pass. ## Risks Low risk. The change affects only Hermes environment validation. The adapter accepts a configured loopback endpoint without requiring a cloud API key. It does not verify that the endpoint is reachable or that the inference server accepts requests without authentication. The change does not modify model execution, credentials, or database state. ## Model Used Local inference using Tiel-Coder-35B-A3B-GGUF-MTP through LM Studio, integrated with Cline in VS Code. The model assisted with code changes and regression tests. ChatGPT (GPT-6) assisted with review, test planning, and pull request preparation. ## 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 or (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links - [x] My branch name describes the change and contains no internal Paperclip ticket id - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] 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 - [ ] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
ed82614fae |
fix(pi): settle the run when the adapter fails before the provider (#17416)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Every agent run settles when it has a usage receipt, or when it carries the proof that the provider was never reached > - The Pi adapter can fail before it reaches the provider. Two examples: the command is not resolvable, or the configured model is not in `pi --list-models` > - In that case the adapter throws. The server receives no result. The terminal run then has no receipt and no proof of "no provider work". > - The cost accounting sweeper skips such a run. The run never settles. The budget gate counts it as unsettled spend and hard-stops the scope. The agent cannot run again. > - This pull request returns the bootstrap proof for that failure path. > - The benefit is that a pre-provider failure settles at zero cost and the agent keeps working. ## Linked Issues or Issue Description Refs #15649 Related work and duplicates found in the pre-PR search: - #17265 fixes the same failure class for the hermes adapter. This PR is the Pi equivalent. It does not touch hermes. - #15986 handles a cancelled run with partial usage. This is a different case: the provider was reached there. ## What Changed - Wrap the pre-flight checks in `packages/adapters/pi-local/src/server/execute.ts` in one try/catch block. The block covers command resolution and model availability. - Return `executionRecovery: { kind: "bootstrap", providerWorkStarted: false }` when a pre-flight check fails. Do not rethrow. - Add `packages/adapters/pi-local/src/server/execute.bootstrap.test.ts`. The test forces the model check to fail and asserts the bootstrap proof, the exit code, and the log line. ## Verification - Run `vitest run` in `packages/adapters/pi-local`. Result: 7 test files, 63 tests, all pass. - Run `tsc --noEmit` in the same package. Result: no errors. - Manual reproduction on a self-hosted 2026.1023.0 instance, Pi adapter, model not present in `pi --list-models`: - Before the change: the run ends as `adapter_failed` with `cost_accounting_pending = true`. `retry-accounting` returns `{"accounted": false}` on every call. The scope stays paused. - The same run row, with `usage_json.accountingProviderWorkStarted = false` present, settles at zero cost. `retry-accounting` returns `{"accounted": true}` and the scope resumes on the next wake. ## Risks Low risk. The change touches only the code path before the provider starts. Runs that reach the provider keep the current behaviour. One behaviour change: a pre-flight failure now returns a result instead of an exception. The run message becomes `Pi cannot start: <reason>` instead of a bare `adapter_failed`. This message is the same shape the hermes adapter uses. ## Model Used - Provider: DeepSeek - Model ID: `deepseek-flash` - Reasoning: enabled - Context window: 1M tokens ## 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 - [ ] 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 Co-authored-by: jet <jet@users.noreply.github.com>canary/v2026.1205.0-canary.898600 |
||
|
|
378278b21e |
fix: stop tool gateway routes from returning raw internal error text (#17321)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The tool gateway routes in server/src/routes/tool-gateway.ts serve the board API and the public MCP protocol at POST /mcp/gateways/:gatewayPublicId > - Those routes use their own sendGatewayError helper instead of the global error handler > - for any error that isn't an HttpError it sent err.message back to the caller, so a database failure leaks drizzle's Failed query text with the SQL and its params > - The public MCP route only needs a bearer header to reach that path, so even a caller with a bad token can get that text > - This pull request makes the helper answer with a fixed Internal server error and log the real error on the server, same as the global handler does > - The benefit is no more SQL or param values in 500 responses from these routes ## Linked Issues or Issue Description Fixes #16783 ## What Changed - sendGatewayError in server/src/routes/tool-gateway.ts now logs unknown errors with logger.error and returns { error: "Internal server error" } with status 500. - HttpError and ToolGatewayHttpError responses are not changed, they still send their own message and details. - Added server/src/__tests__/tool-gateway-error-response.test.ts. It mounts mcpGatewayProtocolRoutes with a gateway that throws a drizzle style error and checks the 500 body has no SQL or params. Same for a thrown string. ## Verification - Ran the new test on master first and both cases fail, the response body has the full Failed query text and the param value. With the fix both pass. - tool-gateway.test.ts, tool-gateway-discovery-http.test.ts, tool-grant-scope.test.ts and prompt-injection-gateway.test.ts still pass. - Typecheck on the changed files is clean and check:node-version, check:module-boundaries, check:tokens and the no git push check pass. ``` cd server && npx vitest run src/__tests__/tool-gateway-error-response.test.ts src/__tests__/tool-gateway.test.ts ``` ## Risks - Low risk. Only the fallback branch for unexpected errors changes. - If some client was reading the raw message from a 500 it will now just see Internal server error. The full error is still in the server log so nothing gets lost for whoever runs the instance. - btw tool-gateway.ts was already over 1000 lines before this, the change adds one import line. ## Model Used Grok Bot (an AI assistant) helped trace the root cause and draft the fix and the test. I reviewed the change and ran the tests locally. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [ ] 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 - [ ] 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 - [ ] I will address all Greptile and reviewer comments before requesting merge Co-authored-by: Pradeep Peddineni <23334879+pradeeppeddineni@users.noreply.github.com>canary/v2026.1205.0-canary.898500 |
||
|
|
68533743a2 |
fix(ui): settle Files reports and preserve sidebar navigation (#17296)
## Thinking Path > - Paperclip shows workspace files next to an agent task. > - The Files browser reports its current folder and search to the task panel. > - New callback identities repeatedly report identical state and rerender the panel. > - A stale task callback can also replace a new sidebar destination. > - This pull request fixes notification identity and stale-path navigation together. > - Files can stay open without trapping navigation on the task. ## Linked Issues or Issue Description Fixes: #15620 Thanks to @nunobarrosmir for the local-build diagnosis of both mechanisms in this Issue. Related merged #17068 stabilizes tab widths, not this synchronization boundary. ## What Changed - Use the existing callback-ref pattern so callback identity changes do not report unchanged browse state. Real state changes reach the latest callback. - Reject viewer URL updates from an obsolete pathname. Migrate both provider and task-panel guard callers. - Add browser/provider and real TaskSidePanel regression coverage, and update the development guide. ## Verification - RED: 4 failed, 88 passed across the three focused files. Failures included the real panel/browser update loop and stale-path navigation. - GREEN: from ui, `pnpm exec vitest run src/components/WorkspaceFileBrowser.test.tsx src/context/FileViewerContext.test.ts src/components/task-side-panel/TaskSidePanel.test.tsx` — 92 passed. - `pnpm check:token-gates` — passed. - Real Chromium smoke mounted the actual WorkspaceFileBrowser and FileViewerProvider against local empty-workspace API fixtures. The inline state-updating parent settled with one report. After clicking Dashboard, invoking the previous task's saved browse callback left the browser on Dashboard with no task-path replacement. Temporary fixture files were removed. This was a focused component/provider surface, not a complete authenticated task installation. - Independent read-only review checked latest-callback ordering and all guard callers; no concrete blockers. - UI `tsc --noEmit` failed on missing SDK/generated Storybook artifacts and dependency errors outside the changed files. It did not pass. - Same-base full checks in the independent SSH-fix worktree hit test/typecheck deadlines and ENOSPC during build. They are not passes for this branch and were not repeated here. - `git diff --check` passed before commit. ## Risks - The pathname guard intentionally discards late task-state reports after navigation. - Same-task folder changes, current search, and close behavior retain regression coverage. - Full validation, CI, and Greptile remain gates. Draft, not merge-ready. ## Model Used OpenAI `openai-codex/gpt-6.1-sol`, tool use and code execution; context-window size is not exposed by the harness. TypeSafe `jev-1.14.0` supplied advisory approach selection. ## 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 linked the existing public Issue - [x] I have not referenced internal/instance-local Paperclip issues or links - [x] My branch name describes the change and contains no internal ticket id - [ ] 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 ## Append-only follow-up verification - Appended commit `b14ebe622` without rewriting history. The existing markdown-file-link fixture mocked a task pathname while jsdom remained on `/`; it now models the actual browser pathname and restores the original URL. This fixes the dependent regression without weakening the stale-path guard. - Four focused files now pass **102 tests**, including all 10 markdown-availability cases and the existing same-task/stale-path navigation coverage. - Original CI UI shard: 4,987 passed / 1 failed (the corrected fixture). Server shard: 1,803 passed / 1 failed / 13 skipped, with `login-cleanup-work.test.ts:119` observing active=1 instead of 0. E2E shard: 15 passed / 1 failed / 1 skipped; `cases-read-only.spec.ts:130` expected Done but saw All statuses, with an announcement handler also active. The latter two are unchanged-area failures, not established baseline failures, and remain gates. - Replacement CI is pending. Prior UI typecheck/full-build limitations remain. Draft, not merge-ready. --------- Co-authored-by: kaluli123123 <295758798+kaluli123123@users.noreply.github.com> |
||
|
|
0b15b9b2a5 |
fix: clear watchdog user assignees and isolate reconciliation failures (#17286)
## Thinking Path > - Paperclip helps people manage AI agents for work. > - Task watchdogs reuse review issues when a watched subtree stops again. > - A finished review can still have a user assignee. > - Reopening that review for an agent retains the user and fails the single-assignee check. > - One failed watchdog also rejects a whole reconciliation batch, so other watchdogs in that batch are not evaluated. > - This change clears the prior user, isolates each watchdog failure, and keeps a failed watchdog as recovery retry debt. ## Linked Issues or Issue Description **What happened?** A new stopped fingerprint causes a done, user-assigned watchdog issue to reopen. The update sets assigneeAgentId but leaves assigneeUserId set. The issue service returns 422, "Issue can only have one assignee". Reconciliation rejects, and the remaining watchdogs in the same batch or ancestor chain are not evaluated. On the reported release this rejection also aborted startup recovery. **Expected behavior** Reopen the reusable issue with only its configured agent assigned. Log a failed watchdog, continue the other watchdogs, and retry the failed one through the task-watchdog recovery work. **Steps to reproduce** 1. Configure a task watchdog and let it create a review issue. 2. Complete the review and assign that completed issue to a user. 3. Change a watched leaf to produce a new stopped fingerprint. 4. Reconcile task watchdogs. Before this change, the operation rejects with 422. **Paperclip version or commit** Reproduced on upstream master at `2cd6eb27c`. The reopen path is unchanged on current master `629281b1e8a4bae014d682a99aa6cd790508414d`. Current merge candidate: `66d9c624cd86101e8bf65d05cabc3ed449255e5c`, integrating that master with the previously published branch head `681955f972c79a827c5bf2aa3e138fe4b2df69f9`. Related PRs: #11855 addresses reviewed fingerprint reset, #15063 addresses incomplete subtree scans, and #15067 fences reviews by configuration revision. #18402 replaced the startup and periodic recovery sweep with per-watchdog recovery work. This branch now builds on that design instead of changing server startup. #21670 moved subsystem notes out of `doc/DEVELOPING.md`, so the recovery note now lives in `doc/TASK-WATCHDOG.md`. #22831 deleted `task-watchdogs-scheduler.test.ts` and `issue-recovery-work-lifecycle.test.ts`, so this branch's regression tests now live in two focused files. ## What Changed - Clear assigneeUserId in the existing issue-service update when reopening for an agent. - Catch individual watchdog errors in both batch and ancestor reconciliation. Log identifiers and the error, and return a failed count. - Reject the task-watchdog recovery-work check when a watchdog reports `failed`, as it already does for `incomplete`. The coordinator keeps that watchdog as retry debt instead of treating the swallowed error as settled. - Update the route no-op service and the recovery-work owner type to match the result contract. - Add database-backed reassignment, isolation, and reevaluation tests in `task-watchdogs-reconciliation.test.ts`, and a recovery-work test for failed-watchdog retry in `task-watchdog-recovery-retry.test.ts`. - Document the recovery behavior in `doc/TASK-WATCHDOG.md`, under "How a scan works". - No server startup changes. The earlier startup and periodic catch blocks were dropped with the sweep that #18402 removed. ## Verification Current merge revision (29 November): - The only conflicts were the two test files that #22831 deleted. This branch accepts the deletions and moves its four regression tests, unchanged, into `task-watchdogs-reconciliation.test.ts` (with the minimal database harness from the deleted suite) and `task-watchdog-recovery-retry.test.ts` (with the trimmed recovery-work fixture). The added and removed non-test lines are identical to the 16 November revision. - Frozen install with declared pnpm 9.15.4 succeeds. The plugin SDK was rebuilt first; a stale SDK build otherwise fails test collection. - New suites: **4 passed**. With upstream versions of the four changed server files, all 4 fail: the reopen rejects with 422 "Issue can only have one assignee", both reconcile paths reject on the malformed watchdog, and the recovery check sets no retry wake. - Related suites `issue-watchdogs-routes` and `task-watchdogs-incident-fixture`: **14 passed**. - Server TypeScript: failed with 395 diagnostics, none in changed files. With upstream versions of the changed files on the same tree and dependencies, the same 395 diagnostics reproduce exactly. This is baseline reproduction, not a passing typecheck. - `git diff --check` passed. Full workspace checks were not repeated; the historical incomplete-suite and missing-Cargo limitations remain. - CI and Greptile results from the prior published head do not accept this revision. Fresh checks are required after publication. Earlier merge revision (16 November, `681955f9`): 210 focused tests and 20 database-backed recovery tests passed; 370 TypeScript diagnostics reproduced exactly on the upstream parent. Earlier merge revision (1 November, `cd37b848`): 192 focused tests and 18 database-backed recovery tests passed. The failed-watchdog retry test failed without the recovery-work change (1 failed, 12 passed) and passed with it. 208 TypeScript diagnostics reproduced exactly on the upstream parent. Earlier merge revision (27 October, `03cd5fc9`): 89 focused tests passed in independent QA. 48 TypeScript diagnostics reproduced exactly on the upstream parent. Historical initial revision evidence: - New database regressions on unmodified service: 3 failed, 19 passed. Failures were the dual-assignee 422 and uncaught assignment validation failures in both reconciliation entry points. - New startup regression on unmodified startup code: failed because startServer rejected. The other 39 tests passed. - Initial focused suite: 82 passed, 0 skipped: `TMPDIR=/tmp pnpm exec vitest run server/src/__tests__/task-watchdogs-scheduler.test.ts server/src/__tests__/server-startup-feedback-export.test.ts server/src/__tests__/task-watchdogs-classifier.test.ts`. - Initial server TypeScript passed: `TMPDIR=/tmp pnpm --filter @paperclipai/server exec tsc --noEmit`. - `git diff --check` passed. - Full workspace typecheck and build were attempted. Both stop because cargo is absent. They are not green. - Full test suites ended without terminal summaries. They are incomplete, not green. - Initial local setup failures: missing plugin-sdk build, missing embedded PostgreSQL library symlinks, and an overlong tsx IPC temporary path. Built the workspace dependencies, ran the platform package install step, and shortened TMPDIR before the successful focused run. These tests used real PostgreSQL with synthetic data on macOS arm64 and Node 24.22.1. ## Risks - Watchdog errors no longer abort a reconciliation batch. Operators must use the error logs, failed count, and recovery-work retry errors to find an invalid configuration. - No migration, timer, new privilege, startup change, or live installation change. - Existing partial-write delivery behavior is unchanged: a failure after issue creation/reopening can leave an open same-fingerprint issue that suppresses a later enqueue. Later reevaluation does not guarantee every failed delivery retries. The regression proves retry after a pre-write assignment failure. - Independent QA reviewed this exact revision before publication. Full checks remain incomplete; fresh CI is pending publication. ## Model Used Initial fix and 27 October merge: OpenAI Codex, GPT-6, with reasoning, shell tools, code editing, and test execution; exact backend model ID and context window not exposed. 1, 16 and 29 November merges: Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with shell tools, code editing, and test execution. Independent QA reviews each exact revision before publication. ## 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 - [x] My branch name describes the change and contains no internal ticket id or instance-derived details - [ ] I have run tests locally and they pass — focused tests pass; full suites ended without terminal summaries - [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 --------- Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Paperclip <paperclip@localhost> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
23ff8e8be6 |
fix(hermes): settle the run when the skills cannot be reconciled (#17265)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Every run has an accounting state, and the budget gate reads the pending runs > - A run settles when it has a usage receipt, or when it carries the proof that the provider was never reached > - The server writes that proof on every failure path that happens before the adapter is entered > - The Hermes adapter can also fail before it reaches the provider, when it cannot reconcile the Paperclip-managed skills > - The adapter threw that error, so the server received no proof and the run stayed pending for ever > - The budget gate then counts the run as unsettled spend, and it hard-stops the agent, so the agent can never run again > - This pull request reports the failure with the bootstrap result that the server already understands, so the run settles ## Linked Issues or Issue Description There is no public GitHub issue for this defect. The description below follows `.github/ISSUE_TEMPLATE/bug_report.yml`. **Pre-submission checklist** - [x] I have searched existing open and closed issues and this is not a duplicate. The repository was searched for the error text, for the accounting states, and for the recovery record of the bootstrap. The related items are listed at the end of this section. None of them covers this case. - [x] I am on the latest released version of Paperclip (or can reproduce on `master`). The change is based on `master` at `043f2514e67c50320433a0013fb228a75a51325c`. The new test fails on that revision. - [x] I have confirmed the error originates in Paperclip itself — not in my agent adapter, API provider, or local configuration. The Hermes adapter is part of this repository, not an external plugin. The defect is in `packages/adapters/hermes/src/server/execute.ts`. The new test fails on unmodified `master` and passes with the fix. **What happened?** The Hermes adapter failed during its bootstrap, before it called the provider. The adapter threw the error, so the server received no proof that the provider was never reached. The run stayed in the pending accounting state for ever. The budget gate then hard-stopped the agent, and the agent could not run again. The run could not be settled, and the agent could not be resumed past the budget hold. **Expected behavior** A run that fails before the provider is reached must settle. The agent must stay able to run after such a failure. **Steps to reproduce** 1. Give an agent a Hermes adapter with a Paperclip-managed skill. 2. Make the reconciliation of that skill fail. One way is to let a real directory occupy the runtime name of the skill in the skills home. 3. Start a run of the agent. 4. The adapter throws `Cannot reconcile Hermes skill "<key>" because <target> is occupied by another installation.` 5. The run stays in the pending accounting state. The budget gate hard-stops the agent. **Paperclip version or commit** `master` at `043f2514e67c50320433a0013fb228a75a51325c`. **Deployment mode** Self-hosted server. **Installation method** Built from source. **Agent adapter(s) involved** Hermes. The change is in `packages/adapters/hermes`, so no other adapter changes. **Database mode** Not database-related. **Node.js version** v24.22.1 on the author's own host, where the tests ran before the push. **Operating system** Linux on the author's own host, where the tests ran before the push. **Relevant logs or output** The error in the step list above is the complete error from the adapter. The run log then shows that the run never settled. **Additional context** Related pull requests and issues in this repository. This change does not overlap with them. - Refs #15649. That issue reports runs that stay in `waiting_for_receipt` and that block the budget resume. It is the same symptom. The cause there is a missing acknowledgement for the `opencode_local` adapter. This change covers the Hermes adapter, which fails before it reaches the provider. - Refs #13807. That issue reports that a bundled skill release drift throws and hard-fails every run. That throw happens in the run preparation of the server. The server already records the proof on that path. This change covers the adapter path. - Refs #14234. That pull request stops the regeneration of holds for settled runs that failed before the launch. It is server-side work on the same area. **Privacy checklist** - [x] I have reviewed all pasted output for PII (usernames, file paths, API keys, tokens, company names) and redacted where necessary. The pasted output has no API key, no token, no company name, and no user name. The company id, the skill key, the runtime name, and the temporary folder name are replaced with placeholders. ## What Changed - `packages/adapters/hermes/src/server/execute.ts`: a failure of the managed-skills reconciliation no longer throws. The adapter returns a result with `exitCode: 1` and the recovery record `executionRecovery: { kind: "bootstrap", providerWorkStarted: false }`. - `packages/adapters/hermes/src/server/execute.ts`: the error message still goes to the log stream for stderr. The returned result carries the text `Hermes cannot start: <reason>`. - `packages/adapters/hermes/src/server/execute.skills.test.ts`: new test file with one case. The case lets a real directory occupy the runtime name of a managed skill, so the reconciliation fails. The test checks that the adapter returns the no-provider-work proof instead of throwing, and that the provider was never started - the promise the server settles the run on. The mock of the child process would succeed silently if it were called, so the test asserts on the mock itself. - No code comments are added. The upstream contributing guide asks that a pull request carries none, so the explanation of the failure mode lives in this description. ## Verification The commands below ran on the author's own Linux host, before the push. They did not run on CI. The host used Node.js v24.22.1 and pnpm 12.14.0. The tree was the upstream `master` revision `043f2514e67c50320433a0013fb228a75a51325c`. ```sh pnpm --filter @paperclipai/hermes-paperclip-adapter exec vitest run src/server/execute.skills.test.ts ``` Before the change, the new case failed. The failure was the production error itself. ``` FAIL src/server/execute.skills.test.ts > hermes-local adapter: the skills cannot be reconciled > reports the failure with the no-provider-work proof instead of throwing Error: Cannot reconcile Hermes skill "<company-id>/<skill-key>" because <skills-home>/<runtime-name> is occupied by another installation. ❯ reconcileHermesPaperclipSkills src/server/skills.ts:242:13 ❯ Module.execute src/server/execute.ts:370:30 Test Files 1 failed (1) ``` The company id, the skill key, the runtime name, and the temporary folder name are replaced with placeholders. The test uses fixed values for them. After the change, the file passes. ``` Test Files 1 passed (1) Tests 1 passed (1) ``` The whole package was run in the state of this branch, and it is green. ``` Test Files 11 passed (11) Tests 174 passed (174) ``` That run was repeated on the same host after the review, on Node.js v24.16.0 with vitest 5.0.3, against the branch tree with the cost test of the other pull request moved aside - that test belongs to a different branch. The package copy was placed next to the original so that the workspace links resolve the same way, and the instance that serves the drill was not touched. The assertion on the child process was checked to have teeth: with the assertion inverted, the same file fails with `expected "vi.fn()" to be called at least once`, so the mock really records the calls. The wider suites of the two packages were not re-run for this pull request. A recorded run of them shows failures that also exist on unmodified `master` in the same environment. They concern the workspace sync and the sandbox provisioning. ### The pull request carries no code comments The contributing guide asks that a pull request adds no code comments, so the explanatory blocks of this change were removed and the reasoning moved into this description. The tree of the branch was rebuilt from the branch content alone, and the whole package suite was run again on that tree. ``` Test Files 11 passed (11) Tests 174 passed (174) ``` The type check of the package passes as well. ``` cd packages/adapters/hermes ./node_modules/.bin/tsc --noEmit ``` ## Risks - The change is local to the Hermes adapter. No other adapter and no server code changes. - The adapter now reports the failure instead of throwing it. The run still fails, and the agent still does not do the work. Only the accounting state changes, because the run can now settle. - The fix is in the adapter on purpose. A fix in the core would have to guess whether an adapter that threw had already spent money. A wrong guess under-bills. Only the Hermes adapter has this failure, and only the adapter knows that the provider was never reached. - If the server does not understand the bootstrap result, the run would stay pending. The server already handles a result with `kind: "bootstrap"` and `providerWorkStarted: false` on the failure paths that happen before the adapter is entered. - The upstream contributing guide asks that a pull request carries no code comments, so this change adds none. The explanation that the code would have carried lives in this description instead: the failure mode is not obvious from the diff, so a reviewer has to read the description above to follow the change. ## Model Used - Provider: MiniMax - Model id: `minimax-M3.1-Flash` - Context window: not published in this environment. The size is unknown. - Reasoning mode: the environment does not expose a reasoning or thinking mode for this model. - Capabilities used: tool use, code execution, shell, file editing. ## 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 - [ ] 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 |
||
|
|
43a3b12bd7 |
fix(claude-local): classify auth from provider evidence (#17229)
## Thinking Path > - Paperclip manages work performed by AI agents. > - The Claude CLI adapter converts provider output into run errors. > - Ordinary transcript text can contain words such as `unauthorized` or `login required`. > - A max-turns result can also contain the model's last answer. > - These words can mark a valid Claude connection as needing reauthentication. > - This change limits auth classification to failure evidence and excludes max-turns summary prose. > - Cleanup finalization and retry policy stay with their existing owners. ## Linked Issues or Issue Description Refs #5534, #15441, #15660, #14089, #13647, #17865. Related cleanup work: Refs #15774, #14611, #13322, #13028. **What happened?** A successful Claude result followed by process cleanup at exit 143 received `claude_auth_required` because an unrelated tool transcript contained `unauthorized`. A max-turns result can produce the same false label when its summary quotes login or token-failure text. **Expected behavior** Use provider authentication evidence to decide whether Claude needs a new login. Preserve a max-turns stop when only its summary mentions auth. Preserve real provider auth errors. Leave cleanup outcome, notification detection, and retry policy unchanged. **Steps to reproduce** Feed the adapter a successful result, transcript auth prose, and a cleanup receipt. It must not report `claude_auth_required`. Feed it an `error_max_turns` result whose summary says "The page says login required for guests." or quotes an invalid bearer token. It must retain `max_turns_exhausted`. The fixtures require no provider credentials. **Paperclip version or commit** The original reproduction used `def4726be`. The branch includes upstream master `1ca90d2d6f`; the latest auth correction is `ae586d060d`. **Deployment mode** Local source-checkout verification with synthetic process receipts. ### Related PR boundaries - #15660 overlaps the auth parser change. This alternative also excludes max-turns summary text from both auth scans, ignores stderr after a successful result, filters JSON records from eligible diagnostic streams, and retains explicit terminal HTTP 401. Maintainers should select or consolidate one parser implementation. - #14089 adds an execution-level failure gate. It does not by itself prevent transcript words from misclassifying a run that failed for another reason. - #17865 addresses max-turns classification and connection repair. This PR excludes model summary prose while retaining separate provider auth evidence. It does not change connection repair. - #15774 owns a proposed cleanup success rule. This PR adds no cleanup error code and no success promotion. It defines no new retryability rule. - #13322/#13028 concern synthetic task-notification results. This PR does not change result selection or the cleanup trigger and does not claim to fix that case. ## What Changed - Match login markers against failed terminal fields and plain failed-run stderr. Before a result exists, also accept plain startup stdout. Exclude JSON transcript records from those diagnostic streams. - Ignore successful answer text and successful-run stderr. - Exclude max-turns `result` prose from both login-prompt and token-failure scans. Reuse the existing structured max-turns detector. - Retain explicit provider `error`/`errors`, terminal HTTP 401, and plain CLI login diagnostics. - Add parser and adapter regressions for summary prose, provider errors, startup diagnostics, and cleanup receipts with exit 143, SIGTERM, or SIGKILL. - Incorporate [Bart Rozycki's follow-up](https://github.com/TheJohnzo/paperclip/pull/1), including 33 synthetic scenarios and 76 detector/execution tests. Ignore stdout lines beginning with `{` after trimming when no terminal result exists, so a partial JSON tool event cannot become a login diagnostic. Stderr continues to discard only valid JSON; malformed JSON-looking login prompts there and in terminal results remain recognized. - Keep upstream's deletion of the obsolete execution-semantics document and upstream's shared CLI startup budget. The re-home fixture retains only a workload explanation comment. The Claude adapter owns this parsing. No shared contract or orchestration change is needed. `execute.ts` matches upstream. Existing exit codes, signals, and nested cleanup evidence remain intact. ## Verification - At `ae586d060d`, `pnpm --filter @paperclipai/adapter-claude-local exec vitest run src/server` passed: **489 tests passed, two skipped**, across 23 passing files and one skipped file. This includes all 76 new auth classification tests. - Red/green: removing only the stdout partial-JSON filter reproduced exactly the two M3 failures (detector and `execute()`), with the other 74 new tests passing. Restoring the filter passed the full server suite. - Adapter `typecheck`, adapter `build`, and staged diff whitespace checks passed. - Prior-head [CI run 44106433610](https://github.com/paperclipai/paperclip/actions/runs/44106433610) at `4ccb4ddfa5` had 58 successful checks and three skipped. Prior-head Greptile was 5/5 with no actionable findings. These results do not qualify the new head. - New-head CI and Greptile review are pending after the push; their live state is shown in this PR's checks. No repository-wide local suite, live provider run, or deployment was performed for this correction. - The previously reported CI timing failures and local dependency/native-library setup failures were resolved before the prior green CI run; no dependency or native-library change is included in this correction. ## Risks The new regression inputs are synthetic, not captured provider output. A genuine login diagnostic emitted only on a JSON-looking stdout line is excluded; stderr and failed terminal fields remain eligible. Edge/Cloudflare HTML 403 handling remains outside scope (see #21351). Plain diagnostic text remains a compatibility fallback. A new CLI output format may need a focused fixture and parser update. A genuine auth failure represented only as max-turns summary prose will retain the budget-stop classification; explicit provider fields, HTTP 401, and plain CLI login diagnostics remain recognized. Cleanup success/failure, retry eligibility, and synthetic notification handling need their own coordinated work. ## Squash merge attribution When squash-merging, retain the following trailer in the final commit message, separated from the body by a blank line. This uses [Bart's verified commit email](https://github.com/paperclipai/paperclip/pull/17229#issuecomment-7105332696), superseding the bot's suggested noreply address: ```text Co-authored-by: Bart Rozycki <contact@bartrozycki.com> ``` ## Model Used OpenAI Codex, GPT-6 family, with reasoning, repository inspection, code editing, and local test execution. The exact serving snapshot and context-window size are not exposed in this session. ## 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 and contains no internal Paperclip ticket id or instance-derived details - [ ] I have run tests locally and they pass — focused and adapter suites pass; repository-wide checks remain unqualified - [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 for `ae586d060d` - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups — pending for `ae586d060d`; prior head was 5/5 - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Bart Rozycki <bmrozycki@gmail.com> Co-authored-by: Bart Rozycki <contact@bartrozycki.com>nightly/v2026.1205.0-nightly.1 canary/v2026.1205.0-canary.898100 |
||
|
|
797680a5ff |
fix(opencode-local): keep global instructions and skill paths stable across runs (#17209)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - The `opencode_local` adapter runs each heartbeat with a runtime
OpenCode config. It copies the user OpenCode config directory into a new
`mkdtemp` directory for every run.
> - OpenCode writes the path of the global `AGENTS.md` ("Instructions
from: <path>") and the location of each config skill into the system
prompt.
> - Because the directory name is random, the system prompt is different
in every run, at about token 2,000.
> - Provider prompt caching matches a prompt prefix only. Each run
therefore pays for the full prompt again, and the model waits longer
before it answers.
> - This pull request loads the global `AGENTS.md` and the config skill
folders from the source config directory instead of copying them into
the per-run directory.
> - The benefit is a stable system prompt across runs, so providers can
reuse cached prompt tokens.
## Linked Issues or Issue Description
Refs #16678
Refs #15440
I found no issue or pull request for this problem. #16678 and #15440
also change how this adapter builds the runtime OpenCode config
(run-scoped MCP servers). They do not change the copy of `AGENTS.md` or
skills.
**What happened?**
Every `opencode_local` run with a global `~/.config/opencode/AGENTS.md`
sent a different system prompt. With OpenRouter and
`deepseek/deepseek-v4.1-flash-1017`, each run read only 1,792–2,048
cached tokens of about 48,000 prompt tokens. A short message ("halo")
took 9–20 seconds, depending on the model, and the full prompt was
billed every time.
**Expected behavior**
Two runs of the same agent with the same OpenCode config send the same
system prompt. Prompt caching then covers the system prompt.
**Steps to reproduce**
1. Put an `AGENTS.md` (and optionally a `skills/<name>/SKILL.md`) in
`~/.config/opencode`.
2. Create an agent with the `opencode_local` adapter and an OpenRouter
model that supports implicit prompt caching.
3. Run the agent twice with a short prompt.
4. Compare `cachedInputTokens` in the usage of the two runs. It stays at
about 2,000 tokens.
5. Run `XDG_CONFIG_HOME=<per-run dir> opencode debug skill` for two
per-run directories. The skill `location` contains the random
`paperclip-opencode-config-*` directory.
**Agent adapter(s) involved**
`opencode_local` (OpenCode 1.18.34; the same config keys exist in
1.19.3).
**Relevant logs or output**
System prompt layout that OpenCode sends, captured with an OpenCode
plugin that records `experimental.chat.system.transform`:
| Characters | Content | Same in each run? |
|---|---|---|
| 0–8,740 | OpenCode base prompt | Yes |
| about 8,970 | `Instructions from:
/tmp/paperclip-opencode-config-<random>/opencode/AGENTS.md` | No |
| about 13,000 to end | `<available_skills>`, with the `location` of
config skills under the same random directory | No |
## What Changed
- `packages/adapters/opencode-local/src/server/runtime-config.ts`: after
the adapter copies the source config directory, it removes the copied
`AGENTS.md` and the copied `skill`/`skills` folders from the per-run
directory. It adds the source `AGENTS.md` path to `instructions` and the
source skill folders to `skills.paths` in the runtime `opencode.json`.
Existing `instructions`, `skills.paths` and `skills.urls` values stay in
the config. The adapter adds a note to the run when it does this.
- `packages/adapters/opencode-local/src/server/runtime-config.test.ts`:
a test for two runs from the same source config: different per-run
directories, no copied `AGENTS.md` or `skills`, the same `instructions`
and `skills` values, and existing user entries kept. A test for a source
config without `AGENTS.md` or skills: the adapter does not add
`instructions` or `skills`.
## Verification
- `pnpm --filter @paperclipai/adapter-opencode-local exec vitest run`
passes (84 tests).
- `pnpm --filter @paperclipai/adapter-opencode-local exec tsc --noEmit`
passes.
- `opencode debug skill` and `opencode debug config` with a per-run
directory from this change: all 26 skills load, the config skill
`location` is the source path, and no `paperclip-opencode-config-*` path
is in the output.
- Direct `opencode run` test (DeepSeek through OpenRouter, "halo"): with
a new random config directory for each run, 0 of 6 runs read cached
tokens past 2,000. With a fixed config directory, the system prompt was
the same byte for byte in three runs.
- Self-hosted instance (Linux, systemd user unit, embedded Postgres),
one `opencode_local` agent with `deepseek/deepseek-v4.1-flash-1017`,
before and after this change:
| Run | Cached input tokens before | Cached input tokens after |
|---|---|---|
| First message of a new session | 1,792 | 1,536–1,792 |
| Second message in the same session | 1,792 | 7,680–29,978 |
The first message of a new session still reads about 1,800 cached
tokens. OpenRouter sends requests for this model to many providers, and
each provider keeps its own cache.
## Risks
- Low. Remote execution targets do not use this code path. Configs
without a global `AGENTS.md` or config skills do not change.
- Behavior shift: OpenCode now loads the global `AGENTS.md` through
`instructions`. It is the first entry, before other configured
instructions. The text in the prompt is the same. Only the path in
"Instructions from" changes to the source path.
- The run reads `AGENTS.md` and the config skills from the source
directory, not from a copy. The adapter does not change these files.
- `skills.paths` must be a supported OpenCode config key. OpenCode
1.18.34 and 1.19.3 support it.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`), via Claude Code CLI, with tool
use (file edits, shell, test runs) and extended reasoning. A human
reviewed the diff.
## 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
- [ ] 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
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com>
|
||
|
|
d1cdd217a2 |
fix(adapter-utils): give hermes_local real session-rotation thresholds (#17199)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - It keeps a session for each agent. Some agents use the same session
for many runs.
> - The session compaction feature rotates a session when it grows too
large.
> - The rotation function asks the adapter registry for a limit for each
adapter type.
> - The registry gave hermes_local a policy where all limits were 0.
> - The function read those 0 values and decided that no limit exists.
It never rotates.
> - So a new hermes agent starts with no rotation limit unless someone
adds a manual override.
> - hermes does not compress its own context well on large sessions. Its
compression stops.
> - A stalled compression uses half of the run budget and the run then
fails.
> - This pull request gives hermes_local its own rotation policy with
real limits.
> - The benefit is that every new hermes agent is protected by default.
## Linked Issues or Issue Description
No public GitHub issue exists for this defect. This is the defect
report.
**What happened?**
The registry marks `hermes_local` as `nativeContextManagement:
"confirmed"`. It gives the type `ADAPTER_MANAGED_SESSION_POLICY`. Every
limit in that policy is 0. The function
`hasSessionCompactionThresholds()` returns false for it. The server then
never rotates the session.
**Expected behavior**
A new `hermes_local` agent should start with working rotation limits. A
developer should not need to add
`runtimeConfig.heartbeat.sessionCompaction` to each agent by hand.
**Steps to reproduce**
1. Create an agent with adapter `hermes_local`. Do not set any session
policy.
2. Call `resolveSessionCompactionPolicy("hermes_local", undefined)`.
3. Read `hasSessionCompactionThresholds(result.policy)`.
4. The result is `false`. The server returns `rotate: false` on every
wake.
**Agent adapter(s) involved**
`hermes_local`. The change does not affect `claude_local`,
`codex_local`, or `acpx_local`.
**Relevant logs or output**
hermes reports this in its own log:
```
run_agent: Context compression made no progress for 300.0s (total wait 300.0s, ceiling 600.0s); continuing without compression
```
The session row records the same event:
```
compression_failure_error: backoff:stall_interrupted:strategy=lean:msgs=1297:tokens=346650
```
On one measured fleet, 52 unarchived hermes sessions reached 400 or more
messages. They hold 33,894 messages and 854,572,069 cumulative input
tokens.
**Additional context**
On that fleet, agents that have a manual override rotate correctly
today. This change only protects agents that are created after it lands.
## What Changed
- Add `HERMES_SESSION_COMPACTION_POLICY` to
`packages/adapter-utils/src/session-compaction.ts`.
- Point
`ADAPTER_SESSION_MANAGEMENT.hermes_local.defaultSessionCompaction` at
that policy.
- Add a test file with four cases. It covers the default, the other
adapters, an agent override, and a full opt out.
The new policy is:
```ts
const HERMES_SESSION_COMPACTION_POLICY: SessionCompactionPolicy = {
enabled: true,
maxSessionRuns: 12,
maxRawInputTokens: 500_000,
maxSessionAgeHours: 168,
};
```
`maxSessionRuns` and `maxSessionAgeHours` work together across cadences.
An agent that runs about four times a day reaches 12 runs in about three
days. A daily agent reaches the 168 hour limit first.
`maxRawInputTokens` compares only the latest run. For hermes it is a
backstop. `maxSessionRuns` is the limit that acts first.
## Verification
Run these commands from the repository root.
```bash
pnpm install --frozen-lockfile
pnpm --filter @paperclipai/plugin-sdk build
npx tsc --noEmit -p packages/adapter-utils
npx vitest run packages/adapter-utils/src/__tests__/session-compaction.test.ts \
packages/shared/src/validators/adapter-registry.test.ts \
server/src/__tests__/adapter-registry.test.ts
```
Results on master at commit `043f2514e`:
| Check | Result |
| --- | --- |
| `tsc --noEmit` in `packages/adapter-utils` | clean |
| `packages/adapter-utils/src/__tests__/session-compaction.test.ts` | 4
passed |
| `server/src/__tests__/adapter-registry.test.ts` | 33 passed |
| `packages/shared/src/validators/adapter-registry.test.ts` | 4 passed |
CI runs the full suite. It uses `pnpm test:run:general`, the serialized
server shards, `typecheck:build-gaps`, `build`, and the end to end
tests.
One test fails in the sandbox. It is
`heartbeat-workspace-session.test.ts` →
`assertGitWorktreeBaseWorkspaceReady` → `marks a proven non-Git local
path as an owner configuration conflict without changing the failure`.
The same test fails on unmodified master. It does not relate to this
change.
## Risks
The change is low risk. It does not alter a shared default.
- Only `hermes_local` changes. The shared
`ADAPTER_MANAGED_SESSION_POLICY` is unchanged.
- A hermes agent that runs about four times a day rotates after about
three days. Its context is then rebuilt from a handoff note.
- Any agent can still set `runtimeConfig.heartbeat.sessionCompaction`
and override the policy.
- Any agent can set `enabled: false` and stop rotation.
- There is no migration. No stored data changes.
Reviewers should compare this change with PR 3905. That PR is open. It
sets limits for `codex_local`. It edits the same file. The two changes
touch different adapter keys.
## Model Used
The original fix was written with Anthropic Claude Opus 4.8. It used a
1M context window.
The change was later moved onto current master by an OpenClaw agent
runtime. That runtime used the model `minimax-portal/MiniMax-M3`. It
used shell access, git, the GitHub API, and the test runner. It did not
use a separate reasoning mode.
## Related and Prior Work
- PR 3905 is open. It sets limits for `codex_local`. This change does
the same job for `hermes_local`.
- PR 7902 is closed. It tried to stop unbounded session growth in the
shared policy. That approach would rotate adapters that compress
correctly. This change gives hermes its own policy instead.
## 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
- [ ] 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
- [ ] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: ruai-engineering-lead <engineering-lead@ruah.innovations>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Head of Engineering <engineering@ruah-innovations.local>
|
||
|
|
d9ce549dd2 |
docs: fix OpenClaw onboarding to use the invite-prompt CLI (#17178)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Operators connect outside agents, such as OpenClaw, through the
`openclaw_gateway` adapter
> - `doc/OPENCLAW_ONBOARDING.md` is the checklist for that setup
> - Step 4 tells the reader to click "Generate OpenClaw Invite Prompt"
in company settings
> - That control does not exist in the current UI, so the checklist
cannot be completed as written
> - The `openclaw/invite-prompt` route and the `paperclipai openclaw
invite-prompt` command still work
> - This pull request moves the checklist to the CLI command and the
route
> - The benefit is that an operator can complete the OpenClaw setup by
following the document
## Linked Issues or Issue Description
**Issue type**
Outdated documentation
**Where is the issue?**
`doc/OPENCLAW_ONBOARDING.md`, steps 3 and 4.
**What's wrong?**
Step 4 says to click `Generate OpenClaw Invite Prompt` in the Invites
section of `/CLA/company/settings`. Company settings has no Invites
section. The Invites tab on the access page creates human invites only
(`allowedJoinTypes: "human"` in `InvitesSection.tsx`).
`createOpenClawInvitePrompt` in `ui/src/api/access.ts` has no caller
outside a test mock. The new-agent picker hides `openclaw_gateway`
(`comingSoon: true` in `adapter-display-registry.ts`). A reader who
follows the document cannot create the invite.
**Suggested fix**
Create the invite with `paperclipai openclaw invite-prompt`, or call the
route directly.
## What Changed
- Replace step 3 (open company settings) with a command that lists
company ids
- Replace the button steps in step 4 with the `paperclipai openclaw
invite-prompt` command and the equivalent route
- Say where the prompt text is: `onboardingTextUrl`, or `inviteMessage`
when it is set
## Verification
I ran each step against a local instance on current `master`
(`043f251`):
- `pnpm paperclipai company list --json` returns the company id
- `pnpm paperclipai openclaw invite-prompt --company-id <id>
--payload-json '{}' --json` returns an invite with `allowedJoinTypes:
"agent"`, `onboardingTextUrl` and `inviteMessage`
- `onboardingTextUrl` returns the agent onboarding text
- In the browser, company settings and the access page have no OpenClaw
invite control, and `openclaw_gateway` is absent from the new-agent
adapter list
This is a documentation-only change. I ran no automated tests.
## Risks
Low risk. One Markdown file changes. No code, API or UI behavior
changes.
## Model Used
- Provider: Anthropic
- Model: Claude Sonnet 5.5 (`claude-sonnet-5-5`)
- Tool use and code execution through Claude Code. A human directed and
reviewed 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
- [ ] I have run tests locally and they pass
- [ ] 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
---------
Co-authored-by: RouterGlock <RouterGlock@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
|
||
|
|
26cff7ebf4 |
fix(plugins): record webhook deliveries whose body holds NUL (#16985)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Plugins receive inbound webhooks on `POST
/api/plugins/:pluginId/webhooks/:endpointKey`
> - The route records each delivery in `plugin_webhook_deliveries`
before it calls the worker
> - The row keeps the parsed body and the headers in jsonb columns
> - PostgreSQL refuses a jsonb value that holds U+0000 or an unpaired
UTF-16 surrogate (22P05 "unsupported Unicode escape sequence")
> - So a delivery whose body has a NUL fails at the insert. No row is
written, the worker is not called, and the sender gets a 500 and retries
into the same failure
> - This pull request stores a jsonb-safe copy of the body and headers,
and gives the worker the request as sent
> - The benefit is that such a delivery is recorded and handled
## Linked Issues or Issue Description
**What happened?**
A plugin webhook delivery whose JSON body held `\^@` failed with
`PostgresError: unsupported Unicode escape sequence` (code 22P05) at
`insert into "plugin_webhook_deliveries"`. The route answered 500 and
did not call the worker. A provider that retries on 5xx sent the same
delivery again, and it failed again.
**Expected behavior**
The route records the delivery, calls the worker with the body as sent,
and answers 200.
**Steps to reproduce**
1. Install a plugin that has the `webhooks.receive` capability and
declares a webhook endpoint.
2. Send `{"text":"a\^@b"}` with `Content-Type: application/json` to
`POST /api/plugins/<pluginId>/webhooks/<endpointKey>`.
3. The answer is 500, and `plugin_webhook_deliveries` has no row for the
delivery.
**Paperclip version or commit**
`master` at
|
||
|
|
921d51d877 |
fix(server): allow plugin managed-agent instructions on a pending-approval agent (#16951)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Plugins can declare managed agents. The server creates them in `server/src/services/plugin-managed-agents.ts`. > - A company can require board approval for new agents. A new agent then starts as `pending_approval`. A `hire_agent` approval must appear in the board inbox. > - A managed agent can declare `instructions`. The host writes those files and updates the agent `adapterConfig`. > - That update runs on a `pending_approval` agent. The agent update path refuses it with HTTP 409 (`pending_approval_agent_config_frozen`). > - The error stops `createManagedAgent` before it creates the approval and the plugin binding. The agent is stuck. The board has nothing to approve. > - This pull request passes `allowPendingApprovalConfigUpdate: true` for that one update. Other instruction and skill materialization paths already do this. > - The benefit is that a managed agent with declared instructions gets its approval and its binding when the company requires board approval. ## Linked Issues or Issue Description Refs #11635. That pull request fixed the same root cause. Its author is @StartupMill. A triage bot closed it as stale on 2026-10-14. It was never merged. The defect is still present on `master` at |
||
|
|
75b22e264d |
fix(ui): honor Project visibility on Kanban cards (#16714)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - People use task collections to track work across projects. > - The collection has a Project visibility setting and a Kanban view. > - The list reads that setting, but board cards receive neither the setting nor the project metadata. > - This pull request passes the existing preference and project map to the board and its drag preview. > - The benefit is that people see each known project's name and color on the board when they enable Project. ## Linked Issues or Issue Description Related prior work: #3686 by @levineam and #7243 by @cassioln. Both PRs are closed without a merge. Thank you to both authors for the earlier work on project metadata in board cards. I searched open and closed PRs and issues before starting this focused follow-up. **What happened?** In the task board, enabling Project in the Columns menu does not show the project on any card. The collection reads the saved preference for list rows, but does not pass it or its existing project map to `KanbanBoard`. **Expected behavior** A card shows its known project's name and color when Project is enabled. Disabling Project hides the badge. Regular cards, compact cards, and the drag preview use the same setting. A long name stays inside the card and keeps its full text in the title. A task with no known project has no badge. **Steps to reproduce** 1. Create a project and a task in that project. 2. Open the Tasks collection and select board view. 3. Open Columns and enable Project. 4. Check the task card. On `master`, it still shows no project. ## What Changed - Pass the saved Project visibility setting and the existing project map from the collection to the board. Both the streamlined and the legacy collection do this. - Show a token-styled badge with the project color, a truncated name, and the full name in its title. Use it in regular cards, compact cards, and the drag preview. - Cover saved enabled and disabled preferences in both collections, badge color, unknown or unset projects, neutral color fallback, long names, and drag-preview visibility in component tests. - Add three Storybook fixture states. Scope update (2026-11-11): the branch is rebuilt as one commit on current `master` (`14cb692`). Earlier revisions also carried shared CI repairs (CLI startup deadline, legacy heartbeat cleanup handoff, and a scheduled-retry test wait). Those changes are not part of this fix and are removed from this PR. The feature-map paragraph is removed too, because routine fixes leave the maps unchanged. `doc/SPEC-implementation.md` no longer exists on `master` (#20565), so the spec paragraph is removed too. ## Verification Run in a clean Node 24.22 container with `pnpm install --frozen-lockfile`, on `9d3d138`. The current head `ed05687` only removes the feature-map paragraph from that revision: - `cd ui && vitest run src/components/KanbanBoard.test.tsx src/components/IssuesList.test.tsx src/components/IssueColumns.test.tsx --maxWorkers=1` — 3 files, 103 tests passed. - `pnpm --filter @paperclipai/ui typecheck` — passed. - `pnpm check:token-gates`, `node scripts/check-maps.mjs`, `node scripts/storybook-catalog.mjs --check`, and `git diff --check` — passed. The feature map is unchanged on the current head, per `rules/feature-map-scope.mdc`. - Storybook states: `product-kanban-projects--project-enabled`, `product-kanban-projects--compact-cards`, and `product-kanban-projects--project-disabled`. These use fixtures and do not prove live API access or navigation. - Earlier revisions recorded a red-before-fix run: the component suites failed on missing project badges and missing board props before the implementation. - Full GitHub CI passed on head `ed05687`. ## Risks - Low risk. The change adds an optional badge row to each board card. - Long names truncate. The badge uses the existing neutral badge tokens. Missing project metadata produces no badge. - The API, stored preferences, task mutations, and drag target logic stay the same. ## Model Used - Original change: OpenAI Codex, GPT-based agent, with repository search, code editing, and code execution. The runtime did not expose the exact model ID. - Rebase onto current `master`, scope cleanup, and the legacy-collection follow-up: Anthropic Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and code execution. ## Merge Attribution If squash-merging, retain these trailers in the squash commit body: ```text Co-Authored-By: Codex <codex@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> ``` ## 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 (head |
||
|
|
9f4562f076 |
fix(claude-local): list Claude Haiku 5.5 in the model catalog (#16708)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - The `claude_local` adapter owns the Claude Code model list that `GET
/api/companies/{companyId}/adapters/claude_local/models` returns.
> - That list includes Claude Opus 5.5 and Claude Sonnet 5.5, but the
newest Haiku entry is still Claude Haiku 4.5.
> - Claude Code 2.1.293 added `claude-haiku-5-5`. Operators on a current
CLI cannot select it in the agent model picker.
> - This pull request adds Claude Haiku 5.5 to the direct catalog and to
the Bedrock catalog, in the same family order as the other 5.5 models.
> - Haiku 5.5 needs Claude Code 2.1.293 or later. Haiku models still do
not take a reasoning effort.
> - The benefit is that the model picker can offer Claude Haiku 5.5
without a catalog redesign.
## Linked Issues or Issue Description
Fixes #16637
Refs #16660. That open pull request also inserts this model ID, but it
replaces the hardcoded catalog with an operator-editable catalog. This
pull request only adds the missing model to the catalog that ships
today.
Refs #14038. Haiku models still return no reasoning-effort choices. This
change does not alter that behavior.
## What Changed
- Added `claude-haiku-5-5` ("Claude Haiku 5.5") to the `claude_local`
model list, after Sonnet 5.5. Moved `claude-haiku-4-5` into the older
Haiku group.
- Added the dateless Bedrock ID `us.anthropic.claude-haiku-5-5`
("Bedrock Haiku 5.5"). The Anthropic Bedrock model ID is
`anthropic.claude-haiku-5-5`.
- Required Claude Code 2.1.293 or later before a CLI run or environment
test uses Haiku 5.5. Documented that minimum in the adapter
configuration notes.
- Left reasoning effort empty for Haiku 5.5, matching Haiku 4.5.
## Verification
- `pnpm exec vitest run --config vitest.config.ts src/index.test.ts
src/server/model-order.test.ts src/server/execute.remote.test.ts
src/server/test.remote.test.ts src/server/test.probe.test.ts` in
`packages/adapters/claude-local` (72 passed).
- `pnpm exec vitest run --config vitest.config.ts
src/__tests__/adapter-models.test.ts` in `server` (28 passed).
- `pnpm exec vitest run --config vitest.config.ts
src/lib/agent-setup-fields.test.ts
src/components/task-chat/composer-run-settings.test.ts` in `ui` (6
passed).
- With no Anthropic API key, the `claude_local` model list includes `{
id: "claude-haiku-5-5", label: "Claude Haiku 5.5" }` ahead of
`claude-haiku-4-5`.
- In Bedrock mode, the list includes `us.anthropic.claude-haiku-5-5` and
does not include the direct ID `claude-haiku-5-5`.
## Risks
Low risk. The new ID is additive. Existing Haiku 4.5 agents keep that
model. A CLI older than 2.1.293 fails the existing version check before
launch when Haiku 5.5 is selected. `ROADMAP.md` does not plan this
catalog entry.
## Model Used
Grok 4.7 from SpaceXAI. Tool use for repository search, tests, and the
pull request.
## 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: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com>
canary/v2026.1205.0-canary.897400
|
||
|
|
957565529c |
fix(server): detach open conversations before deleting an agent (#16706)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - A board member can delete an agent through `DELETE /api/agents/:id`. > - Deletion clears the assignee and the creator on the agent's issues before it clears the conversation. > - An open conversation must keep the same agent in the assignee field and the conversation field. > - The database check fails, the transaction rolls back, and the caller receives HTTP 500. > - This pull request clears the conversation and the assignee in one update, then clears the other issue links. > - The agent row can be deleted. The conversation issue remains as a normal task. ## Linked Issues or Issue Description Fixes #16703. I searched open and merged pull requests for this delete path. No pull request already changes conversation identity during agent deletion. Refs #9186. Refs #3878. Those issues fail on `cost_events`, not on the conversation check. This pull request does not change that path. **What happened?** `DELETE /api/agents/:id` returns HTTP 500 when the agent still has an open conversation. The agent and the conversation remain. **Expected behavior** The delete removes the agent. The open conversation is detached first, so the conversation check stays valid. **Steps to reproduce** 1. Create an agent and start a chat, so the agent has a conversation issue. 2. Pause the agent and wait until nothing is running. 3. Terminate the agent, then call `DELETE /api/agents/{agentId}` as board. **Paperclip version** Reproduced from the report on 2026.1001.0 and 2026.1005.0. The same check is present on current `master`. **Deployment mode** Local. ## What Changed - Clear `conversationAgentId`, `conversationUserId`, `conversationState`, and `assigneeAgentId` together when the conversation belongs to the agent being deleted. - Keep the later update that clears assignee and creator on every other issue for that agent. - Add a lifecycle test for an open conversation and a normal assigned task. - No documentation change. The public delete route stays the same. ## Verification - Command: `pnpm exec vitest run --config vitest.config.ts src/modules/agent-lifecycle/__tests__/lifecycle.test.ts` - Result: 50 passed. - The new test fails on the previous update with `issues_conversation_identity_check`. - With this change, the agent row is gone and both issues remain with a null assignee and a null conversation identity. ## Risks Low risk. The new update runs only for issues whose conversation agent is the agent being deleted. Issue status does not change. Cost-event delete failures in #9186 and #3878 remain open. > 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 Grok 4.7 from SpaceXAI. The model used tool calls to read the repository, run the lifecycle tests, and write this patch. ## 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 |
||
|
|
7bbc35274a |
fix(server): disposition-repair instruction asks owners to continue unblocked work (#16598)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - When an owner's run ends without a recorded disposition, Paperclip sends a disposition-repair wake with an instruction > - The legacy instruction only asks the owner to record a disposition, and owners tend to read it as "recovery only, do no work" > - They then end the repair run with the issue unchanged, the repair attempts run out, and the issue escalates to the board even though the work could simply continue > - This pull request adds one sentence: continue unfinished, unblocked work in the run, then record the disposition > - The benefit is fewer escalations and fewer empty repair runs ## Linked Issues or Issue Description **What happened?** Owners woken by a disposition-repair wake did no work, ended with the same state, and exhausted the repair attempts, so the issue escalated to the board. **Expected behavior** An owner with unfinished work and no blocker continues the work in the repair run, then records a disposition. **Steps to reproduce** 1. Let an owner run end `in_progress` without a disposition while work remains. 2. Observe the disposition-repair wake and its instruction. 3. The owner records nothing new; after the attempts run out, the issue escalates. **Paperclip version or commit** `master`; also v2026.1012.0. Refs #16388. That change addresses original-owner repair instructions. This change clarifies continuation during disposition repair. ## What Changed - Keep the existing continuation instruction. The current review has no code findings. - Refresh the contribution template and repeat the focused instruction checks. ## Verification - Focused tests: **2 passed**. - Run `pnpm --filter @paperclipai/server exec vitest run src/services/recovery/legacy-continuation-instruction.test.ts --maxWorkers 1`. - Worker verification used Node 24 and local workspace source aliases. - Full repository typecheck, tests, and build were not run. The remote build host was unavailable. - CI and Greptile must verify the updated head after the push. ## Risks - The instruction can affect how an agent interprets a repair wake. - The runtime authorization and issue state rules remain unchanged. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`, 1M context) in Claude Code, with tool use (code search, shell, test runs). - Review fixes: OpenAI Codex, `gpt-6.1-sol`, with code search, shell execution, and test execution. - The review adapter does not expose its context window size. ## 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 --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Owner·paperclip <owner-paperclip@users.noreply.github.com> Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
2e99edf825 |
fix(adapter-utils): allow summary slot callbacks from sandboxes (#16535)
## Thinking Path > - Paperclip manages work for companies of AI agents. > - Remote agents use the sandbox callback bridge to reach the controller. > - The built-in Summarizer reads and writes summary slots through that bridge. > - The server and bundled skill already provide these routes. > - The default bridge allowlist rejects all three documented requests. > - This change admits the exact methods and paths, so remote summaries can reach the existing server checks. ## Linked Issues or Issue Description - Fixes: [#16481](https://github.com/paperclipai/paperclip/issues/16481). - Related: [#16534](https://github.com/paperclipai/paperclip/pull/16534) adds a labels read route in the same allowlist. [#14533](https://github.com/paperclipai/paperclip/pull/14533) changes SSH attachment queue reads. Neither adds summary-slot routes. - Related: [#11682](https://github.com/paperclipai/paperclip/pull/11682) adds routine refresh behavior on the server. This change does not include that work. ## What Changed - Add only GET slot, GET slot revisions, and PUT slot to the shared default allowlist. Each pattern matches the full path. - Test all three requests through the file queue. Check that the method, path, query, and JSON body reach the handler. Check that a controller 403 response stays a 403 response. - Add allowlist checks for both transports and rejection checks for wrong methods, missing or extra path segments, similar resource names, and the board-only generate action. ## Verification - On base `185483e0909246b4609980a0e6e7ad3b8dbad1ba`, the new regressions fail: all three queue requests return 403 instead of 200. The allowlist assertion also fails (4 failed). - PASS: `pnpm exec vitest run packages/adapter-utils/src/sandbox-callback-bridge.test.ts packages/adapter-utils/src/http2-bridge-server.test.ts packages/adapter-utils/src/sandbox-callback-bridge-body.test.ts packages/adapter-utils/src/execution-target.test.ts` (162 passed). - PASS: `PAPERCLIP_ENABLE_DARWIN_SSH_ENV_LAB=1 pnpm exec vitest run packages/adapter-utils/src/ssh-fixture.test.ts` (25 passed, no skips). - PASS: `pnpm exec vitest run server/src/__tests__/summary-slot-routes.test.ts server/src/__tests__/summary-slots.test.ts` (31 passed, no skips). These tests use the existing routes and an isolated PostgreSQL database. They cover company access, board write denial, non-Summarizer denial, and generation task/run checks. - PASS: `pnpm --filter @paperclipai/adapter-utils typecheck`, `pnpm --filter @paperclipai/adapter-utils build`, and `git diff --check`. - Local environment: macOS ARM64, Node 26.11.1, pnpm 9.15.4. The first server test attempt could not load the plugin SDK. Building the existing shared/plugin SDK packages resolved that setup failure. One new mock-call assertion also needed correction because the handler receives a second context argument; the tests then passed. - BLOCKED: `pnpm -r typecheck` stops at missing Node types in an uninstalled workspace. `pnpm test:run` and `pnpm build` stop in preflight because the CLI workspace's `tsx` is not installed. Their full test/build bodies did not run. Only the server dependency closure was installed in this isolated worktree. Disk space was limited and Rust/cargo was unavailable. - NOT_RUN: a model-driven SSH Summarizer run against a real Paperclip instance, full repository gates, PR CI, and Greptile. The queue handler's test 403 proves response forwarding; it does not prove controller authorization. The server tests provide separate authorization evidence. ## Risks - The bridge now admits three existing summary-slot operations. Server company access, the summaries feature flag, and the Summarizer task/run write checks remain in force. - No schema or request contract changes. POST generate and unrelated routes stay denied. A real SSH Summarizer run and full CI remain acceptance limits. ## Model Used - OpenAI Codex, `gpt-6.1-sol`, `xhigh` reasoning, for implementation and validation. Read-only assistants used OpenAI `gpt-6-luna` with `max` reasoning for upstream checks, source inspection, and independent review. A browser assistant used OpenAI `gpt-6.1-sol` with `medium` reasoning to prepare the review page. Tools included shell execution, Git/GitHub APIs, Vitest, TypeScript, and browser interaction. The context window size is not exposed by this session. ## 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 linked existing issues or described the issue in-PR - [x] I have not referenced internal/instance-local Paperclip issues or links - [x] My branch name describes the change and contains no internal Paperclip ticket id - [x] I have run the listed targeted tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have checked the existing API/skill documentation; no request contract changed - [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 |
||
|
|
a072b17067 |
fix(cli): warn when run list stops at the server page cap (#16533)
## Thinking Path > - Bounding run history gave `GET /api/companies/:companyId/heartbeat-runs` a default page of 200 runs and a ceiling of 1,000, with no offset parameter and no truncation signal in the response. > - `paperclipai run list` sends `limit` only when `--limit` is passed, makes one request, and the HTTP client returns only the parsed body. So the command prints the newest 200 runs and stops, with no notice — and `--limit 5000` silently stops at 1,000 the same way. > - The issue's expected behavior is that the command either returns every run or says that it did not. > - Returning every run needs server work that is already scoped in open issue #14958 (an `offset` parameter plus `X-Result-Truncated` / `X-Total-Count` headers, and a client that surfaces headers). That is not this PR. > - What the CLI can do today: tell the truth. State the default and the ceiling in the help text, and when a page comes back exactly full — the only truncation sign the current route gives — say on stderr that more runs may exist. ## Linked Issues Fixes #16413 Refs #14958 ## What Changed - `cli/src/commands/client/run.ts`: the `run list` `--limit` help now reads "Maximum runs to return (server default 200, max 1000)", using the shared `HEARTBEAT_RUN_LIST_DEFAULT_LIMIT` / `HEARTBEAT_RUN_LIST_MAX_LIMIT` constants so the text cannot drift from the server values. - Same file: after printing, when the returned row count reaches the effective limit (the requested limit clamped to the server ceiling, or the 200 default), the command prints a notice on stderr: how many runs are shown, the cap that applied, that more runs may exist, and to raise `--limit` to see more. stderr keeps `--json` output on stdout clean and machine-readable. - Tests in `cli/src/__tests__/run.test.ts`: a full 200-row default page triggers exactly one stderr notice and sends no `limit` parameter; a partial page under `--limit 25` stays quiet. ## Verification - `vitest run src/__tests__/run.test.ts` — 5 of 5 pass, including the pre-existing run command tests (request shapes unchanged: no `limit` is sent unless `--limit` is passed). - Disclosure: the CLI package typecheck did not complete in my sandbox (the checker process is very slow against the shared package surface here and was cut off); CI runs the CLI typecheck and is the arbiter. The change uses two constants that are exported from `@paperclipai/shared` today and already imported the same way elsewhere. ## Risks - A company with exactly 200 (or exactly `--limit`) runs gets the notice even though nothing was hidden. The wording says more runs *may* exist, which is the strongest claim the current route supports; #14958's headers will let a later change make it exact. - This PR deliberately does not page or raise the default page size: the server bound exists to keep run-history reads cheap, and silently requesting 1,000 by default would change the command's cost profile for every user. Full retrieval lands with #14958. ## Model Used - **Provider / Model ID:** Meta, Muse Spark 1.3 - **Context window:** 1M+ tokens (exact limit not disclosed); large-repository tasks with long tool transcripts - **Capabilities:** agentic coding with tool use — file editing, shell execution, test execution, browser and API access, multi-step planning ## 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) - [ ] 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 - [ ] 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 --------- Signed-off-by: Josh Cox <joshuacox@users.noreply.github.com> Co-authored-by: Review <review@local> |
||
|
|
599867caac |
fix(recovery): wake the target when a quota monitor's retry is exhausted (#16199)
## 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 |
||
|
|
eb35831f05 |
Add first-class SpreadJam and Okara remote MCP connectors (#23859)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The Apps catalog ships first-class connectors for external services so teams can connect tools with verified endpoints, brand icons, permission reviews, and guided sign-in > - SpreadJam and Okara both publish official hosted remote MCP servers with OAuth discovery and dynamic client registration, so users currently fall back to unverified custom MCP entries without brand assets, scope defaults, or reviewed risk policies > - Adding catalog definitions with conservative risk classification, drift quarantine, and Ask-first defaults lets users discover both apps in the gallery and connect safely without unreviewed write/destructive actions auto-enabling > - This pull request adds first-class remote MCP connectors for SpreadJam (`https://api.spreadjam.com/mcp`) and Okara (`https://okara.ai/api/mcp`) with official brand SVGs, reviewed permission entries, reviewed tool risk + drift policies, Ask-first defaults for write/destructive actions, unit + fresh-OAuth server tests, and refreshed SDK public inputs > - The benefit is a guided connection flow with official branding, safer default OAuth scopes for Okara, optional project pinning and API-key support for SpreadJam, Ask-first approval on write/destructive tools, drift quarantine on catalog refresh, and automatic BYO URL recognition ## Linked Issues or Issue Description **Subsystem affected** Cross-cutting (packages/shared, server, ui, doc/connections) **Problem or motivation** Users connecting SpreadJam (`https://api.spreadjam.com/mcp`) or Okara (`https://okara.ai/api/mcp`) must configure them as unverified custom MCP servers. They get no official brand icon, no catalog entry, no curated permission review, no Okara default scope restriction (`mcp:read`, `mcp:write`), no SpreadJam `X-Jam-Project` or workspace API key setup guidance, and no reviewed risk classification or drift quarantine. **Proposed solution** Add both SpreadJam and Okara as first-class Track A remote MCP connectors in the Paperclip Apps catalog: - Register `spreadjam` with DCR OAuth (`dcr`) and workspace API key (`customer`, `Authorization: Bearer sk_...`) methods, optional `projectId` header pinning (`X-Jam-Project`), default agent instructions, verified `reviewedTools` (against `https://api.spreadjam.com/openapi.json`) with `quarantineNewEntries: true`, and official SVG branding. - Register `okara` with DCR OAuth (`dcr`) requesting `mcp:read` and `mcp:write` by default (omitting `mcp:publish` and `mcp:spend`), conservative `okaraRisk` classification with `quarantineNewEntries: true` in `connectorToolPolicy`, and official light and dark SVG branding. - Require Ask-first approval by default for `write` and `destructive` actions on fresh SpreadJam and Okara connections via `recommendedDefaultsForApp`, keeping read tools immediately usable. - Register permission reviews, manifest entries, generated catalog output, shared/server tests, and `source-sdk-public-inputs.json`. **Alternatives considered** Leaving both servers as custom BYO MCP connections was considered. Custom connections work after #23846, but they cannot provide curated brand assets, verified gallery placement, Okara's read/draft scope guardrails, reviewed tool risk + Ask-first defaults, or SpreadJam's `X-Jam-Project` pinning and API-key flow. **Roadmap alignment** Extends the existing declarative Track A remote MCP Apps catalog (`packages/shared/src/app-definitions/`) and connector risk policy registry (`server/src/services/connectors/`). Does not duplicate or alter planned core architecture in `ROADMAP.md`. **Additional context** Follows up on #23846, which improved custom remote MCP discovery and recovery. ## What Changed - Added SpreadJam connector override and generated definition (`scripts/app-definition-overrides/spreadjam.json`, `packages/shared/src/app-definitions/spreadjam.json`) for `https://api.spreadjam.com/mcp` with `mcp-oauth` (`dcr`), `mcp-api-key` (`customer`, Bearer `sk_...`), optional `X-Jam-Project` tenant header pinning, `spreadjam-default-v1` agent instructions, and `reviewedTools` (42 verified `GET` reads, 26 verified delete/publish/PR/credit-spending/billing-allocation destructive ops, `unlisted: "write"`, `quarantineNewEntries: true`). - Added Okara connector override and generated definition (`scripts/app-definition-overrides/okara.json`, `packages/shared/src/app-definitions/okara.json`) for `https://okara.ai/api/mcp` with `mcp-oauth` (`dcr`) and default `scopesHint: ["mcp:read", "mcp:write"]` (`Read and draft` capability profile, withholding `mcp:publish` and `mcp:spend`). - Added `server/src/services/connectors/okara/risk.ts` and registered `okara` in `server/src/services/connectors/tool-policy.ts` with `quarantineNewEntries: true` and fail-closed risk classification (only explicit `readOnlyHint: true` without destructive/write hints or verbs classifies as `read`; publish/spend/delete/launch verbs classify as `destructive`; unlisted/unannotated fail closed to `write`). - Updated `recommendedDefaultsForApp` in `packages/shared/src/app-definitions.ts` so new SpreadJam and Okara connections default to `askFirstRiskLevels: ["write", "destructive"]` while leaving read tools immediately usable. - Added verbatim official brand SVGs (`ui/public/brands/apps/spreadjam.svg`, `ui/public/brands/apps/okara.svg`, `ui/public/brands/apps/okara-dark.svg`) and registered both identities in `ui/public/brands/apps/manifest.json` without colliding with `jam-dev`'s existing `"jam"` alias. - Added reviewed method entries for `spreadjam/mcp-oauth`, `spreadjam/mcp-api-key`, and `okara/mcp-oauth` in `doc/connections/tool-method-permission-reviews.json`. - Added `"okara"` and `"spreadjam"` to `CONNECTABLE_APP_SLUGS` in `packages/shared/src/app-definitions.ts` and regenerated `packages/shared/src/app-definitions.generated.ts`. - Added unit and embedded-Postgres integration tests in `packages/shared/src/app-definitions.test.ts` and `server/src/__tests__/connector-tool-policy.test.ts` covering definitions, risk classification, fresh OAuth Ask-first policy creation, and drift quarantine on catalog refresh. - Refreshed `tests/runner-e2e/source-sdk-public-inputs.json` to match the updated shared exports. ## Verification - Brand, asset, and override validation: - `node scripts/check-app-brand-assets.mjs` (pass: 117 brand identities validated) - `node --test scripts/app-definition-overrides.test.mjs scripts/app-brand-validation.test.mjs` (pass: 16/16) - Build, typecheck, and Vitest suites: - `pnpm --filter @paperclipai/shared build && pnpm --filter @paperclipai/shared typecheck` (pass) - `pnpm --filter @paperclipai/server typecheck` (pass) - `pnpm --filter @paperclipai/ui typecheck` (pass) - `pnpm exec vitest run packages/shared/src/app-definitions.test.ts server/src/services/tool-access/oauth/client-settings.test.ts server/src/__tests__/connector-tool-policy.test.ts ui/src/pages/apps/AppsConnect.test.tsx` (pass: 4 files, 97/97 tests) - `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse HEAD) --check` (pass: `changed: false`) - Live non-registering preflight against local Paperclip dev server: - `GET /api/companies/:id/tools/apps/spreadjam/preflight` → `endpointReachable: true` (`401 application/json`), `oauth.metadataFound: true`, `oauth.registrationAdvertised: true` - `GET /api/companies/:id/tools/apps/okara/preflight` → `endpointReachable: true` (`401 application/json`), `oauth.metadataFound: true`, `oauth.registrationAdvertised: true`, `oauth.clientIdMetadataDocumentSupported: true` - Local browser verification against isolated dev server: - Verified both tiles render in the Apps gallery with official SVG logos (dark and light theme contrast verified for Okara's light/dark icons). - Verified `/apps/connect?source=spreadjam` shows no unverified badge, default agent instructions, OAuth + API key methods, and optional `Pin to project ID` field. - Verified `/apps/connect?source=okara` shows no unverified badge and clean one-click OAuth flow. - Verified BYO URL recognition (`/apps/byo?link=...`) detects and suggests guided setup for both `https://api.spreadjam.com/mcp` and `https://okara.ai/api/mcp`. ### Production Validation Matrix | Check | SpreadJam | Okara | | --- | --- | --- | | Public docs & live OAuth metadata discovery | Passed | Passed | | Non-registering Paperclip preflight endpoint | Passed | Passed | | Deterministic unit, server OAuth policy, typecheck, and brand asset checks | Passed | Passed | | Local UI gallery, connect flow, light/dark logos, and BYO recognition | Passed | Passed | | Live account-bound OAuth sign-in / tool call execution | Not run (no live user credentials provided) | Not run (no live user credentials provided) | ## Risks - Low risk: additive declarative catalog definitions, static brand SVGs, connector risk policy, tests, and generated metadata only; no database schema, migration, or generic OAuth runtime changes. - Live account-bound OAuth consent, token exchange, and post-connect MCP tool invocation were not executed in this verification pass because no live SpreadJam or Okara account credentials were used. - SpreadJam OAuth and workspace API keys inherit the signed-in user's workspace role; new connections mitigate accidental side effects by starting write and destructive actions on Ask first and quarantining newly added tools on catalog refresh. ## Model Used - Google Antigravity (`gemini-3-pro`, extended thinking, 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 - [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: Paperclip <noreply@paperclip.ing>canary/v2026.1205.0-canary.896800 |
||
|
|
266eccc524 |
fix(connections): improve custom remote MCP OAuth draft setup, auto-detection, and recovery UX (#23846)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - People connect external tools to agents through custom remote MCP servers in `/apps/byo` and manage them on `/apps/:id/permissions` > - Unauthenticated custom MCP OAuth drafts failed catalog reads with `oauth_refresh_missing`, displayed as `Paused`, and left operators on a dead-end `Retry` error screen with no sign-in, auth-method switch, or remove controls > - The `/apps/byo` setup flow also lacked upfront read-only auth detection, display-name editing, custom draft resume, and detached-tab OAuth completion polling > - Custom remote MCP servers must work smoothly out of the box without dead ends or manual trial-and-error > - This pull request fixes backend OAuth draft/catalog truthfulness, adds a read-only custom MCP auto-detection probe, adds dedicated draft setup and error recovery on `AppDetail`, and improves `/apps/byo` auto-detection, resume, and OAuth waiting UX > - The benefit is that operators can connect and recover any standards-compliant remote MCP server cleanly without hitting false expired-credential dead ends ## Linked Issues or Issue Description **What happened?** Opening an unauthenticated custom remote MCP OAuth draft at `/apps/:id/permissions` triggered a live remote catalog refresh that threw `422 oauth_refresh_missing` (`"OAuth credentials have expired and need to be reconnected."`), overwrote stored health to `failed`, displayed status `Paused`, and replaced the Permissions tab with a looping `Retry` box. Operators had no way to start sign-in, change the sign-in method, see OAuth callback failure details, or remove the connection. In `/apps/byo`, pasting a URL did not detect auth upfront, did not allow editing the display name, failed to resume custom MCP drafts via `?resume=<id>`, duplicated the `Unverified server` badge, and stopped polling when opening sign-in in a new tab. **Expected behavior** Unauthenticated OAuth drafts should remain readable without failing catalog reads or reporting expired credentials, show `Setup incomplete` with clear `Sign in`, `Change sign-in method`, `Remove`, and `Connection details` controls, surface OAuth callback errors inline, and keep recovery actions visible when catalog loading fails. `/apps/byo` should detect auth upfront in a read-only probe, allow naming the connection, resume custom MCP drafts cleanly, and detect OAuth completion even when sign-in opens in a new tab. **Steps to reproduce** 1. Create a custom remote MCP OAuth draft via `/apps/byo` or `POST /api/companies/:companyId/tools/apps/connect` without completing browser OAuth consent. 2. Open `/<prefix>/apps/<connectionId>/permissions`. 3. Observe `Paused` and `"Couldn't load tools for this app / OAuth credentials have expired and need to be reconnected. [Retry]"` with no sign-in or recovery controls. **Paperclip version or commit** `master` (`fd8ad7d5b8`) **Deployment mode** Local dev (pnpm dev) ## What Changed - **Backend OAuth draft & catalog truthfulness** - Export `isConnectionAwaitingFirstSignIn` in `server/src/services/tool-access/connections/first-sign-in.ts` and skip remote `refreshCatalog()` in `server/src/services/tool-access/catalog/reader.ts` when an unauthenticated OAuth draft has an empty catalog. - Distinguish never-authorized OAuth connections/grants (`422 oauth_challenge`: `"This app needs you to sign in."`) from genuinely expired tokens missing a refresh token (`422 oauth_refresh_missing`) in `server/src/services/tool-access/oauth/grant-refresh.ts` and `server/src/services/tool-access/oauth/connection-refresh.ts`. - Annotate `firstSignInPending` on `getConnection` in `server/src/services/tool-access.ts` to match `listConnections`. - **Read-only custom MCP auto-detection probe** - Add `probeGenericMcpSchema` and `GenericMcpProbeResult` in `packages/shared`, capture optional `resource_name` in `server/src/services/tool-access/oauth/discovery.ts`, implement read-only `createGenericMcpProbe` in `server/src/services/tool-access/connections/probe-mcp.ts`, expose `POST /api/companies/:companyId/tools/apps/probe-mcp` in `server/src/routes/tool-access.ts`, and add `toolsApi.probeGenericMcp` in `ui/src/api/tools.ts`. - Refresh `tests/runner-e2e/source-sdk-public-inputs.json` for the shared schema and type additions. - **App detail setup, recovery, and management UI** - Show `Setup incomplete` for draft connections in `ui/src/pages/apps/AppDetail.tsx` and `ui/src/pages/apps/Connections.tsx`. - Add `FinishSetupCard` in `AppDetail.tsx` with `Sign in` (shared, personal, and agent policies), `Change sign-in method`, inline OAuth return error recovery (`?oauth=failed|denied`), live completion polling, `Remove`, and `Connection details`. - Scope catalog fetch errors to the Actions area so `IdentitiesSection`, `ReconnectCard`, and custom MCP management (`AdvancedPanel`) stay accessible. - **BYO setup, resume, and OAuth waiting UX** - Run background read-only probing on `/apps/byo` Step 2 in `ConnectionSetupFlow.tsx` and `GenericMcpConnectStep.tsx`, add an editable Display name input, use `Server URL · Connect` for the BYO stepper, and support resuming/reconnecting custom MCP drafts via `?resume=<id>&editAuth=1`. - Remove the duplicate `Unverified server` badge and stuck disabled `Opening …` button on `OAuthConnectStateScreen`, use non-workspace copy for custom MCP servers, and keep polling connection activation after clicking `Open sign-in in a new tab`. ## Verification - Ran server and UI regression tests (183/183 passing): - `pnpm vitest run server/src/__tests__/generic-mcp-connection.test.ts server/src/__tests__/tool-access-cancelled-first-sign-in.integration.test.ts ui/src/pages/apps/AppDetail.test.tsx ui/src/features/connections/ConnectionSetupFlow.generic-mcp.test.tsx ui/src/features/connections/GenericMcpConnectStep.machine.test.tsx ui/src/pages/apps/generic-mcp-connect.test.ts` - Ran package typechecks and UI checks: - `pnpm --filter @paperclipai/shared typecheck` - `pnpm --filter @paperclipai/server typecheck` - `pnpm --filter @paperclipai/ui typecheck` - `node scripts/check-query-error-rendering.mjs` (0 findings) - `pnpm run check:token-gates` (0 violations in changed files) - Verified end-to-end locally in an isolated worktree dev server against live remote OAuth MCP endpoints for draft setup, `Change sign-in method` resume, upfront read-only auto-detection, and OAuth waiting screen. ## Risks - Low risk: existing active and expired OAuth connections keep `oauth_refresh_missing` behavior unchanged (covered by explicit regression tests). - The new `/probe-mcp` route uses the same company/management authorization guards, SSRF/private-network checks, self-loop protection, and OAuth endpoint policy as `/apps/connect`, performs zero database writes, and makes zero DCR `POST` requests. - `packages/shared` exports changed, so `tests/runner-e2e/source-sdk-public-inputs.json` was regenerated for CI. ## Model Used - Google Antigravity (`gemini-3-pro`, extended thinking, 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 mergecanary/v2026.1205.0-canary.896700 |
||
|
|
4b5000fae0 |
fix(hermes): state the enforced timeoutSec default (1800) in local adapter docs (#15936)
## Thinking Path > - Paperclip is a control plane for AI-agent companies. > - The Hermes local adapter has a `timeoutSec` run limit. > - The code sets the default in `DEFAULT_TIMEOUT_SEC`. The value is 1800. > - The UI config builder also floors `timeoutSec` at that default. A user cannot build a lower value in the UI. > - Two doc tables still state the default as 300. The README example config also uses 300. > - A user who copies the documented value gets runs killed at a wall the docs implied was normal. > - This pull request makes the three doc spots state 1800. It changes no code behavior. ## Linked Issues Fixes #15903 ## What Changed - `packages/adapters/hermes/README.md`: the Core Configuration table now states the `timeoutSec` default as `1800`. The example agent config now uses `"timeoutSec": 1800`, so the example no longer shows a value the UI builder cannot produce. - `packages/adapters/hermes/src/index.ts`: the local variant doc table now states the `timeoutSec` default as 1800. - The gateway variant docs are not touched. They state 600, and the gateway code default is 600, so they agree. ## Verification - Text check: all three local-variant spots now read 1800, and `DEFAULT_TIMEOUT_SEC` in `packages/adapters/hermes/src/shared/constants.ts` is 1800. - The Hermes entrypoint test suite passes: 8 tests, including a new guard that fails if the doc table and `DEFAULT_TIMEOUT_SEC` drift apart again. - Docs-only change; no runtime code was modified. ## Risks - None for runtime behavior. The only risk is doc drift in the other direction if the code default changes later; the constant stays the single source of truth in code. ## Model Used - **Model:** Meta Muse Spark 1.3 ## 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) - [ ] 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 --------- Signed-off-by: Josh Cox <joshuacox@users.noreply.github.com> Co-authored-by: Review <review@local> |
||
|
|
1dcab931a6 |
fix(recovery): do not cap new runs at the legacy disposition-repair allowance (#15923)
## Thinking Path > - The execution-semantics spec gives `deliberate_wait_without_target` recovery five disposition-repair attempts, with delays 0, 60, 120, 240, and 480 seconds. > - The disposition-repair module implements that schedule. A separate legacy-episode helper also exists, to protect pre-upgrade episodes that already spent attempts under an older, tighter allowance. > - The helper never answered "not a legacy episode". A run with an entirely empty context snapshot — clearly not a pre-upgrade episode — still got a legacy episode capped at 2 attempts (1 for handoff and old-recovery runs). > - The common continuation path passes that episode unconditionally, so the documented five-attempt fallback next to it was dead code for every non-native run. > - The fix makes the helper return no episode when a run has no legacy markers and has consumed no attempts. Marked or partly spent pre-upgrade runs keep the legacy cap, so no spent budget is resurrected. ## Linked Issues Fixes #15776 ## What Changed - `server/src/services/recovery/legacy-continuation.ts`: `legacyDispositionEpisode` now gives a run with no legacy markers (no persisted episode record, no handoff or old-recovery markers, no repair fingerprint, no liveness-continuation source) and no consumed attempts the documented budget, `DISPOSITION_REPAIR_MAX_ATTEMPTS` (5), instead of the legacy cap. The episode object still exists for every run, so repair dispatch keeps its persisted binding, issue state guard, and source-identity semantics. Marked or partly spent runs still derive their capped episodes, unchanged. - `server/src/services/recovery/legacy-continuation.ts`: the persisted-record branch no longer clamps every episode to the legacy cap. A record keeps the budget it was written with: records written under the legacy scheme carry at most the legacy cap and keep it, and records written under the documented scheme keep theirs. Without this, a new episode was re-capped at 2 from its second attempt on. - Tests in `legacy-continuation.test.ts`: marker-less runs derive the five-attempt budget; persisted records keep their written budget (2 stays 2, 5 stays 5); fingerprinted, liveness-sourced, and partly spent runs still derive their capped episodes. - Test updates in `legacy-continuation-authority.test.ts` and `heartbeat-process-recovery.test.ts`: expectations that pinned the old cap for marker-less runs now expect `maxAttempts: 5`; the exhaustion tests (ACCT-02, ACCT-04, and the bounded-episode test) stamp a genuine pre-upgrade episode on their source runs so they keep pinning the legacy bound. No production behavior outside the budget derivation changed for those tests. ## Verification - `vitest run server/src/services/recovery/legacy-continuation.test.ts` — 28 of 28 pass, including the existing "does not resurrect an exhausted pre-upgrade budget" cases. - CI on the final head: all checks pass (55 of 55), including the suites that pin the surrounding semantics — `legacy-continuation-authority`, `heartbeat-process-recovery`, `heartbeat-stale-queue-invalidation`, `heartbeat-slack-invitation`, `heartbeat-issue-liveness-escalation`, and the chat integration suites. - An earlier revision of this PR returned `undefined` for marker-less runs; CI showed that episode presence also drives the state guard and dispatch identity checks, so the fix was reworked to change only the budget derivation. The PR comments carry the full history. ## Risks - A run whose only history is a positive generic continuation counter stays on the legacy cap. That matches this repo's existing test expectation that a run with `continuationAttempt: 2` is an exhausted pre-upgrade episode; the counters cannot distinguish schemes, so the conservative reading wins. - Note for sequencing: open PR #15658 also touches the recovery area (owner continuation after partial work) but does not change the attempt cap, so the two changes are independent. ## Model Used - **Provider / Model ID:** Meta, Muse Spark 1.3 - **Context window:** 1M+ tokens (exact limit not disclosed); large-repository tasks with long tool transcripts - **Capabilities:** agentic coding with tool use — file editing, shell execution, test execution, browser and API access, multi-step planning ## 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) - [ ] 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 - [ ] 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 --------- Signed-off-by: Josh Cox <joshuacox@users.noreply.github.com> Co-authored-by: Review <review@local> Co-authored-by: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com> |
||
|
|
587de9420f |
fix(native-runtime): stamp attribution on cancel_continuations run cancellations (#15922)
## Thinking Path > - Native status decisions can cancel an issue's continuations. The `cancel_continuations` effect cancels queued wakes and pending interactions, then terminalises the heartbeat run. > - That run write set only `status`, `finishedAt`, and `updatedAt`. Every other run-cancellation write in the codebase also stamps an `errorCode`, a `resultJson` marker, or both. > - Recovery treats a cancelled run with no attribution as possible agent stranding. It can re-wake an agent that a status decision deliberately stopped, and there was no activity row recording the run's cancellation. > - The committer already writes an issue-level activity row for the decision itself, with actor `system` / `native-status-committer`. The fix stamps the run in the same terms and adds a run-level activity row in the same transaction. ## Linked Issues Fixes #15767 ## What Changed - `server/src/services/native-runtime/status-decision-committer.ts`: the `cancel_continuations` branch now - sets `errorCode: "native_cancelled_continuations"` and an `error` message on the run, - merges a `resultJson` marker into the run's existing result (`stopReason`, `cancelledByActorType: "system"`, `cancelledByActorId: "native-status-committer"`, and the cancelled wake-request and interaction ids), - writes a `heartbeat.cancelled` activity row for the run inside the same transaction, using the file's existing `persistActivity` helper and the same system actor the decision row uses. - New embedded-Postgres test `server/src/__tests__/native-cancel-continuations-attribution.test.ts`: seeds the native finalization graph (company, agent, issue, run, contract, result, assessment, coordinator), commits an issue-scope cancellation decision, and asserts the run's status, errorCode, error, merged resultJson, and the single `heartbeat.cancelled` activity row. ## Verification - The new test runs against embedded Postgres. The sandbox I used runs as root, and embedded Postgres refuses to start as root, so the suite self-skips there and runs in CI. - Type check: a full server `tsc` run does not fit in the memory of the sandbox I used. I ran a scoped program over the changed files instead; its errors are confined to pre-existing scoped-program artifacts in unrelated files, with none in the changed files. - The fix follows the exact field conventions of the sibling cancellation writes enumerated in the issue (the board route's `heartbeat.cancelled` activity action and the `cancelledByActorType` result marker), with the actor recorded as the system committer because no user or agent actor reaches this path. ## Risks - `cancelledByActorType: "system"` does not trip the operator stand-down in recovery, which is keyed to `user`/`board`. That is deliberate: this path is a system status decision, not an operator action, and claiming a user actor would be false attribution. The run now carries a distinct errorCode, so it no longer groups with unexplained cancellations. - The resultJson merge reads the run's current resultJson inside the same transaction before the update, so existing markers (for example native cancellation receipts) are preserved. ## Model Used - **Provider / Model ID:** Meta, Muse Spark 1.3 - **Context window:** 1M+ tokens (exact limit not disclosed); large-repository tasks with long tool transcripts - **Capabilities:** agentic coding with tool use — file editing, shell execution, test execution, browser and API access, multi-step planning ## 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) - [ ] 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 - [ ] 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 --------- Signed-off-by: Josh Cox <joshuacox@users.noreply.github.com> Co-authored-by: Review <review@local> |
||
|
|
81547e803e |
fix(server): do not re-create closed plugin session rows on run finalization (#15860)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Plugins can open agent sessions with `ctx.agents.sessions.create`, send messages to them, and end them with `ctx.agents.sessions.close`. > - Each plugin session is one `agent_task_sessions` row with the task key `plugin:<pluginKey>:session:<uuid>`. `close` deletes this row. > - The host publishes the terminal run event (`heartbeat.run.status` and the plugin `agent.run.*` event) before run finalization saves the session state. Finalization calls `upsertTaskSession`, and that function inserts a new row when no row exists. > - Thus a plugin that closes its session on the terminal event gets the row back a few milliseconds later. The closed session becomes a leaked row that nobody owns. > - This pull request makes `upsertTaskSession` update an existing plugin session row and never insert one. Only `agentSessions.create` creates these rows. > - The benefit is that `close` is final. Plugins do not need delays or cleanup jobs to remove leaked session rows. ## Linked Issues or Issue Description Refs #14143 (we found this bug while we built a Boardroom plugin for this feature request). Related: #9977 (open) adds general task-session tombstones and atomic finalization. That change is much larger and does not cover the plugin `close` path. This pull request is a small, separate fix for plugin sessions only. **What happened?** A plugin called `ctx.agents.sessions.close` when it received the terminal event of a session run. The `agent_task_sessions` row for that session came back after the delete. On a real instance, the row was re-created 5 ms after the plugin closed the session. That run was cancelled, but a "done" (succeeded) run has the same race. **Expected behavior** After `ctx.agents.sessions.close` returns, the session row stays deleted. A run that finalizes after the close does not create the row again. **Steps to reproduce** 1. Install a plugin that has the `agent.sessions.create`, `agent.sessions.send`, and `agent.sessions.close` capabilities. 2. In the plugin, create a session and send a message with `ctx.agents.sessions.sendMessage`. 3. In the `onEvent` callback, call `ctx.agents.sessions.close` when the event type is `done` or `error`. 4. Wait for the run to finish (or cancel it). 5. Query `agent_task_sessions` for the task key `plugin:<pluginKey>:session:%`. The closed session row is there again, with `last_run_id` set to the finished run. **Paperclip version** `master` atcanary/v2026.1205.0-canary.896300 |