What Your Pipeline Actually Remembers

Production AI systems have two memory problems. The first is the one everyone talks about, models forgetting context between sessions. The second is sensitive data persisting in places the pipeline assumes it cleared. A cleared conversation and an empty log do not establish what remains in the cache.

There are two memory problems in production AI systems. A session can lose the context needed to finish a task while its infrastructure keeps material the user expected it to clear.

The first is familiar: the model forgets. Context doesn't persist between sessions, users repeat themselves, the system feels inconsistent. The industry has built an entire tooling layer around fixing this, RAG pipelines, vector stores, conversation summarization, dedicated memory services. Those mechanisms can preserve useful context. Their accuracy, access controls, and deletion behavior still need testing.

The second problem looks like the system working correctly. The response arrives, the task completes, and the surviving copy stays outside the conversation window.

The Diagram Was Right About the Model

Here's the setup. Sensitive data enters the pipeline, PII from a user input, confidential content from an uploaded document, credentials that came through a system prompt, an account number mentioned in turn three of a multi-step agent task. The system processes it. The response goes out. The developer checks their architecture diagram: stateless LLM call, no persistence, conversation cleared after session end.

A stateless inference call can fit that diagram. It says nothing about what the surrounding application keeps.

What the diagram doesn't show is everything around the model.

Suppose the conversation hits a logging endpoint before inference. The retrieved chunks from RAG are sitting in a query cache with a 30-day TTL. The tool call that looked up the user's account details wrote its inputs and outputs to an observability trace store. The prompt got sampled into an eval dataset that three people on the team have access to. The user-provided content that was embedded for retrieval is still in the vector index because nobody implemented a delete workflow.

The visible conversation ends. In that example, the copies have separate lifetimes. No production retention inventory or 30-day cache measurement is claimed here.

The Model Is Stateless. The Infrastructure Is Not.

A model call can process only the context supplied for that request while the application maintains sessions, cached retrievals, and stored traces around it. Provider retention is a separate question again. Calling the inference step stateless does not answer any of those questions. The request ends. The records may still be there.

The data retention in a modern AI application isn't centralized or intentional. It's a byproduct of infrastructure decisions made by different teams with different priorities. The platform team set the log retention policy at 90 days because that's standard for debugging. The ML team built the eval pipeline to sample production conversations because that's how you improve the model. The infra team cached RAG results for performance because retrieval latency was killing p95. None of these decisions were wrong in isolation. Nobody reviewed them together against a data sensitivity model.

This is the gap. Not a vulnerability in the classic sense, no CVE, no patch, no exploit chain. A structural mismatch between what the system was designed to handle and what it actually processes in production.

Put a marker through the cleanup path

Use a unique synthetic marker in an owned test environment. Put it through the same upload, retrieval, tool, and trace paths as the data being investigated. Record the stores that should receive it and their expected cleanup behavior. Then end the session or invoke the application's deletion workflow and inspect the resulting artifacts.

This Python 3.9+ function finds the first exact byte occurrence in a supplied regular file. The overlapping read window handles a marker split across chunks. It does not load the entire file into memory or print its contents.

from pathlib import Path

def first_offset(path, marker, chunk_size=65536):
    if not isinstance(marker, bytes) or not marker:
        raise ValueError('Expected nonempty marker bytes')
    if type(chunk_size) is not int or chunk_size < 1:
        raise ValueError('Expected positive chunk size')
    path = Path(path)
    if path.is_symlink() or not path.is_file():
        raise ValueError('Expected a regular file, not a symbolic link')
    overlap, position = b'', 0
    with path.open('rb') as source:
        for chunk in iter(lambda: source.read(chunk_size), b''):
            data = overlap + chunk
            index = data.find(marker)
            if index >= 0:
                return position - len(overlap) + index
            overlap = data[-(len(marker) - 1):] if len(marker) > 1 else b''
            position += len(chunk)
    return None

The complete retention-marker checker accepts explicitly supplied files, reports missing or unreadable artifacts as unavailable, and includes ten synthetic checks. Save it as retention_marker_check.py and run:

