mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 11:47:42 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Native Runner saves a question before it stops the provider turn. > - The wait must retain usage and prove shutdown before the run can finish. > - OpenCode's abort HTTP request can hold the command loop for twenty seconds. > - The transport close budget is ten seconds. A late abort can delay definitive stop and suspension beyond that budget. > - This pull request limits the cooperative abort request to five seconds. > - The benefit is time for definitive shutdown, with the same accounting and suspension checks. ## Linked Issues or Issue Description **What happened?** A saved question can be followed by a failed native run. OpenCode's cooperative abort can wait longer than the transport's shutdown budget. The shutdown commands then lack time to prove provider drain and durable suspension. A saved interaction alone cannot prove that the previous executor stopped. **Expected behavior** A stalled cooperative abort must release the command loop in time for definitive process stop. A timeout must still reject interruption. It must not create a terminal event or count as successful accounting. **Steps to reproduce** Start a controlled OpenCode session. Keep its abort HTTP request pending until its signal aborts. Request interruption. Advance the controlled clock by five seconds. On the base code, the request is still pending. With this change, the request rejects and the active turn remains recorded without a terminal event or a new model request. Related prior repairs: #20494, #20519, #20838. They address saved wait recovery. This change addresses the pending cooperative abort before definitive shutdown. ## What Changed - Give only OpenCode's session abort a five-second HTTP deadline through the API helper. Other API requests keep their existing deadline. - Keep timeout errors visible. Keep physical stop, retained usage, and durable suspension proof unchanged. - Add a controlled-clock regression to the existing interruption tests. - Document the deadline and proof requirements in the durable transport contract. - Keep session state and identity formats unchanged. Previous releases' saved state needs no migration. ## Verification - Red: the new regression fails on the base code because the request signal remains active after five seconds. - Green: both interruption test files pass, 13 tests. These include idle, silent, busy-tool, provider-question handoff, pending MCP tool, and the new stalled abort case. - The eight `settles only verified governed shutdown` cases pass. They cover success, restart, foreign turn, missing proof, stop failure, timeout, provider failure, and terminal write failure. - The broader driver run has 99 passes and eight failures. The same driver file with this production change removed has 86 passes and the same eight failures. Those failures concern final-answer retention. They remain a verification gap; this PR does not change their assertions. - No hosted acceptance claim yet. After merge and automatic staging deployment, run only the question-answer-resume journey. - Required CI passed on final commit `45e39805efffbd648bfeca9697c9898593487805`: https://github.com/paperclipai/paperclip/actions/runs/46726627054. This includes typecheck, build, Runner tests, general tests, and E2E suites. - Greptile gives final commit `45e39805e` 5/5, Medium impact. All three review threads are resolved. - After review corrections, both interruption files pass again: 13 tests. The test always restores timers and attempts resource cleanup. The API helper owns the single request deadline. ## Risks - An abort response that needs more than five seconds now fails earlier. Definitive process stop must still prove shutdown. A timeout alone does not authorize session reuse or completion. - The regression uses the real driver and a controlled HTTP boundary. It does not prove hosted suspension timing. The targeted staging journey remains required. - The owning driver file already exceeds 1,000 lines. The change adds only the request deadline and its rationale at the existing abort call. A separate module would add no useful boundary. - There is no schema, saved identity, provider selection, accounting policy, or journey grading change. ## Model Used - OpenAI GPT-6, through Codex with reasoning and tools for source inspection, code editing, and test 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 - [ ] 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>