Repository navigation
fix(worker): 后台子任务未完或启动参数里的首条提示仍在执行时,回到提示符不再释放本轮权限 - #3055
Merged
Merged
Conversation
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 12:08
This was referenced Nov 7, 2026
|
🚀 Released in v3.59.0 |
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.
症状
一轮还在执行时,从这一轮发出的
botmux report间歇性地被拒(HTTP 403turn_provenance_stale)。典型场景:主轮派出后台子任务后回到提示符等待它们的完成通知,或启动参数里带的首条提示(Grok 类)尚未执行完。根因
markPromptReady()先按decideQueuedReadyTransition的结果释放本轮的 turn authority,之后才检查「后台子任务仍在运行」和「启动参数里的首条提示仍在执行」,并把这次 ready 改报为 working、保持非就绪。也就是说,一个并非本轮结束的 ready 已经把 authority 释放了,仍在运行的工作再发 report 时找不到本轮的 live origin,被当作过期。修法
释放前先判断这次 ready 是否会在下方被改报为 working:启动参数里的首条提示仍在执行,或本轮有未完成的后台子任务;并且没有待写入的消息、原始输入、重命名或已排队的 type-ahead 轮次会在这次 ready 接管 CLI。满足时不释放,其余情况照旧。条件与下方改报 working 的分支一致。
authority 保留的时长与会话卡片显示 working 的时长相同:后台子任务的停止记录到达、收到新的真实提示或 CLI 进程被替换后,下一次真正的空闲 ready 会照常释放。这期间新消息的处理与任何一轮运行中相同(同一调用方写入时接管,隔离关闭时沿用原主体)。
issue 中提到的诊断日志、首条提示超时保护和 OpenCode2 嵌套工具忙碌状态的排查未做,不在本 PR 范围内。
验证
test/worker-ready-keeps-busy-turn-authority.test.ts:用真实的markPromptReady和ActiveTurnAuthority/decideQueuedReadyTransition:test/dispatch-user-route.test.ts与test/worker-bridge-queue-hold-wiring.test.ts的局部 fixture 只覆盖到释放点为止,各补一行「无后台子任务」的backgroundTaskTracker桩。npx vitest run test/worker-ready-keeps-busy-turn-authority.test.ts test/dispatch-user-route.test.ts test/worker-bridge-queue-hold-wiring.test.ts test/worker-codex-execution-root.test.ts test/worker-idle-queue-stall.test.ts test/worker-terminal-authority-release.test.ts test/worker-structured-turn-attribution.test.ts test/worker-turn-idle.test.ts test/worker-argv-reaction-status.integration.test.ts test/turn-reactions.test.ts test/background-task-tracker.test.ts test/dsh-tui-ready-signal.test.ts test/initial-prompt-arg-limit.test.ts test/restart-worker-null-reattach.test.ts test/input-gate.test.ts test/inject-queue-policy.test.ts test/schedule-hidden-run-argv-gate.test.ts test/runtime-screen-status.test.ts test/worker-durable-expiry-order.test.ts test/raw-input-followup-atomicity.test.ts test/worker-restart-merge-attempt.test.ts:通过。npx tsc --noEmit -p .、bun run build:通过。Fixes #1723