Skip to content

fix(chat): Finish turn after Slack accepts the reply - #1397

Merged
dcramer merged 7 commits into
mainfrom
fix/complete-turn-after-accepted-reply
Aug 10, 2026
Merged

dcramer merged 7 commits into
mainfrom
fix/complete-turn-after-accepted-reply

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

When Junior posts a final answer and Slack accepts it, that turn is done.

Before this change, a host timeout could still try to pause the turn with shorter history. That failed and left the turn in a failed state (JUNIOR-7Y).

Change

If Slack accepted the final reply and the turn then times out, complete the turn. Do not pause it.

Test proof

The integration test starts with a real Slack mention. It uses the real worker, agent runtime, delivery path, SQL history, timeout, and next turn. Only the model response and Slack HTTP are fake.

The test checks that:

  • Slack gets one reply
  • the turn completes
  • the reply stays in SQL history
  • a later mention works

I also ran the test with the production fix disabled. It failed with the original AgentHistoryBranchError, and the turn was failed instead of completed. Restoring the fix made the same test pass.

The suite also keeps coverage for existing queue behavior: long work resumes after timeout, retries do not duplicate replies, steering works, and dead workers do not block later work.

Follow-up

Sentry: https://sentry.sentry.io/issues/7664050472/

Once Slack accepts a tool-free assistant, finish the turn on timeout instead
of parking a shorter history. Recovery also completes stranded turns that
already have an accepted destination reply.

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview Aug 10, 2026 9:16pm

Request Review

Drive JUNIOR-7Y from Slack webhook ingress through real runtime wiring.
Hold only Slack accept past the host deadline, then assert one completed
turn, one destination post, durable assistant history, and a later turn.

Co-Authored-By: David Cramer <[email protected]>
sentry-junior Bot and others added 2 commits August 10, 2026 20:20
Rewrite durable-queue around the six product outcomes from #1398.
Drive live mid-work timeout → park → fresh wake → finish. Keep only
dead-worker residue seeding where a live process cannot leave state
in-process. Drop auth from this suite.

Co-Authored-By: David Cramer <[email protected]>
The accept-is-terminal rule must cover cooperative yield after delivery,
not only hard timeout. Assert the live mid-work park uses timeout, and
label the dead-worker accepted-reply case as seeded residue.

Co-Authored-By: David Cramer <[email protected]>
});

// ── Tool wiring ──────────────────────────────────────────────────
const wiring = await wireAgentTools({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should create a github issue to f/u here - this is SO bulky at this point and needs to be cleaned up

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #1401 for the agent module split.

@dcramer
dcramer marked this pull request as ready for review August 10, 2026 20:53
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Aug 10, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 15fe1a4. Configure here.

Completing on any accepted tool-free reply broke delivery+steer+yield.
Hard timeout after accept still completes. Soft yield after a pure
assistant tail already cannot park; steered continuable boundaries may.

Co-Authored-By: David Cramer <[email protected]>
When destination already accepted a reply, return after the complete
attempt. Do not fall through to stranded-failure fallback if the turn
record does not close on this pass.

Co-Authored-By: David Cramer <[email protected]>
@sentry-junior sentry-junior Bot changed the title fix(chat): Complete turn after accepted tool-free reply fix(chat): Finish turn after Slack accepts the reply Aug 10, 2026
@dcramer
dcramer merged commit e91f246 into main Aug 10, 2026
37 checks passed
@dcramer
dcramer deleted the fix/complete-turn-after-accepted-reply branch August 10, 2026 21:29

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 76a10076 Deployed Aug 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant