Heuristic:1jehuang Jcode Repeat Suppression
| Knowledge Sources | |
|---|---|
| Domains | Memory, Optimization |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
A 30-second deduplication window suppresses repeated memory injections, preventing the same memory from being injected twice in rapid succession.
Description
The Repeat_Suppression heuristic applies a 30-second deduplication window (REPEAT_SUPPRESSION = Duration::from_secs(30)) to memory injections. When a memory is injected into a session's context, it is tracked for 30 seconds. If the same memory would be injected again within that window, it is suppressed. This prevents the agent from receiving redundant context when the same memory is recalled multiple times in quick succession (e.g., during rapid turn cycles or periodic extraction). A separate 60-second failure backoff (FAILURE_BACKOFF) prevents retry storms when memory operations fail.
Usage
Use this heuristic when injecting memories into agent context. Track recently injected memories and suppress duplicates within the 30-second window. This is particularly relevant for the periodic extraction interval (every 12 turns) where the same memories may be recalled again.
The Insight (Rule of Thumb)
- Action: Track injected memories per-session; suppress re-injection within
REPEAT_SUPPRESSION(30s). - Value: 30-second suppression window; 60-second failure backoff; periodic extraction every 12 turns.
- Trade-off: A memory that becomes newly relevant within 30s won't be re-injected; this is acceptable because context is already present.
- Compatibility: Per-session tracking; cleared on session reset via
clear_all_injected_memories().
Reasoning
Without suppression, periodic extraction (every 12 turns) and recall triggers could inject the same memory repeatedly, wasting context tokens and potentially confusing the agent with redundant information. The 30-second window is long enough to cover rapid turn cycles but short enough to allow re-injection when context has genuinely changed. The 60-second failure backoff prevents retry storms when the memory system encounters errors.
Code Evidence
Suppression and backoff constants from crates/jcode-base/src/memory_agent.rs:14-17:
const CONTEXT_CHANNEL_CAPACITY: usize = 16;
const PERIODIC_EXTRACTION_INTERVAL: usize = 12;
const REPEAT_SUPPRESSION: Duration = Duration::from_secs(30);
const FAILURE_BACKOFF: Duration = Duration::from_secs(60);
Session reset clearing injected memories from crates/jcode-base/src/memory_agent.rs:182-186:
fn reset(&mut self) {
self.sessions.clear();
memory::clear_all_pending_memory();
memory::clear_all_injected_memories();