Issue: runMemoryReflection missing isInvalidAgentIdFormat guard
Problem
The runMemoryReflection command hook in index.ts lacks a isInvalidAgentIdFormat() guard before calling isAgentOrSessionExcluded(). This creates an inconsistency with the other 5 hook sites that all have this guard.
Affected location: index.ts:3507 (approximate line, within runMemoryReflection)
Current code:
const sourceAgentId = parseAgentIdFromSessionKey(sessionKey) || "main";
// ⚠️ Missing isInvalidAgentIdFormat guard here
const excludePatterns = config.memoryReflection?.excludeAgents;
if (excludePatterns && isAgentOrSessionExcluded(sourceAgentId, sessionKey, excludePatterns)) {
api.logger.debug?.(`memory-reflection: command hook skipped (excluded agent=...)`);
return;
}
Why this matters
- All other 5 hook sites (
before_prompt_build × 4, before_reset × 1) have isInvalidAgentIdFormat() as a前置 guard
runMemoryReflection is the only site that jumps directly to isAgentOrSessionExcluded() without the format check
- Currently protected by
|| "main" fallback, but this is fragile defense-in-depth
- A future refactor removing the fallback would expose a potential issue
Proposed fix
Add isInvalidAgentIdFormat guard before isAgentOrSessionExcluded:
const sourceAgentId = parseAgentIdFromSessionKey(sessionKey) || "main";
// ✅ Add format validation guard (consistent with other hook sites)
if (isInvalidAgentIdFormat(sourceAgentId, config.declaredAgents)) {
api.logger.debug?.(
`memory-reflection: command hook skipped — invalid agentId '${sourceAgentId}'`,
);
return;
}
const excludePatterns = config.memoryReflection?.excludeAgents;
if (excludePatterns && isAgentOrSessionExcluded(sourceAgentId, sessionKey, excludePatterns)) {
api.logger.debug?.(
`memory-reflection: command hook skipped (excluded agent=${sourceAgentId}, sessionKey=${sessionKey ?? "(none)"})`,
);
return;
}
Context
Labels
bug, good first issue
Issue: runMemoryReflection missing isInvalidAgentIdFormat guard
Problem
The
runMemoryReflectioncommand hook inindex.tslacks aisInvalidAgentIdFormat()guard before callingisAgentOrSessionExcluded(). This creates an inconsistency with the other 5 hook sites that all have this guard.Affected location:
index.ts:3507(approximate line, withinrunMemoryReflection)Current code:
Why this matters
before_prompt_build× 4,before_reset× 1) haveisInvalidAgentIdFormat()as a前置 guardrunMemoryReflectionis the only site that jumps directly toisAgentOrSessionExcluded()without the format check|| "main"fallback, but this is fragile defense-in-depthProposed fix
Add
isInvalidAgentIdFormatguard beforeisAgentOrSessionExcluded:Context
Labels
bug, good first issue