Repository navigation
fix(agent): idle 会话的结构化通知不再等到下次 busy - #470
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
问题
后台/卡片通知的 idle/busy 分支失效:会话 idle 时消息不立刻变成 user 消息,而是等到下一次 busy 才投递。
用户实测:卡片批复(decision / ask_user)在会话空闲时无反应,下次有请求跑起来才出现。
根因(两层)
ccfbef9f):decision 路径的persistUserNoticeFeedback从「无条件落库」改成「仅 idle 落库」,移除了 busy 期的历史兜底副本。514ec7b3):drainStructuredQueue只有 Run 的 iteration 边界一个消费点,drainAndProcessNotifications(idle 路径)从不处理该队列。两者叠加:busy 期入队 → Run 在下一个 drain 边界前结束 → 既没落库、也没人消费 → 卡到下次 busy。
修复
flushStructuredQueueAsUserMessage(sessionKey):把队列残留合并成一条消息,内联 content、不带structured_delivery(否则 processMessage 会跳过落 user 行),走injectInboundWithMetadata→ 落库 + 起新 turn,表现为普通 user 消息。drainAndProcessNotifications开头按!ss.busy调用,覆盖 Run 正常结束 / 异常结束 / cancel ack 后的所有 idle 路径。peekStructuredQueue(不创建空队列)。验证
TestFlushStructuredQueueTurnsResidueIntoUserMessage:busy 入队 2 条 → 置 idle → 真实 drain → 队列清空、收到 1 条合并消息、内容含两张卡片、无structured_delivery标记。TestFlushStructuredQueueIsIdempotent:flush 后再 drain 不重复投递。TestDeliverWhenIdleStillInjectsImmediately:idle 直接投递契约不变(persist 恰 1 次、不入队、立即注入)。queue must be empty after flush, got 2)。go test ./...EXIT=0;预提交检查(Go/前端/lint)通过。已知残余风险(不在本 PR 范围)
内存队列无持久化:busy 入队与 Run 结束 flush 之间若进程被杀,消息仍会丢。彻底解法是 outbox 落库 + 启动重放,另开任务。