fix: add isInvalidAgentIdFormat guard to runMemoryReflection (Issue #686)#722
fix: add isInvalidAgentIdFormat guard to runMemoryReflection (Issue #686)#722jlin53882 wants to merge 3 commits intoCortexReach:masterfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0a00cadda
ℹ️ 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".
| // We skip them rather than block all numeric IDs to avoid false positives. | ||
| function isChatIdBasedAgentId(agentId: string | undefined): boolean { | ||
| if (!agentId) return false; | ||
| return /^\d+$/.test(agentId); |
There was a problem hiding this comment.
Allow numeric agent IDs in reflection path
The new guard marks every digits-only agentId as invalid (/^\d+$/), so runMemoryReflection now exits early for sessions like agent:123:.... That is a behavioral regression because this codebase otherwise accepts numeric agent IDs (the canonical parser in src/scopes.ts only rejects empty and reserved bypass IDs), meaning valid agents can silently lose reflection generation and memory updates after this commit. Consider restricting this check to known chat-id extraction failures (or gating it with declared-agent validation) instead of blocking all numeric IDs.
Useful? React with 👍 / 👎.
…ortexReach#686) Minimal fix addressing Issue CortexReach#686 without the scope creep of PR CortexReach#687. Changes: - Add isInvalidAgentIdFormat() guard (Layer 1: empty/undefined, Layer 2: pure numeric = chat_id) to runMemoryReflection command hook, consistent with other hook sites. - Export isInvalidAgentIdFormat for testability. - Add integration test (agentid-validation-686.test.mjs) that directly imports the production export — NOT skipped/helper-only. Layer 3 (declaredAgents Set validation) is intentionally omitted from this fix. The plugin config does not carry agents.list from openclaw.json root config; implementing Layer 3 requires proper api.config.agents access from the plugin API, which is not reliably available in all install configurations. A follow-up PR should address Layer 3 once the correct API integration path is confirmed. No schema changes, no CI manifest changes, no serialCooldownMs, no excludeAgents — focused scope on the CortexReach#686 guard only.
Add test/agentid-validation-686.test.mjs to core-regression CI group and update verify-ci-test-manifest baseline to include it.
4587aac to
140493d
Compare
- Add scope note to runMemoryReflection guard: Layer 3 omission is intentional scope discipline for CortexReach#686, not a technical limitation - Update test Layer 3 describe block to clarify 'guard call omits param' - Fix misleading comment: 'Layer 3 is no-op in this guard call' (not impl)
Summary
Adds a minimal
isInvalidAgentIdFormat()guard to therunMemoryReflectioncommand hook (Issue #686), consistent with other hook sites in the plugin. Only the #686 fix — no scope creep.Changes
index.tsrunMemoryReflectionhook guard:Exported:
isInvalidAgentIdFormat(public, for testability)New test:
test/agentid-validation-686.test.mjsisInvalidAgentIdFormatexport (not a skipped helper)runMemoryReflectionwith numeric sessionKeyCI manifest
test/agentid-validation-686.test.mjstoscripts/ci-test-manifest.mjs(required for CI to execute the new test)Scope Discipline
serialCooldownMsconfigurable cooldownexcludeAgentspattern matchingdeclaredAgentsLayer 3 in guard callsrc/reflection-store.tsmass reformatteropenclaw.plugin.jsonschema changesLayer 3 Note
Layer 3 (declaredAgents Set validation against
openclaw.json agents.list) is intentionally omitted from the guard call in this PR. This is a scope discipline decision — not a technical limitation. TheisInvalidAgentIdFormatfunction body does contain Layer 3 logic, but this PR's specific guard call passes onlysourceAgentId(Layer 1+2) to maintain a minimal fix surface area. A follow-up PR should address Layer 3 as a separate concern once the API integration path is confirmed with maintainers.Testing
node --test test/agentid-validation-686.test.mjs # → 14 tests, 0 failures, 0 skippedExisting tests still pass: