Troubleshooting
Common issues and solutions
Tokens Not Deanonymized in Response
Symptom: The LLM response contains raw tokens like <PERSON_1> instead of the original values.
Causes:
- Non-streaming response with no session mappings. Deanonymization only runs on streaming responses when
session.has_mappingsisTrue. If the middleware didn't detect any entities in the request, no mappings exist and deanonymization is skipped. - Synthetic strategy mismatch. If the LLM invents its own names that happen to match synthetic values, those won't be in the session map. This is expected behavior — only values generated by the anonymizer are mapped.
Fix: Verify that entities are being detected by adding an on_entities_detected callback.
NER Model Not Found
Symptom: OSError: [E050] Can't find model 'en_core_web_sm'
Fix: Download the spaCy model:
python -m spacy download en_core_web_smAnd ensure you installed the NER extra:
pip install rdakt-ai[ner]Redis Connection Refused
Symptom: ConnectionError: Error connecting to redis://localhost:6379
Fix: Ensure Redis is running and accessible at the configured URL:
redis-cli ping
# Should return: PONGImport Error for RedisStore
Symptom: ImportError: redis package is required for RedisStore
Fix:
pip install rdakt-ai[redis]Gzip Decompression Error
Symptom: zlib.error: Error -3 while decompressing data
Cause: This can happen if a proxy or CDN modifies the Content-Encoding header but doesn't actually decompress the body.
Fix: Ensure no middleware between your application and the Anthropic API is stripping or modifying encoding headers.
Custom Pattern Not Matching
Symptom: Your custom regex pattern doesn't detect entities.
Debug:
import re
pattern = r"EMP-\d{6}"
text = "Contact EMP-123456"
matches = re.finditer(pattern, text)
print(list(matches))Common issues:
- YAML requires escaping backslashes:
"EMP-\\d{6}"not"EMP-\d{6}" - Python raw strings don't:
r"EMP-\d{6}"
Streaming Latency
Symptom: Streaming responses feel delayed.
Cause: The deanonymizer buffers text when it encounters a < character that could be the start of a token. If the next chunk takes time to arrive, there's a perceived delay.
Mitigation: This is by design and only affects chunks containing potential token starts. The buffer has a 256-character safety limit. In practice, the delay is imperceptible (under 1ms) because LLM streaming chunks arrive rapidly.