Skip to content

[business-logic] tool_call_budget: hard-stop path injects 'summarize' directive then immediately returns nil — directive never consumed in-run, subagent callers can't distinguish budget truncation from completion #367

Description

@topcheer

文件与行号

internal/agent/agent.go:4446-4463(budget stop 路径)vs :4466-4478(maxIter 路径)、internal/agent/tool_call_budget.go:132-136

问题(独立复核确认)

预算硬停路径注入 "Summarize what was accomplished..." user 消息到 contextManager 后立即 return nil 结束 run——该指令在本 run 内永远不被消费(循环已终止,无再调 LLM 的路径),tool_call_budget.go:132-136 的收敛文案在 stop=true 场景是死代码(80%/95% 分层警告正常生效)。且 return nil 与 maxIter 路径(emit 完整 Summary + StreamEventError,返回 err)语义不对称:

后果

  • subagent 调用方(internal/acp/agent_loop.go 等 RunStreamWithContent 使用者):nil = 正常完成,预算截断与真实完成不可区分,无 error 事件供上层重试/标记
  • session resume:注入的总结指令持久化在 contextManager,下一轮用户消息时 LLM 可见——表现为下一轮突兀地要求总结已结束的 run,体验错位
  • cron 路径无实际影响(纯 prompt 入队器,不判读 run 结果)

修复建议

stop 时要么允许一次收尾 LLM turn 再终止,要么 emit 预算摘要(类似 maxIter 路径的 runStats.Summary())并返回哨兵 error。

严重程度

medium

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions