Recover stalled Slack active turns#69
Open
pengx17 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Slack 线程里用户追问「PR 呢」时,broker 已经定位到
active_turn_id卡在旧 turn:后续消息被继续送进僵尸 turn,session 没有自动恢复。原修复分支已经推到codex/active-turn-watchdog-recovery,但当时 GitHub 身份没有权限开 PR;这次把该分支同步到pengx17fork 后发起 PR。协作过程
Note: 关键转折是把问题从「固定 5 小时清理」改判为「terminal event / active turn stale 后缺少自动恢复」,所以本 PR 不做 session 全量清理,而是恢复单个 stalled active turn。
方案讨论
最终方案
flowchart TD A[Slack follow-up message] --> B{session has activeTurnId?} B -- no --> C[normal pending dispatch] B -- yes --> D[read runtime thread state] D --> E{terminal / missing?} E -- yes --> F[clear active turn and resume] E -- no --> G{runtime activity older than timeout?} G -- no --> H[keep active turn] G -- yes --> I[interrupt stale turn best-effort] I --> J[reset inflight messages to pending] J --> FSLACK_ACTIVE_TURN_STALL_TIMEOUT_MS配置,默认 10 分钟。slack-turn-reconciler根据 runtime state + last trace activity 判断 stale active turn。slack-conversation-service支持 force reset + resume pending dispatch。slack-routes增加单 session repair route。验证情况
pnpm install --frozen-lockfilepnpm exec tsc -p tsconfig.json --noEmitpnpm exec vitest run test/config.test.ts test/e2e-broker.test.ts test/slack-conversation-service.test.ts test/slack-routes.test.ts test/slack-turn-reconciler.test.ts test/slack-turn-runner.test.tspnpm buildCodex review verification:
pnpm exec tsc -p tsconfig.json --noEmitCodex review verification:
pnpm exec vitest run test/config.test.ts test/e2e-broker.test.ts test/slack-conversation-service.test.ts test/slack-routes.test.ts test/slack-turn-reconciler.test.ts test/slack-turn-runner.test.tsGitHub CI
Build and testpassed on headca5a582.已知局限 / 后续工作