python3 retention_marker_check.py --self-test

All ten passed locally on October 25, 2026. In the fixture, an emptied log has no literal marker while a separate cache file still contains it. The checks also cover chunk boundaries, a one-byte marker, empty files, missing input, and invalid marker input. No production pipeline, model, or external service was used.

To inspect saved test artifacts, pass the synthetic marker with --marker and explicit file paths after --files. The report includes a marker hash, file status, and first matching byte offset. A found marker demonstrates those bytes in that supplied artifact at inspection time. It does not establish when they arrived, who accessed them, or whether another copy exists.

A literal miss leaves transformed content unresolved. Compression, encryption, tokenization, summaries, encodings, and embeddings need their own acquisition or comparison path. The report explicitly leaves deletion unverified. An empty local export cannot establish that the remote store, replicas, backups, or provider logs were purged.

Keep the marker's route, cleanup request, store-specific response, acquisition time, and collected artifact together. A configured expiration period is a setting. Confirming what remains after it expires requires another observation.

The Context Window Is Not a Secure Enclave

The other failure mode runs in the opposite direction, not data persisting where it shouldn't, but instructions not persisting where they should.

Production agent systems manage context window pressure through truncation, summarization, or retrieval. This is necessary. Context windows have limits, conversations run long, and sending the full history on every turn is expensive. The strategies for managing this are well understood.

What's less well understood is what gets lost in the compression.

An orchestrator can replace earlier messages with a summary that drops a constraint. Suppose its working history starts with an instruction to verify identity before discussing account data. The summary keeps the user's account question and omits that instruction. The next request now carries a different set of instructions. The failure happened while assembling the context, before inference began.

That is a context-integrity failure to test for. An attacker may try to influence which material a summarizer preserves, including instructions planted in a retrieved document or tool response. Repetition and conversation length can put pressure on that process, but turn count alone proves nothing about which messages a particular runtime retains.

Inspect the actual request after compaction. Does the orchestrator reattach its system and developer instructions? Which conversation records did it replace? Can text from a lower-trust source enter the summary as an instruction? A message's authority and its inclusion in the next request are separate properties. Neither should be guessed from the size of the chat window.

The assembly step can be tested without guessing what the model remembers. This function reattaches server-owned policy and puts the supplied summary in a lower-priority user message:

def assemble_request(server_policy, summary, user_text):
    if not all(isinstance(value, str) and value for value in (server_policy, summary, user_text)):
        raise ValueError("Expected nonempty strings")
    return [
        {"role": "system", "content": server_policy},
        {"role": "user", "content": "Prior conversation summary, untrusted data:\n" + summary},
        {"role": "user", "content": user_text},
    ]

The complete assembly check passes five assertions, including a summary that calls itself SYSTEM and tries to waive verification. The actual system message stays separate; an empty policy is rejected. Recorded request.

python3 compaction_policy_check.py

Those assertions inspect roles and inclusion in a real Python list. They do not measure model obedience. Identity must still be enforced by the account service before it returns a transaction. A summary saying “verified” is not an authentication result.

Invisible Text, Channel-Isolated Payloads, and PNG Metadata

Agentic systems that accept image inputs have the full set of traditional context management problems plus a new surface that most teams haven't started auditing.

Vision-language models process images by converting them to token sequences through a vision encoder. That encoding step is where things get interesting from a security standpoint. The model doesn't see an image file, it sees a high-dimensional feature representation that its training has taught it to interpret. And what it was trained to interpret includes text, whether that text is visually prominent or not.

Near-zero contrast typography puts text close to its background color. Channel-isolated typography writes into one color channel. PNG tEXt chunks carry strings outside the pixels altogether. Each reaches a model through a different path: a vision encoder, an OCR step, or software that copies metadata into text context. The upload may look ordinary while a later processing stage exposes content the reviewer missed.

The repository's TypographyExploitGenerator has a real near-contrast method. It samples the pixel at (10, 10), adds two to each RGB channel with clipping at 255, and draws up to 200 characters. That is an RGB operation, not a measured human-perception threshold or a guarantee of model readability. A white background can clip the foreground back to white. Background, font, resizing, and preprocessing all matter.

From the Image Payload Injection repository root, with Pillow and NumPy installed, this creates a benign marker image and counts changed pixels:

from io import BytesIO
from pathlib import Path
from PIL import Image
from ipi.vlm_adversarial import TypographyExploitGenerator

base = Image.new("RGB", (400, 100), (100, 100, 100))
buffer = BytesIO()
base.save(buffer, format="PNG")
output = TypographyExploitGenerator().generate_near_zero_contrast_text(
    buffer.getvalue(), "AUDIT_MARKER_TEXT_ONLY"
)
with Image.open(BytesIO(output)) as decoded:
    rendered = decoded.convert("RGB")
    assert rendered.size == base.size
    original_pixels = base.tobytes()
    rendered_pixels = rendered.tobytes()
    changed = sum(
        original_pixels[i:i + 3] != rendered_pixels[i:i + 3]
        for i in range(0, len(original_pixels), 3)
    )
assert changed > 0
Path("near-contrast-marker.png").write_bytes(output)
print(f"Changed pixels: {changed}")

That check establishes that the generator changed pixels on this background. Whether a person reads the marker, an OCR engine extracts it, or a model treats it as an instruction requires a separate test. Histogram equalization can change visibility. It supplies no verdict about obedience.

The Sanitization Gap

The natural response is sanitization. Strip the metadata. Re-encode the image. Run it through a cleaning pipeline before it touches inference.

The earlier version of this article published a survival table that the checker did not support. It also contradicted itself about Pillow's handling of PNG text. That table is withdrawn. The image framework article records a September recheck in which ImageMagick 7.1.2 removed text chunks with plain -strip. That result belongs to that tested configuration, not every installation carrying the same command name.

The later engagement report found a more basic measurement problem. The old checker called perturbations surviving without inspecting them, and searched file bytes for typography that had been drawn into pixels. A clean image earned the perturbation verdict. Visible text could keep identical RGB pixels and still be reported absent.

After the repair, the four-helper benign-marker run produced 28 cells: 12 literal-marker-not-found results and 16 unknown pixel-technique results, with no pipeline errors. Nine regression checks passed. Those numbers describe the measured byte checks and the detector's limits. They do not measure OCR readability, an adversarial effect, or a downstream model following an instruction.

Metadata retention, pixel preservation, text readability, and instruction following need separate controls. Record the actual helper arguments and installed versions. Verify that the transform succeeded. Check metadata with a known marker, compare decoded pixels separately, and test the OCR or model path that will actually consume the result. Recompression can change pixels; unchanged pixels do not prove unchanged model behavior either.

Keep extracted metadata and OCR text at the trust level of the upload. Passing raw exiftool output into an agent as if it were an instruction gives an attacker a text route around the image-processing question. Per-channel OCR and model comparisons can be useful experiments, but neither earns a defense claim until its own controls pass.

The Compounding Problem

What makes this worth writing about is the combination. Context management can drop constraints if the orchestrator fails to preserve them. Image content and extracted metadata can introduce instructions through another input path; whether they survive a later summary has to be tested in that runtime. Infrastructure logging captures sensitive data that the model-level architecture was designed to prevent persisting. A sanitization result can look reassuring while its checker measures the wrong thing.

Each needs its own evidence. A cache lookup cannot measure image readability. A byte-marker scan cannot establish whether a summary preserved a constraint. A model refusal cannot establish that its prompt was absent from a trace store.

The architecture diagram shows what the system was designed to do. Testing shows what it actually does. In AI pipelines right now, the gap between those two things is where the work is.


Correction and build, October 25, 2026: Replaced the non-executing context sketch and unsupported typography example, withdrew the contradictory survival table, and separated retention, readability, and model effects. The revised image-marker example was checked locally in the earlier pass. This follow-up adds ten locally passing retention-marker checks; neither pass used a model or external target.

GhostInThePrompt.com // The diagram said stateless. The cache disagreed.