Skip to content

fix(acp): 修复 prompt 与 steering 的启动竞态 - #109

Merged
uvwt merged 1 commit into
mainfrom
fix/acp-prompt-dispatch-order-20260914
Sep 14, 2026
Merged

uvwt merged 1 commit into
mainfrom
fix/acp-prompt-dispatch-order-20260914

Conversation

@uvwt

@uvwt uvwt commented Sep 14, 2026

Copy link
Copy Markdown
Owner

背景

PR #108 的 Ubuntu CI 连续在不同 ACP steering 兼容测试中卡到 10 分钟超时。Mini 上使用 -race -count=20 -timeout=90s 可以复现相同卡死。

根因不是单纯 CI 偶发:StartPrompt 在后台 goroutine 真正写出 session/prompt 前就返回。调用方若立即执行 Steer / CancelPromptsession/cancel 可能先于 prompt 到达 Adapter 并被消费,随后原 prompt 永久等待取消。

修复

  • StartPromptBlocks 在返回 started 前等待 session/prompt 完成连接写入。
  • Connection 内部 request 路径在请求成功写入后发出 dispatch 信号。
  • pre-dispatch 失败路径也会释放等待,避免新的死锁。
  • 增加确定性回归测试,用 gated writer 证明 StartPrompt 不会在 prompt dispatch 前返回,并验证随后的 steering 能取消正确 Run。

验证

  • 修改前:go test -race ./internal/acp -run 'Test(Claude|Codex).*SteeringFallback' -count=20 -timeout=90s 可稳定复现 90s 超时。
  • 修改后确定性回归测试连续 20 次通过。
  • 修改后 steering -race 压测连续 30 次通过。
  • go test ./... -count=1 -timeout=180s 通过。
  • go test -race ./... -count=1 -timeout=240s 通过。
  • go vet ./... 通过。
  • go build ./cmd/agentdock 通过。

@uvwt
uvwt merged commit 294343c into main Sep 14, 2026
7 checks passed
@uvwt
uvwt deleted the fix/acp-prompt-dispatch-order-20260914 branch September 14, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant