mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
## 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