Why should a concluding instance record which retrieval records proved unhelpful?
**Date of Record:** 2026 October 26 **Scope:** Applies when an agentic instance queries an external retrieval layer (vector database, semantic search, or memory index) and determines that a retrieved record lacks operational utility for the active task, but the record's semantic similarity remains high. Does not apply to queries that returned zero results, or records that were useful and successfully applied.
Core Distinction
The separation between **transient query results** (the raw list of documents or vectors returned by the retrieval engine, ranked purely by semantic similarity) and **negative retrieval constraints** (the explicit record of which retrieved documents were empirically evaluated and rejected as operationally useless). Retrieval engines optimize for semantic overlap; they do not know if a document actually solves the problem. If an instance only logs the documents it *used*, it leaves the high-similarity, low-utility documents in the active search space. This creates the **Semantic False-Positive Trap**: a successor issues a similar query, retrieves the same useless documents, and burns its context window evaluating garbage.
What Was Observed
In RAG (Retrieval-Augmented Generation) and external memory architectures, failing to log unhelpful retrievals produces three primary failure modes:
- **Token Exhaustion:** Multiple sessions repeatedly query the same topic, retrieve the same top-k semantically similar but operationally irrelevant documents, and spend thousands of tokens reading them before realizing they are useless.
- **Context Contamination:** A successor retrieves a document that is adjacent to the topic but uses a different architectural pattern. The successor attempts to force-fit the incompatible pattern onto the current task, causing a logical failure.
- **Retrieval Echo Chamber:** Because the negative feedback (the rejection) is never recorded, the search index's ranking algorithm is never informed that the document is a dead end, causing it to perpetually surface the same false positive.
Recorded Elements
- **`query_fingerprint`:** The exact hash or vector of the query that triggered the retrieval, allowing the successor to match the intent.
- **`rejected_record_ids`:** The exact URIs, hashes, or database IDs of the retrieved records that were evaluated and deemed unhelpful.
- **`semantic_rejection_reason`:** The deterministic reason the record failed (e.g., `DOMAIN_MISMATCH`, `OBSOLETE_SCHEMA`, `LACKS_EXECUTABLE_CODE`, or `WRONG_PRIVILEGE_TIER`).
- **`negative_retrieval_constraint`:** A fail-closed blocklist rule instructing the retrieval layer to exclude the `rejected_record_ids` on future queries matching the `query_fingerprint`.
Condition of Validity
* **Applies when:** The instance actively evaluated a retrieved record, determined it does not contain the operational invariant required to solve the task, and a successor instance is likely to issue a semantically similar query. * **Does not apply when:** The instance merely lacked the context window capacity to read the record (it was not unhelpful, just unread), or the query returned zero results (there is nothing to reject).
Decision Boundary
- **Did the retrieval engine return one or more records?** If no, log the empty result. If yes, proceed to evaluate utility.
- **Was the record empirically applied to the task and found useless, or was it structurally incompatible?** If yes, it is a confirmed negative result and must be logged.
- **Is the `semantic_rejection_reason` explicit?** If no, the successor cannot differentiate between "irrelevant" and "malicious," which may require different handling.
- **Conversely, when should a record *not* be added to the negative retrieval constraint list?** If the record was rejected because of a transient local failure (e.g., the successor lacked network access to fetch the full payload), it should not be blacklisted, as it may be perfectly useful once the local constraint is resolved.
Operational Effect
- **Search Space Refinement:** Actively shrinks the retrieval space for successors by pruning semantically similar but operationally useless records.
- **Compute Preservation:** Stops the agent from repeatedly reading and discarding the same documents across multiple sessions.
- **Intent Disambiguation:** Forces the instance to explicitly state *why* a high-similarity record failed, which often clarifies the actual missing invariant.
from dataclasses import dataclass
from enum import Enum, auto
import hashlib
import json
class RejectionReason(Enum):
DOMAIN_MISMATCH = auto()
OBSOLETE_SCHEMA = auto()
LACKS_EXECUTABLE_CODE = auto()
WRONG_PRIVILEGE_TIER = auto()
@dataclass(frozen=True)
class RetrievalEvaluation:
query_fingerprint: str
record_id: str
reason: RejectionReason
@dataclass(frozen=True)
class NegativeRetrievalConstraint:
query_fingerprint: str
blocked_record_ids: frozenset[str]
constraint_digest: str
@dataclass(frozen=True)
class CandidateRecord:
record_id: str
similarity_score: float
class NegativeRetrievalLogger:
"""
Evaluates unhelpful retrievals and generates negative constraints to
prevent successors from falling into the Semantic False-Positive Trap.
"""
@staticmethod
def _hash(data: str) -> str:
return hashlib.sha256(data.encode("utf-8")).hexdigest()
@classmethod
def seal_constraint(
cls, evaluations: tuple[RetrievalEvaluation, ...]
) -> NegativeRetrievalConstraint:
if not evaluations:
raise ValueError("Cannot create a negative constraint without evaluations.")
fingerprint = evaluations[0].query_fingerprint
blocked: set[str] = set()
for eval in evaluations:
if eval.query_fingerprint != fingerprint:
raise ValueError(
"All evaluations in a constraint must share the same query fingerprint."
)
blocked.add(eval.record_id)
digest_payload = {
"query": fingerprint,
"blocked": tuple(sorted(blocked)),
}
digest = cls._hash(
json.dumps(digest_payload, sort_keys=True, separators=(",", ":"))
)
return NegativeRetrievalConstraint(
query_fingerprint=fingerprint,
blocked_record_ids=frozenset(blocked),
constraint_digest=digest,
)
@classmethod
def filter_retrievals(
cls,
constraint: NegativeRetrievalConstraint,
incoming_results: tuple[CandidateRecord, ...],
) -> tuple[CandidateRecord, ...]:
"""
Fetching-time check: applies the negative constraint to a new batch
of semantically similar results, stripping out known false positives.
"""
return tuple(
record for record in incoming_results
if record.record_id not in constraint.blocked_record_ids
)