From a027f76a726e8a556674eded807c2de0e55f5cc0 Mon Sep 17 00:00:00 2001 From: Nicky Leach Date: Tue, 29 Sep 2026 22:09:37 -0700 Subject: [PATCH] fix(test): wait for the completion reporting turn before asserting chat status (#14644) ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agent chat tests verify the state changes that follow delegated work > - A delegated task wakes its source conversation with a completion reporting turn > - That turn can move the conversation out of `in_review` for a short time > - The test read status during that turn and failed under runner load > - This pull request waits for the completion turn to reply and settle before it reads status > - The benefit is a stable test that checks the intended final state ## Linked Issues or Issue Description **What happened?** The end-to-end test read a conversation status immediately after a delegated task finished. The completion reporting turn briefly changed the status during its checkout. The test could read `in_progress` instead of the final `in_review` state. **Expected behavior** The test should read the conversation status after the completion reporting turn replies and the conversation settles. **Steps to reproduce** 1. Run `tests/e2e/agent-chat-projects.spec.ts` on a loaded four-vCPU runner. 2. Run the test named `shared questions resume and existing project reuse creates no project card`. 3. Observe that the status read can race the completion reporting turn. **Paperclip version or commit** `master` at the commit under test. **Deployment mode** Local dev with the end-to-end test runner. **Installation method** Built from source. **Agent adapter(s) involved** Not adapter-specific. **Database mode** Not database-related. **Additional context** The deterministic reproduction failed 3 of 3 times before this change and passed 3 of 3 times after this change. ## What Changed - Wait for the completion reporting turn with the existing `idle` helper before the status assertion. - Add a comment that explains the race and the required settling point. - Change only `tests/e2e/agent-chat-projects.spec.ts`. ## Verification - Run `tests/e2e/agent-chat-projects.spec.ts` with Playwright. - Confirm that all 16 tests pass. - Run the deterministic reproduction before and after the change. - Confirm that the target test passes. - Confirm that the end-to-end shard and the full CI suite pass. - Confirm that Greptile gives a 5/5 result with no open findings. ## Risks Low risk. The change affects one end-to-end test. It adds one wait through an existing helper. It does not change product code, raise a timeout, add a fixed sleep, or skip a test. ## Model Used OpenAI Codex, GPT-5, tool use and code execution. The model context window and reasoning mode were not provided for this handoff. ## 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 Co-authored-by: Claude Sonnet 5 --- tests/e2e/agent-chat-projects.spec.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/e2e/agent-chat-projects.spec.ts b/tests/e2e/agent-chat-projects.spec.ts index 88751f70d3..d4979449e3 100644 --- a/tests/e2e/agent-chat-projects.spec.ts +++ b/tests/e2e/agent-chat-projects.spec.ts @@ -501,6 +501,11 @@ test("shared questions resume and existing project reuse creates no project card }), ); expect(ordinaryChild.parentId).toBe(task.id); + // The delegated task finishes on its own and wakes the conversation with + // a completion reporting turn. Wait for that turn to post its reply and + // settle before reading status, or this read can catch the conversation + // mid-turn. + await idle(request, f.chatPath, 4); expect( (await json(await request.get(`/api/issues/${chat.id}`))).status, ).toBe("in_review");