mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-22 09:58:06 +00:00
feat(scheduler): M6 任务级回执 + 断链点统一为终态事件
设计依据 docs/zh/input-scheduler-design.md §7(I5)、§11.3(X1/X2/X4)。 - 新增 emitSkippedReply:跳过路径(去重命中、空输入)给同步调用方一个 skipped 终态,但**不发 agent_output 事件**(避免 WebUI 聊天记录凭空多出 空消息)。修复前 cli/clawhubadapter 这类无超时的同步注入在去重命中时永久挂起 - 回执按任务归属:中断任务的回执只写自己的 ResponseCh,绝不误投给被挂起的等待者; 被挂起任务恢复并结束后才拿到自己的回执 - 新增 task_terminal_test.go 3 项:X1 回执不误投、X2 空输入有 skipped 终态、 X4 无超时同步调用方 1s 内拿到终态(回归判据) - 更新 M3a 去重用例:由「不得回执」改为「必须有 skipped 终态」 - 验收:agent 全量 + -race;全仓 build/vet 通过
This commit is contained in:
@ -271,6 +271,40 @@ func (a *Agent) mediaToBlocks(payload map[string]interface{}, mediaType string,
|
||||
return blocks, alt
|
||||
}
|
||||
|
||||
// emitSkippedReply 给被跳过任务的**同步**调用方一个终态。
|
||||
//
|
||||
// 为什么要单独一条路径而不是复用 emitResponse:跳过意味着“我们没有处理这条输入”,
|
||||
// 不应对外发 agent_output 事件(否则 WebUI 聊天记录会凭空多出一条空消息),
|
||||
// 但必须写 ResponseCh——否则 cli/clawhub 这类无超时的同步注入会永久挂起。
|
||||
//
|
||||
// 非阻塞写:ResponseCh 由同步调用方以 cap=1 创建,调用方超时离开后仍可写入。
|
||||
func (a *Agent) emitSkippedReply(evt *agentIO.InputEvent, reason string) {
|
||||
if evt == nil || evt.ResponseCh == nil {
|
||||
return
|
||||
}
|
||||
ch := evt.OutputChannel
|
||||
if ch == "" {
|
||||
ch = evt.Source
|
||||
}
|
||||
payload := map[string]interface{}{
|
||||
"content": "",
|
||||
"request_id": evt.RequestID,
|
||||
"skipped": true,
|
||||
"reason": reason,
|
||||
}
|
||||
select {
|
||||
case evt.ResponseCh <- &agentIO.OutputEvent{
|
||||
RequestID: evt.RequestID,
|
||||
Target: evt.Source,
|
||||
Type: "text",
|
||||
Payload: payload,
|
||||
Done: true,
|
||||
OutputChannel: ch,
|
||||
}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Agent) emitResponse(evt *agentIO.InputEvent, response string) {
|
||||
stageCtx := &sdk.StageContext{
|
||||
FinalText: response,
|
||||
|
||||
Reference in New Issue
Block a user