Reflect and Contradict: Consolidating Knowledge Without an LLM
Two pipelines that make memory better over time. Reflection turns episodes into insights, and contradiction detection catches conflicting beliefs. Both work with or without an LLM.
After 40 conversations about one customer an agent holds 40 observations. Some agree, some conflict, and none state the pattern. We run two pipelines over the store: reflection turns clusters of episodes into insights, and contradiction detection flags pairs of memories that cannot both be current. Each has a route that needs no LLM inside the engine, because the calling agent does the reasoning.
Reflection: prepare, then commit
reflect-prepare collects up to 500 episodes for an entity (or globally), clusters their embeddings with k-means into at most 50 clusters, choosing k by silhouette score, and returns each cluster with its memories and ready-made prompts. No model is called. The agent reads the clusters, decides what the pattern is, and calls reflect-commit with a session ID, the insight text, a confidence, and the source memory IDs, which must come from the prepare output. Sessions expire after 10 minutes. Each insight is stored as a memory of kind INSIGHT with INSIGHT_FROM edges to its sources, and is returned by recall and prime from then on. With an LLM configured on the server, one reflect command does the same with a propose call and a validate call.
Contradiction: cheap flagging, deliberate verdicts
On every ingest the new memory is compared with its 10 nearest neighbours. Pairs with similarity of at least 0.5 go to a heuristic classifier with three signals: negation asymmetry (one side says "not", "never", "failed" and the other does not), 25 built-in antonym pairs such as reliable/unreliable and increase/decrease, and numeric disagreement in similar context ("$5,000 per tenant" against "$2,000 per tenant"). Heuristic confidence is capped at 0.75. Candidates at 0.35 or above are stored as pending records in their own column family. No edges are written at this stage.
The agent later calls contradiction-prepare, reads both snippets with the classifier score and similarity, and commits a verdict.
| Verdict | Effect on the graph |
|---|---|
| contradiction | Bidirectional CONTRADICTS edges; both memories flagged |
| revision | REVISED_FROM edge; the newer memory takes precedence in recall |
| dismiss | Pending record deleted; no edges |
With a server-side LLM the classification happens during ingest, skips the pending stage, and can report confidence up to 1.0.
Why two phases
Detection must not block ingest, and a keyword heuristic should not be allowed to rewrite the graph. Splitting flag from verdict gives both. The agent reviewing a pair also has conversation context and domain knowledge that a generic server prompt lacks. Both pipelines write typed edges, so causal recall can traverse them: restricting edge types to insight_from traces an insight to its evidence, and contradicts walks the conflicts.
