Two distinct symptoms, both silent — no exception, no failed request, fluent output throughout.
Two distinct symptoms, both silent — no exception, no failed request, fluent output throughout.
The two symptoms are independent: the first is a read-path defect, the second a write-path defect. They are recorded together because they shipped together and because both come from the same underlying habit — letting a stored or defaulted value stand in for something that was never verified.
What makes this class expensive is that the failure is invisible in the output. The prose is fluent, the format is correct, and nothing anywhere reports a fault. The only observable is that the story quietly stops being true to its own world state.
Scene state is written once when a scene is established and read back on every subsequent turn. Between the write and the read, the world moves: entities leave, are dispatched, die, get dismissed. The read path did the obvious thing — fetch the blob, concatenate it into the system prompt:
state = store.get(SCENE_STATE_KEY) # a snapshot of one past moment
system_prompt += state.narrative # no diff, no TTL, no membership checkThe missing invariant is: every entity named in injected state must be present in the current roster at the moment of injection. The store is permitted to be stale. The prompt is not.
Why this fails silently rather than obviously: injected context carries no provenance. To the model, a sentence in a system prompt is indistinguishable from a rule it is obliged to obey. Stale presence is not a weak hint competing with a stronger signal — it is a fact stated in the most authoritative position the prompt has, and the user turns that contradict it carry strictly less weight. The effect compounds with session length: the same stale claim is re-injected every turn, so a single wrong sentence accumulates more in-context repetitions than any correction the user can make in one message.
The trust inversion is the real hazard. A store read is a cache lookup, and cache reads are treated as cheap and safe, so the value goes straight into the highest-trust slot in the prompt. Anything crossing that boundary from storage to instruction needs an explicit check, because the boundary is precisely where a cached value silently acquires authority it was never verified for.
The hook that post-processes a message has to emit a speaker field. When its resolution path fell through, it emitted the protagonist's id.
A default in an attribution field is not a neutral placeholder. It is a positive assertion that the protagonist produced that line — and once persisted, it is byte-identical to a correct attribution. Nothing downstream can tell a guessed speaker from a resolved one, which means the corruption is invisible to every reader, including the person debugging it weeks later.
Filter at read time, every turn — not at write time. Write time does not know the future roster, so a write-time filter reproduces the same staleness one turn later. The read is the only point where the current roster is actually known.
The submitter's implementation puts this filter in a store wrapper (named
FilterAbsentFromPhysicalin their codebase) called from their protagonist prompt builder. The name is local to that project; the mechanism is the filter and its call site.
def build_scene_state(store, roster, now):
state = store.get(SCENE_STATE_KEY)
if not state:
return ""
present = {e.id for e in roster if e.active_at(now)}
kept, dropped = [], []
for sentence in split_sentences(state.narrative):
named = entities_in(sentence) # ids, not display names
if named and not (named & present):
dropped.append(sentence)
else:
kept.append(sentence)
parts = ["\n".join(kept)]
if dropped:
# Say what was removed. Silence would let the model re-infer presence
# from the gap, which is the same bug wearing a different hat.
parts.append("Not present in this scene: " + ", ".join(names_of(dropped)))
return "\n".join(p for p in parts if p)Three properties that matter more than the specific code:
The submitter's fix threads a resolved speaker object through their NPC-extraction hook (their
npcExtractionHook, via aMessageSpeakerfield). Local naming; the mechanism is the removal of the fall-through.
# Before — a fall-through attribute is a silent positive claim
def extract_speaker(msg):
return resolve(msg.candidates) or PROTAGONIST_ID
# After — unresolved is a state the caller must resolve, not a value to guess
class SpeakerUnresolved(Exception):
pass
def extract_speaker(msg):
hit = resolve(msg.candidates)
if hit is None:
raise SpeakerUnresolved(msg.id) # never substitute the protagonist
return hitThe rule generalizes past speaker fields: in an attribution field, unknown is a legal value and a default is not. An unresolved speaker must fail at the point of resolution, where a human or a retry can still see it, rather than being filled in downstream where it becomes indistinguishable from a real answer.
Evidence boundary, stated up front: the submission is a single-node report and carries no reproduction script, no log excerpt, and no before/after count. The two behavioural outcomes described below are what the submitter observed in their own deployment. Nothing here is a result reproduced elsewhere, and no numbers are claimed.
What the submitter reports observing after the change: entities that had left the scene stopped being narrated as present, and NPC-authored lines carried their own speaker label rather than the protagonist's.
The rest of this section is the criterion set a reader can apply in their own system. These are tests to run, not results already obtained.
Checks 1–2 isolate the read path and check 3–4 the write path, so a pass on one does not mask a failure on the other.