fix: add isInvalidAgentIdFormat guard to runMemoryReflection (Issue #686)#687
fix: add isInvalidAgentIdFormat guard to runMemoryReflection (Issue #686)#687jlin53882 wants to merge 7 commits intoCortexReach:masterfrom
Conversation
…ebase) This rebases the following fixes from PR CortexReach#516 onto upstream/master (0988a46): F2 (excludeAgents runtime reading): - Add isAgentOrSessionExcluded() helper supporting exact/wildcard/temp:* patterns - Add memoryReflection.excludeAgents to PluginConfig and openclaw.plugin.json schema - Add excludeAgents check in runMemoryReflection command hook F3 (wildcard pattern fix): - Replace config.autoRecallExcludeAgents.includes(agentId) with isAgentOrSessionExcluded() in before_prompt_build hook - Supports pi-, temp:*, and exact match patterns F5 (serialCooldownMs configurable): - Add serialCooldownMs?: number to PluginConfig.memoryReflection - Serial guard now reads cooldown from cfg.memoryReflection.serialCooldownMs - Default: 120000ms (2 min), set to 0 to disable Schema additions (openclaw.plugin.json): - memoryReflection.serialCooldownMs (integer, min: 0) - memoryReflection.excludeAgents (string array) - autoRecallExcludeAgents (string array, top-level) EF1 (backtick fix already present in upstream 0988a46)
…eclaredAgents validation - Add isChatIdBasedAgentId() helper: pure-digit IDs (e.g. "657229412030480397") are almost always chat_id extractions and cause 60s auto-recall timeout - Add isInvalidAgentIdFormat() with three-layer guard: empty check → numeric check → declaredAgents Set lookup (authoritative, from openclaw.json) - Add declaredAgents Set (IIFE) populated from cfg.agents.list in config return - Add guard to all 6 hook sites: auto-recall entry, recallWork inner, auto-capture (agent_end), reflection inheritance, reflection derived+error, before_reset
新增 test/agentid-validation.test.mjs,覆蓋 Issue CortexReach#492 的修復邏輯: 測試內容: 1. Layer 1(空值檢查) - undefined / null / "" → invalid 2. Layer 2(純數字 = chat_id) - "657229412030480397" → invalid(這就是導致 60s timeout 的元兇) - "dc-channel--1476858065914695741" → NOT invalid(有字母前綴,正確) - "tg-group--5108601505" → NOT invalid 3. Layer 3(declaredAgents Set) - "main" 在清單中 → valid - 不在清單中的隨機字串 → invalid - declaredAgents 為空時 → 不主動阻擋 4. Regex 迴歸測試 - 13 個邊界案例全部驗證通過 同時更新 ci-test-manifest.mjs,將新測試加入 core-regression 測試群組。 根因對照: Issue CortexReach#492 的根本原因是 numeric chat_id(如 657229412030480397)被當成 agentId 傳入 LanceDB,導致 retriever.test() timeout。本測試確保: - 純數字 ID(Layer 2)被正確攔截 - 有效的 agent ID(dc-channel-- / tg-group--)不受影響 - declaredAgents Set 白名單邏輯正確
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1b3bd46f2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| })(), | ||
| errorReminderMaxEntries: parsePositiveInt(memoryReflectionRaw.errorReminderMaxEntries) ?? DEFAULT_REFLECTION_ERROR_REMINDER_MAX_ENTRIES, | ||
| dedupeErrorSignals: memoryReflectionRaw.dedupeErrorSignals !== false, | ||
| serialCooldownMs: parsePositiveInt(memoryReflectionRaw.serialCooldownMs) ?? DEFAULT_SERIAL_GUARD_COOLDOWN_MS, |
There was a problem hiding this comment.
Allow zero serial cooldown to disable reflection throttle
memoryReflection.serialCooldownMs is documented as “set to 0 to disable,” but this parser uses parsePositiveInt, which rejects 0 and falls back to the default 120000 ms. In configs that explicitly set serialCooldownMs: 0, reflection still remains throttled for two minutes, so command-hook reflections are unexpectedly skipped instead of running every trigger.
Useful? React with 👍 / 👎.
CI 失敗分析(3 個 Job 均無關聯 PR #687)失敗摘要
關鍵觀察三個 Job 的 Test step 都失敗在同一個 merge commit ( 建議建議開獨立 issue 追蹤這三個 upstream 既有問題,或在 |
Fix: Add isInvalidAgentIdFormat guard to runMemoryReflection (Issue #686)
Summary
Adds a missing
isInvalidAgentIdFormat()guard torunMemoryReflection, making it consistent with the other 5 hook sites that all have this check.Changes
index.ts—runMemoryReflectioncommand hook:Why this matters
All other hook sites in PR #516 have
isInvalidAgentIdFormat()as a 前置 guard:before_prompt_build(auto-recall) — ✅ has guardbefore_prompt_build(recallWork) — ✅ has guardbefore_prompt_build(auto-capture) — ✅ has guardbefore_prompt_build(reflection inheritance) — ✅ has guardbefore_prompt_build(reflection derived+error) — ✅ has guardbefore_reset— ✅ has guardrunMemoryReflection— ✅ now has guard (this PR)Currently protected by the
|| "main"fallback, but the explicit guard is the correct defense-in-depth pattern.Dependencies
This PR builds on #516. It should be reviewed and merged after #516.
Links