mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-11 23:36:51 +02:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The Paperclip Runner package manages live sessions and durable command recovery > - Capability live-session tests can fail when a turn-timeout rejection has no handler > - A resumed session can also stall when the durable control plane rejects an indeterminate command result > - These failures make valid tests fail or hide the turn that stalled > - This pull request captures timeout rejections early and accepts indeterminate recovered commands > - The benefit is stable tests and clearer timeout failures after a runner restart ## Linked Issues or Issue Description **What happened?** Capability live-session tests failed intermittently on loaded CI hosts. A timer could reject a turn promise before the test attached its assertion. A resumed session could also stall after a runner restart because the durable control plane rejected the indeterminate command status. **Expected behavior** The test must handle a timeout rejection at promise creation. The durable control plane must accept an indeterminate recovered command and allow the session to continue. A configured timeout must persist in the checkpoint and identify the stalled turn. **Steps to reproduce** 1. Run the capability live-session test file on a loaded host. 2. Create a turn promise with a timeout and delay before attaching its assertion. 3. Resume a session after a runner restart with a journaled but unconfirmed command. 4. Observe the unhandled rejection or the stalled resumed session. **Paperclip version or commit** Commit `ede642e57e22ea3fb0a73590fca8bcc994f1a47f` on `master`. **Deployment mode** Built from source. **Installation method** Built from source. **Agent adapter(s) involved** Not adapter-specific. The tests use the Paperclip Runner package. **Database mode** Not database-related. **Additional context** Pull request #12646 also updates durable recovery for indeterminate command results. If it lands first, this pull request must retain the compatible behavior without duplicate edits. ## What Changed - Add a helper that captures a turn rejection before any await step. - Update three live-session test sites to assert the captured rejection value. - Add a helper test that waits past the turn timeout before it asserts. - Accept indeterminate as a terminal recovered-command status. - Add tests for acceptance, duplicate absorption, and reload from persisted state. - Add an optional turnTimeoutMs value to resume and pin its checkpoint behavior. ## Verification - `npx vitest run src/live/live-session.test.ts` from `packages/paperclip-runner`: 19 passed, 1 skipped. - `npx vitest run src/control-plane/durable-prp-control-plane.test.ts` from `packages/paperclip-runner`: 5 passed. - The live-session file passed 10 of 10 runs with 30 competing workers on a 32-core host. - TypeScript reported five pre-existing errors in `src/eval/workflow-harness.ts`. - CI must run `pnpm --filter @paperclipai/paperclip-runner check:all`. ## Risks The durable control plane now accepts one additional terminal recovery status. The change affects only recovered command handling and capability live-session tests. The main risk is overlap with pull request #12646 if that pull request lands first. ## Model Used OpenAI Codex, GPT-5, with tool use and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes: #` / `Refs: #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [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>
12 lines
531 B
TypeScript
12 lines
531 B
TypeScript
// A turn-timeout timer can reject its promise before a test reaches its own
|
|
// assertion. Vitest treats a rejection with no attached handler as an
|
|
// unhandled rejection and fails the whole file, even if every assertion
|
|
// later passes. Call this at the same moment the promise is created, before
|
|
// any `await`, so a handler is always in place before the timer can fire.
|
|
export function captureTurnRejection<T>(promise: Promise<T>): Promise<unknown> {
|
|
return promise.then(
|
|
() => null,
|
|
(error: unknown) => error,
|
|
);
|
|
}
|