Files
Agent-System/internal/coordinator/reply_flags.go
T
weichen d55488ae37 feat(coordinator): 用智能体叙述查询、帮助与操作回执
确定性事实仍由代码生成;PI Agent 只组织语言,失败或关闭开关时回退原模板。安全拦截与确认提问保持模板。
2026-09-28 03:25:06 +00:00

42 lines
930 B
Go

package coordinator
import (
"os"
"strings"
"sync"
)
// 意图叙述开关:默认开启。关闭后查询/帮助/结果通报全部回到确定性模板。
var (
replyFlagMu sync.RWMutex
agentReplyLLMOn = envAgentReplyLLM()
)
func envAgentReplyLLM() bool {
v := strings.TrimSpace(os.Getenv("AGENT_REPLY_LLM_ENABLED"))
if v == "" {
return true
}
return v == "1" || strings.EqualFold(v, "true") || strings.EqualFold(v, "yes")
}
// agentReplyLLMEnabled 报告意图叙述是否走智能体。
func agentReplyLLMEnabled() bool {
replyFlagMu.RLock()
defer replyFlagMu.RUnlock()
return agentReplyLLMOn
}
// SetAgentReplyLLMForTest 测试专用覆盖,返回恢复函数。
func SetAgentReplyLLMForTest(enabled bool) func() {
replyFlagMu.Lock()
prev := agentReplyLLMOn
agentReplyLLMOn = enabled
replyFlagMu.Unlock()
return func() {
replyFlagMu.Lock()
agentReplyLLMOn = prev
replyFlagMu.Unlock()
}
}