mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-04 04:29:01 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A run in a sandbox must start its Runner before a deadline > - A startup that passes the deadline is cancelled, and its sandbox task is stopped > - The cancelled run then has no successor, so the server blocks the task > - The answers and messages that wait behind the run stay held until a person acts > - The agent did no work, so nothing needs a person > - This pull request queues the same wake again when the evidence shows that no work started > - The benefit is that a slow startup delays a task but does not block it ## Linked Issues or Issue Description No issue exists. **What happened?** A user answered an agent's question. The new run passed its startup deadline. The server stopped the sandbox task and confirmed the stop. The server then set the task to blocked, and the answer was not delivered. **Expected behavior** The server starts the run again with the same answer. It continues the saved session if that is safe. **Steps to reproduce** 1. Use an agent whose environment provider runs Runner tasks. 2. Start a run on a task. 3. Make the startup pass its deadline before the Runner connects. 4. Wait for the server to confirm the stop. 5. See that the task is blocked and that a new message stays held. **Paperclip version or commit** `dc16c47362` **Deployment mode** Self-hosted server with a sandbox environment plugin. ## What Changed - The server queues the same wake again after it confirms the stop of a startup that timed out. The new run keeps the wake reason, the comments and the answer. - The server does this only with all of this evidence: - The startup deadline is the only cause of the cancellation. - The provider confirmed that the task stopped. - No process request, session, turn, Runner checkpoint or result exists. - No workspace recovery or file copy is open. - The new run uses the existing retry limits for an interrupted preparation. - The server queues the new run before it acknowledges the cleanup. The new run cannot start until the cleanup is acknowledged. Held messages stay in order behind it. - The new run continues the saved session when the stopped task still holds the session state of an earlier run. Otherwise, it starts a new session. - If the server stops between these steps, the next cleanup pass completes them. It queues one run only. - If any evidence is missing, or the server cannot queue the run, the task is blocked as before. - A Stop by a person, a pause, a budget or a reassignment does not change. ## Verification - `npx vitest run src/services/native-runtime/native-startup-requeue.test.ts`: 46 passed. These tests use embedded Postgres. They test the full cancellation, the two server-stop points, 24 refusals, the session state transfer, and which run the next run resumes. - `npx vitest run` on the 14 test files that use the changed modules: 2146 passed, 7 skipped, 1 failed. The failed test is `archives a damaged prior epoch before completing guarded same-task replacement with real runnerd`. It also fails at `dc16c47362` on the same computer, without this change. - `npx vitest run` on the retry scheduling and early Stop tests: 79 passed. - `npx tsc --noEmit` in `server` has no errors. - Not done: a live test of this change. CI runs the Runner integration suites. ## Risks - A wrong decision could run work twice. The server refuses when any saved record shows provider work, and the resume path checks the same records again. - A startup that always times out now retries. The existing limit and backoff apply. After the last retry, the task is blocked as before. - The new run uses another sandbox start. Budget checks and retry counts apply to it as to other retries. - A task that is already blocked by this problem does not change. A person must retry it or send a message. - No migration. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code, with 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>