Skip to content

fix(core): emit warn logs when LLM unavailable + configurable tool-heavy skip thresholds#1557

Merged
hijzy merged 1 commit into
MemTensor:mem-agent-0424from
hijzy:fix/llm-silent-degradation
Apr 28, 2026
Merged

fix(core): emit warn logs when LLM unavailable + configurable tool-heavy skip thresholds#1557
hijzy merged 1 commit into
MemTensor:mem-agent-0424from
hijzy:fix/llm-silent-degradation

Conversation

@hijzy
Copy link
Copy Markdown
Collaborator

@hijzy hijzy commented Apr 28, 2026

Summary

  • 修复所有 LLM 依赖模块在 LLM 客户端为空时静默降级的问题,改为输出 warn 级别日志,便于诊断"自我进化链路未跑通"的根因
  • decideSkipReason 中硬编码的工具密集型判断阈值(toolTurns >= totalTurns * 0.7assistantContentChars < 80)提取为可配置参数

背景

TaskCLI demo 测试(2026-04-27)发现:当 OpenClaw 的 HostLlmBridge 未注入时,memos-local-plugin 内部 LLM 客户端为空,导致 reward/L2/Skill/L3 全部静默退化为 heuristic/跳过,但日志中几乎看不到任何提示。此外 decideSkipReason 的工具密集型启发式在 OpenClaw 大量使用工具的场景下误判过多 episode 为 skip。

Changes

文件 改动
core/reward/human-scorer.ts debugwarn score.llm_unavailable,附原因
core/memory/l2/induce.ts 新增 warn l2.induce.llm_unavailable(之前无日志)
core/skill/crystallize.ts infowarn skill.crystallize.llm_unavailable,附原因
core/memory/l3/abstract.ts 新增 warn l3.abstract.llm_unavailable(之前无日志)
core/reward/reward.ts 新增一次性 warn reward.llm_unavailabledecideSkipReason 读取可配阈值
core/reward/types.ts RewardConfig 新增 toolHeavyRatio + minAssistantCharsForToolHeavy
core/config/schema.ts 注册两个新的 reward 配置字段
core/config/defaults.ts 设置默认值 0.7 / 80(保持向后兼容)
tests/unit/reward/*.test.ts 补充新字段到测试 mock

Test plan

  • 配置 llm.provider: host 但不注入 bridge → 日志应出现 reward.llm_unavailablescore.llm_unavailablel2.induce.llm_unavailable 等 warn
  • 配置正常 LLM → 无新增 warn,行为不变
  • config.yaml 设置 algorithm.reward.toolHeavyRatio: 0.9 → 工具密集型 episode 不再被误判 skip
  • 现有单元测试通过(tests/unit/reward/

…egradation

All LLM-dependent modules were silently falling back to heuristic/skip
when the LLM client was null (e.g. host bridge not attached), making it
very hard to diagnose why the self-evolution pipeline produced no
results. This was reported in the TaskCLI demo test (2026-04-27).

Changes:

1. human-scorer.ts: upgrade `score.heuristic` debug → `score.llm_unavailable`
   warn with explicit reason (config disabled vs client null)

2. induce.ts (L2): add `l2.induce.llm_unavailable` warn when llm is null
   (previously returned silently with no log at all)

3. crystallize.ts (Skill): upgrade `skill.crystallize.llm_disabled` info →
   `skill.crystallize.llm_unavailable` warn with reason

4. abstract.ts (L3): add `l3.abstract.llm_unavailable` warn when llm is null
   (previously returned silently with no log at all)

5. reward.ts: add one-time `reward.llm_unavailable` warn at runner creation
   explaining the full downstream impact

6. reward.ts + types.ts + schema.ts + defaults.ts: extract hardcoded
   `toolTurns >= totalTurns * 0.7` and `assistantContentChars < 80` into
   configurable `algorithm.reward.toolHeavyRatio` (default 0.7) and
   `algorithm.reward.minAssistantCharsForToolHeavy` (default 80)

7. Fix test mocks to include the two new RewardConfig fields
@hijzy hijzy merged commit e16107d into MemTensor:mem-agent-0424 Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant