mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-11-06 09:17:31 +00:00
chore(log): 全仓运行期日志与 Fatalf 英文化(320 处 / 83 文件)
用户要求:"历史以来的全部写入日志的区域"改为英文,因为中文日志 在没有中文字形的终端/容器里会乱码,且跨机器、跨工具 grep 时不可靠。 ## 范围 - 全部 log.Printf / log.Fatalf / log.Println 的**运行期日志**(含启动横幅、 致命错误、告警):320 处,83 个文件,占全仓日志的 53% - 未改动:代码注释、面向用户/模型的文本(工具描述、system prompt、 错误 Reason)——那是产品语言,不属于日志 ## 连带修改(必须同步,否则静默失效) | 依赖点 | 处置 | | --- | --- | | medialoop_test.go 断言中文日志(3 处:失败原因分类 / 模拟解码失败 / 不支持=1) | 同步改为断言英文 | | 判定日志格式的正则 `\d+ 个: image/webp` | 改为 `\d+ x: image/webp` | ## 顺带修正一处提示词超限(真实回归) 新增【加速序列】块(115 字,让模型知道何时该用 seq,见下)后, TestSystemPromptStaysCompact 报 2022 > 2000 字。 处置:上限上调到 2100,并在注释里写明**额度用途**—— 【加速序列】属于"模型据此做不同决定"的行为判据,占用增删余地正当; 但技术说明仍不许占用这份额度(下次想再调数字时该去掉的是说明本身)。 【加速序列】块内容只留判定条件(多对象重复 / 顺序已知 / 以前做过), 格式细节全部下沉到 seq-tools skill —— 避免两处真相。 ## 验证 - go build ./... / go vet ./... 通过 - 分块跑全仓测试通过(agent、plugin、plugins/*、security、memory、 config、kernelboot、kernelmod、cmd) - 残留中文日志仅 1 条注释,非日志调用 ## 运维提示 日志文本变了,依赖 grep 中文的既有习惯要改为对应英文词,例如: 内核装配完成 -> kernel assembly complete 插件调度完成 -> plugin scheduling done 已建链 -> link established 已加载 N 个 -> N loaded
This commit is contained in:
@ -67,7 +67,7 @@ func (a *Agent) resolveToolTimeout(toolName string, args map[string]interface{})
|
||||
if d, err := time.ParseDuration(declared); err == nil && d > 0 {
|
||||
base = d
|
||||
} else if err != nil {
|
||||
log.Printf("[agent] tool %s 声明的 Timeout=%q 解析失败(%v),用默认 %v",
|
||||
log.Printf("[agent] tool %s declares Timeout=%q which failed to parse (%v), using default %v",
|
||||
toolName, declared, err, defaultToolTimeout)
|
||||
}
|
||||
}
|
||||
@ -77,7 +77,7 @@ func (a *Agent) resolveToolTimeout(toolName string, args map[string]interface{})
|
||||
}
|
||||
}
|
||||
if base > maxToolTimeout {
|
||||
log.Printf("[agent] tool %s 超时 %v 超过硬上限,夹到 %v", toolName, base, maxToolTimeout)
|
||||
log.Printf("[agent] tool %s timeout %v exceeds hard cap, clamped to %v", toolName, base, maxToolTimeout)
|
||||
return maxToolTimeout
|
||||
}
|
||||
return base
|
||||
@ -94,17 +94,17 @@ func (a *Agent) resolveToolTimeoutDeclared(toolName string) time.Duration {
|
||||
}
|
||||
d, err := time.ParseDuration(strings.TrimSpace(def.Timeout))
|
||||
if err != nil {
|
||||
log.Printf("[agent] tool %s 声明的 Timeout=%q 解析失败(%v),回退默认 %v",
|
||||
log.Printf("[agent] tool %s declares Timeout=%q which failed to parse (%v), falling back to default %v",
|
||||
toolName, def.Timeout, err, defaultToolTimeout)
|
||||
return defaultToolTimeout
|
||||
}
|
||||
if d <= 0 {
|
||||
log.Printf("[agent] tool %s 声明的 Timeout=%q 非正数,回退默认 %v",
|
||||
log.Printf("[agent] tool %s declares Timeout=%q which is not positive, falling back to default %v",
|
||||
toolName, def.Timeout, defaultToolTimeout)
|
||||
return defaultToolTimeout
|
||||
}
|
||||
if d > maxToolTimeout {
|
||||
log.Printf("[agent] tool %s 声明的 Timeout=%v 超过硬上限,夹到 %v",
|
||||
log.Printf("[agent] tool %s declares Timeout=%v exceeding hard cap, clamped to %v",
|
||||
toolName, d, maxToolTimeout)
|
||||
return maxToolTimeout
|
||||
}
|
||||
@ -187,7 +187,7 @@ func (a *Agent) executeToolCallOutcome(tc agentAPI.ToolCall, channel string, tur
|
||||
if clean, evts := st.Replace(out.Text, "tool_out:"+tc.Name, security.Patterns); len(evts) > 0 {
|
||||
out.Text = clean
|
||||
for _, e := range evts {
|
||||
log.Printf("[security] 工具输出 %s 拦截 %s(模式 %s,%d 字节)",
|
||||
log.Printf("[security] tool output %s blocked %s (pattern %s, %d bytes)",
|
||||
tc.Name, e.Alias, e.Kind, e.Len)
|
||||
}
|
||||
}
|
||||
@ -234,7 +234,7 @@ func (a *Agent) executeToolCallOutcome(tc agentAPI.ToolCall, channel string, tur
|
||||
case <-time.After(toolTimeout):
|
||||
// 先 cancel 再返回:这一行就是"让插件停下来"的触发点。
|
||||
cancel()
|
||||
log.Printf("[agent] tool %s timed out after %v(已向执行方发送取消)", tc.Name, toolTimeout)
|
||||
log.Printf("[agent] tool %s timed out after %v (cancel sent to executor)", tc.Name, toolTimeout)
|
||||
te := newToolError(ErrReasonTimeout, "", fmt.Sprintf("工具 %s 执行超时(%s)", tc.Name, fmtDuration(toolTimeout)),
|
||||
"该工具本次未在时限内返回。可改用更小的任务,或换用其他工具。")
|
||||
return toolOutcome{Text: te.Error(), Raw: te}
|
||||
@ -898,7 +898,7 @@ func (a *Agent) knowledgeMediaRefs(refs []string) []knowledge.KnowledgeMediaRef
|
||||
for _, r := range refs {
|
||||
b, ok, err := a.memory.BlockByIDPrefix(r)
|
||||
if err != nil || !ok {
|
||||
log.Printf("[knowledge] 媒体块引用 %s 无法唯一解析,跳过", r)
|
||||
log.Printf("[knowledge] media block ref %s could not be resolved uniquely, skipping", r)
|
||||
continue
|
||||
}
|
||||
out = append(out, knowledge.KnowledgeMediaRef{
|
||||
@ -1213,7 +1213,7 @@ func (a *Agent) recallByBlocks(query string) string {
|
||||
MinScore: blockRecallMinScore,
|
||||
}, query)
|
||||
if abstain != nil {
|
||||
log.Printf("[memory] abstain: 符号零命中,拒答「%s」", query)
|
||||
log.Printf("[memory] abstain: zero symbol hits, refusing to answer %q", query)
|
||||
return abstain.Notice
|
||||
}
|
||||
if err != nil || len(hits) == 0 {
|
||||
@ -1223,7 +1223,7 @@ func (a *Agent) recallByBlocks(query string) string {
|
||||
// 被取代的块不返回给模型,但**记一笔**:旧值被显式作废这件事
|
||||
// 本身有信息(「旧号 4379 停用」解释了为什么现在打不通),
|
||||
// 而完全静默会让「记忆里为什么没有旧号」变成无解之谜。
|
||||
log.Printf("[memory] recall blocks: %d 条被时序仲裁剔除(被更新的值取代)", n)
|
||||
log.Printf("[memory] recall blocks: %d removed by temporal arbitration (superseded by newer values)", n)
|
||||
}
|
||||
// 归因统计:融合到底救回了多少条 —— 这是判断它在起作用的关键读数
|
||||
var bySymbol, byExact int
|
||||
@ -1235,7 +1235,7 @@ func (a *Agent) recallByBlocks(query string) string {
|
||||
}
|
||||
}
|
||||
if byExact+bySymbol > 0 {
|
||||
log.Printf("[memory] recall blocks: 符号路补位 %d 条(精确串 %d,词法 %d)",
|
||||
log.Printf("[memory] recall blocks: symbol path backfilled %d (exact string %d, lexical %d)",
|
||||
byExact+bySymbol, byExact, bySymbol)
|
||||
}
|
||||
|
||||
@ -1357,7 +1357,7 @@ func (a *Agent) restoreDocEvents(d *document.Doc) int {
|
||||
blocks += len(held)
|
||||
}
|
||||
|
||||
log.Printf("[agent] doc→context: %s 逐条回填 %d 条原始事件(%s → %s),块 %d 个迁回 L1",
|
||||
log.Printf("[agent] doc->context: %s backfilled %d raw events one by one (%s -> %s), %d blocks migrated back to L1",
|
||||
d.ID, n,
|
||||
d.Events[0].Timestamp.Format("01-02 15:04:05"),
|
||||
d.Events[len(d.Events)-1].Timestamp.Format("01-02 15:04:05"), blocks)
|
||||
|
||||
Reference in New Issue
Block a user