fix(agent,loop): 静音路径工具广告面与流式路径统一(P0-12,审计 §4.3)
- 原缺陷:流式路径经 loop.toolSchemas(capacity 允许集 + restrict)过滤,而 agent 静音/内部路径
(RunStep,被 services/automations 等使用)广告 dispatcher **全量** ⇒ 两条路径不一致
- 修法(方案 1):**过滤实现只留一份**(loop.toolSchemas);l.agentStep 调用同一个函数,结果经
agent.WithToolSurface(ctx, …) 下传,agent 的 buildRequest 原样广告(取不到才回退全量,保持既有回退语义)
· 按构造相同:同一次函数调用、同一份输入 ⇒ 不存在第二份可漂移的实现
· 未选「抽共享函数两侧各调一次」:loop 的过滤输入含 loop 私有会话环境 ctx key 与 capacity 判定器,
agent 侧凑齐等于再造一套 ctx 管线,漂移面更大
- 复核:agent/loop 包测试绿;新增 parity 用例(owner 与 group 两组,静音 == 流式);
变异(撤掉下传行)→ parity 必红且精确复现「静音=全量 4 个」,已还原
- 附注:全仓仅剩 `services/automations` 的「无 Loop 回退」仍广告全量(没有循环就没有闸可言);
子代理 ToolWhitelist 是执行期否决、本不参与 schema 过滤(未改)
This commit is contained in:
1 parent
20d452a51a
commit
5c28ace70d
5 files changed
+303
-10
No files matched your search
@@ -64,7 +64,14 @@ func (l *Loop) step(ctx context.Context, sessionID string, messages []model.Mess
|
||||
|
||||
// agentStep 把非流式步委托给该 turn 的 agent,由后者运行输入
|
||||
// 与输出护栏、调用模型并解码所有工具调用。
|
||||
//
|
||||
// 工具面与流式路径**同源**(audit P0-12):两条路径都取这一处过滤结果
|
||||
// (capacity 允许集 + design/11 §3 会话环境安全门),区别只在于流式路径在
|
||||
// 循环里组装请求时直接把它写进 model.Request,而本路径经 ctx 下传给 agent
|
||||
// 广告。agent 侧因此不需要、也不允许自行过滤,两份实现无从漂移;静音内部
|
||||
// 流程(backthink、子代理)与前端聊天看到的是同一份工具面。
|
||||
func (l *Loop) agentStep(ctx context.Context, sessionID string, messages []model.Message) (*stepOutcome, error) {
|
||||
ctx = agent.WithToolSurface(ctx, l.toolSchemas(ctx, messages))
|
||||
sr, err := l.agentFor(ctx).RunStep(ctx, sessionID, messages)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("loop: agent step: %w", err)
|
||||
|
||||
Reference in new issue
Block a user