mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-10-02 15:23:57 +00:00
feat(scheduler): M4 临界区显式化 + 清掉被 pendingInterrupts 取代的 interceptCh
设计依据 docs/zh/input-scheduler-design.md §4.3、§11.1(P5/P6)。 - 临界区语义显式化:让位检查**只在 step 之间**做,执行中的 step (工具 RPC / ONNX / CAS 落盘)天然不可抢占;_consolidation_ 整任务 经 inCriticalSection() 判为不可抢占(它直接改图库) - 删除 interceptCh 与 drainInterrupts:M3b 起中断一律走 pendingInterrupts, 旧的「同行注入 + 三处 drain + 批次放弃」已无写入者,属死代码 - 新增 scheduler_critical_test.go 3 项: P5/P6 工具执行中 arm 了让位信号也不得挂起、必须等工具返回后的安全点; _consolidation_ 判为临界区;无抢占时同批工具必须全部执行(新语义回归) - 验收:agent 全量 + -race;全仓 build/vet 通过
This commit is contained in:
@ -321,33 +321,6 @@ func (a *Agent) emitResponse(evt *agentIO.InputEvent, response string) {
|
||||
a.runStage(sdk.StageAfterOutput, stageCtx)
|
||||
}
|
||||
|
||||
func (a *Agent) drainInterrupts() []string {
|
||||
var out []string
|
||||
for {
|
||||
select {
|
||||
case evt := <-a.interceptCh:
|
||||
if evt == nil {
|
||||
continue
|
||||
}
|
||||
text, _ := evt.Payload["content"].(string)
|
||||
if text == "" {
|
||||
continue
|
||||
}
|
||||
source := evt.Source
|
||||
if source == "" {
|
||||
source = "unknown"
|
||||
}
|
||||
channel := evt.OutputChannel
|
||||
if channel == "" {
|
||||
channel = source
|
||||
}
|
||||
out = append(out, fmt.Sprintf("[打断消息][来源:%s][输出通道:%s] %s", source, channel, text))
|
||||
default:
|
||||
return out
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pruneOnInput 按声明的上下文策略裁剪上下文,返回归档的事件数。
|
||||
//
|
||||
// 默认**不裁剪**:ContextPolicy 必须在注入点(payload 的 context_policy)
|
||||
|
||||
Reference in New Issue
Block a user