Guardrails Filter Tackles Complex LLM Streaming and Tool Call Challenges to Protect Sensitive Data
Developers at Cloud.ru have shared the technical challenges encountered while building Guardrails Filter, a dedicated protection layer that prevents personal data from reaching large language models. The filter scans incoming JSON requests, locates phone numbers, email addresses, passport numbers, SNILS and names using regular expressions, and replaces them with stable placeholders such as <PHONE_1> or <PERSON_1>.
A simple substitution approach quickly proved inadequate. When two different phone numbers appear in the same conversation, replacing both with the generic token <PHONE> makes it impossible to restore the correct values after the model replies. The team therefore maintains an internal mapping table that guarantees the same real value always receives the same placeholder throughout the dialogue history.
Because LLMs are stateless between requests, Guardrails Filter must re-process the entire conversation history on every turn, rebuild the mapping table, mask the data, and then restore original values once the response arrives. With ordinary non-streaming JSON responses the task is manageable, yet streaming via SSE introduces far greater complexity.
In streaming mode, responses arrive in small chunks that may split a placeholder across multiple events. The filter therefore buffers several events until enough characters accumulate to determine whether a complete placeholder is present. Once a placeholder is identified, the original value is substituted and a new chunk is emitted to the client. This buffering adds a small latency but prevents broken placeholders from reaching users.
Tool calling adds another layer of difficulty. Model-generated function calls may contain masked values inside JSON arguments that themselves are serialized inside another JSON object. The filter must fully reconstruct each tool-call argument, validate that all braces are closed, and only then perform demasking. Failure to do so can produce invalid JSON that breaks downstream agent pipelines.
Support for the Anthropic Messages API required a completely separate implementation because its event format differs significantly from OpenAI’s Chat Completions streaming. The Messages API uses explicit lifecycle events for tool calls, while Chat Completions delivers deltas inside larger JSON objects. Separate code paths and approximately 1,000 additional lines of tests were written to handle both providers consistently.
In total, the streaming logic alone grew to roughly 1,500 lines of code, backed by more than 3,000 lines of tests. The engineering effort focused on correctly identifying the end of reasoning blocks, the completion of tool-call arguments, and the safe delivery of any remaining buffered data once the model signals the end of a response.
Related articles
How to Interact with AI Models Without Exposing Sensitive Data
The article provides practical guidance on minimizing data leakage risks when using popular AI chatbots such as ChatGPT, Gemini, Claude and GigaChat. It explains that conversations are routinely scanned by automated filters and may be reviewed by human moderators or shared with law enforcement upon request. Key recommendations include disabling model training on user data, replacing sensitive values with placeholders, regularly deleting chat histories and verifying downloaded models for malicious injections. The guide also demonstrates local deployment using Ollama and secure API integration through the ChatBox client with Cloud.ru’s Evolution Foundation Models service. Local execution in Docker containers is presented as the most private option, although it requires significant computational resources. The author stresses that even after disabling training, data may still reach moderators and that users remain responsible for their own information.
Raft Develops Multilabel Guardrail Classifier Detecting 15 Risk Categories with 3x Speed and Cost Gains
Raft has released details on a custom multilabel guardrail classifier designed to scan both incoming prompts and model outputs for 15 distinct risk categories in real time. The system handles Russian and English text while maintaining independent thresholds for each category to balance false positives against critical misses. By switching from a PyTorch baseline to TensorRT inference on NVIDIA RTX 3090 hardware, the team achieved a 2.95x reduction in single-request latency and lowered inference cost to $0.062 per million requests. The architecture uses per-category expert query tokens plus a lightweight interaction transformer to capture correlations such as those between armament and violent content. Training relied on asymmetric loss functions and post-epoch per-class threshold tuning rather than standard binary cross-entropy. Benchmarking against nine open guardrail and toxicity models showed superior macro-F1 on rare but high-impact categories while remaining an order of magnitude cheaper than external LLM judges.
Zhou Hongyi Warns AI Tools Are Industrializing Vulnerability Discovery
At the Fourth Cyberspace Security Forum in Tianjin, 360 founder Zhou Hongyi stated that vulnerability mining is shifting from artisanal workshops to automated production lines, compressing discovery cycles from months or years down to hours. AI tools such as Mythos are standardizing and automating the process, enabling attackers to replicate elite hacker expertise at scale through distilled models and agent swarms. 360's own Tulongfeng platform has already discovered over 10,000 vulnerabilities since its June release, including long-hidden high-risk flaws in Windows, Office, OpenClaw, Flowise, and Codex. The emergence of multi-agent systems introduces new attack surfaces because compromised agents can autonomously collaborate and move laterally faster than human operators. Zhou described this as the "second one-way transparency," where offensive tradecraft becomes copy-pasteable via prompts and toolchains. Defenders are advised to adopt "model-versus-model" strategies, automate vulnerability intelligence workflows with SOAR, enforce strict agent permission audits, and integrate AI into their own code review and detection engineering processes.
Anthropic Fable 5.1 System Prompt Fully Leaked Hours After Launch Exposing 275000 Characters of Rules
Anthropic released its flagship Fable 5.1 model alongside Mythos 5.1 on September 2, achieving strong benchmark scores including 90 percent on ARC-AGI-2. Within hours, researcher Pliny the Liberator published the complete 275000-character system prompt on GitHub, far exceeding the company's official 27000-word disclosure. The leaked document details 46 built-in tools, strict copyright restrictions, memory classification boundaries, and behavioral constraints that function as an internal employee handbook. The incident highlights that model weights remain the true core while prompt-based guardrails create an attack surface once mapped. It also reveals privacy rules that permanently exclude storage of minor identities, criminal records, and self-harm indicators even when users disclose them. The leak underscores the growing gap between vendor transparency claims and actual runtime instructions governing frontier AI systems.