Files
magpie/internal
youheyu bede73c34d gateway: concurrent tasks of an agent that sends no session id are told apart by their conversation (#2001, CnsMaple)
Task done 通知按 agent+session 分桶,turnState.start 建桶时定死:同一
agent 不带 session 头的多个并发任务共享一个桶,先结束的任务的通知读的
是仍在跑的最长任务的时间(且 going>0 时不发通知)。convOf 生成的
Conv(首个用户轮次的摘要)已存在于 Route 且只在无 session 时填充——
sessionTurnKey 在 Session 为空时用 Conv 兜底,并发任务各归各的桶。
同一 session 的多个请求仍共享一个 turn,等待全部结束、跨度和原来一致。

验证:TestTurnDoneConcurrentTasksByTheirConversation(短任务通知读自己的
一分钟、长任务不受影响各自报自己的跨度)与
TestTurnDoneSameSessionStillOneTurn(同 session 行为不变);未修复基线
前者 FAIL(等了 10s 无通知,因 going>0 被压住)。TestTurnDone* 全组通过。

Root cause and fix by AwadYoo (comment on #2001), landed as their commit.
Reviewed on main: both routes that mark a request as a turn
(gateway.go, codex_backend.go) set Conv, convOf is "" whenever a session
header is present, and begin/end read the key off the same Route, so a
request's begin and end always meet one bucket.

Run (sandbox HOME, pinned caches, rebased on e297a8ab2):
- go test -race -run 'TestTurnDone|TestToolScan' ./internal/gateway: ok
- sessionTurnKey put back alone: TestTurnDoneConcurrentTasksByTheirConversation
  FAILs "the turn's end was never said"; restored: ok
- go test -count=1 -timeout 30m ./internal/gateway: ok (1260s; the default
  10m timed out while five other gateway suites ran on this machine)
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway: ok
Known limit: an agent with no session id whose first user turn changes
mid-task (its own compaction rewriting it) starts a new turn there.
2026-10-14 04:37:07 +08:00
..
…
…