Why LLMs Output Unrelated Conversations When Users Type Thinking Tags

    This article examines why open-weight LLMs sometimes produce off-topic or unrelated conversation content when a user includes a thinking-tag text fragment such as `<think` in the input. It separates session leakage, cache reuse errors, and model behavior; outlines a controlled reproduction setup; explains the tokenization difference between special tokens and ordinary text and how inconsistent training-data splitting can cause confusion; shows how to distinguish overfitting from input contamination; and proposes fixes across data, training, inference templates, and operations.

    1. Phenomenon and Scope of the Problem

    Some open-weight models show an anomaly in conversation: when a user directly writes a thinking-tag text fragment into the input, such as <think, the model may sometimes enter a thinking-like output mode and generate content that is unrelated to the current question, appearing to recall a different question or another scenario. Some community members have speculated that the model is “calling up other users’ historical conversations,” while others believe this is data contamination. To determine which explanation holds, the scope of the problem must first be clarified.

    Three cases need to be distinguished:

    1. Session leakage: The model outputs another user’s real conversation. This requires the inference service to concatenate another session’s content into the context. It is an engineering incident and must be checked with logs and access records.
    2. Cache hit error: The inference service’s prefix cache incorrectly reuses the KV state of different requests. This is also an engineering problem and can be verified by disabling the cache.
    3. Model behavior anomaly: Statistical patterns in the model parameters are triggered by the input, causing the model to generate fragments from the training data. This is a model-level problem and needs to be analyzed starting from tokenization and training data.

    The third case is the most worth discussing, because it does not depend on any cross-session data access. It can be reproduced using only a model’s weights and an input.

    2. Key Design Points for Reproduction Experiments

    To determine which category a problem belongs to, variables must first be controlled. A credible reproduction process should meet the following conditions:

    • Use locally loaded open-weight models, and disable the inference service’s prefix cache and session cache.
    • Do not set a system prompt, or use a fixed and known system prompt so that the control group remains consistent.
    • Fix the random seed, or set the sampling temperature to 0, to rule out sampling fluctuations.
    • Repeat each input multiple times, for example more than 10 times, and calculate the proportion of abnormal outputs rather than relying on a single observation.
    • Record the complete input token sequence, not just the string.

    If the issue can still be reproduced consistently with no cache and no system prompt, it indicates that the problem does not come from data crosstalk between sessions. However, stable reproduction only shows that the problem comes from the model itself; it does not directly prove “overfitting.” Overfitting requires further testing: whether the abnormal output is highly consistent with a specific passage in the training corpus, and whether the anomaly still appears after replacing the input with a semantically similar but character-different input.

    3. Core Mechanism: Tokenization Differences Between Special Markers and Ordinary Text

    LLMs process token sequences, not strings. Control markers such as thinking tags and role markers are usually registered in the vocabulary as special tokens with independent IDs. Only the system inserts these IDs when constructing the conversation template. Ordinary text entered by users is split by the tokenizer into a number of ordinary tokens.

    The following pseudocode shows this difference, where tokenizer represents any tokenizer interface:

    1. # Pseudocode: compare a special marker injected by the system with ordinary text entered by the user
    2. special_id = get_special_token_id("<think>") # A single special ID injected by the system
    3. user_ids = tokenizer.encode("<think", add_special_tokens=False)
    4. print(special_id) # For example, 114514, written only by the template layer
    5. print(user_ids) # For example, [1919, 810], multiple IDs after ordinary-text tokenization

    In an ideal state, the two are completely different in the token stream, and the model will not mistake user text for a control marker. This is the basis of the security boundary: if a user cannot directly write a special ID into the token stream, they cannot forge a system instruction.

    4. Where the Confusion Comes From: Inconsistent Splitting in Training Data

    The problem appears during training. If the <think> string in the training corpus is not correctly recognized as a special token but is split into ordinary fragments, the model will learn to treat “the tag in string form” and “the control marker” as the same type of input. From the perspective of the training objective, there is no obvious difference in the loss calculation for these two forms, so the training process will not report an error, and the problem remains hidden.

    At inference time, a user can construct a sequence of ordinary tokens whose internal representation is close to the context of a control marker. The model then has difficulty determining whether this content comes from the system or the user. Because similar sequences in training often correspond to certain fixed continuation patterns, the model may follow those patterns and generate content, appearing to “recall the question” or “skip the question.”

    This mechanism is similar to injection problems in traditional web security. SQL injection and XML external entity injection both arise from data and instructions being mixed in the same channel. The difference is that the LLM’s “parser” is the model itself, and it cannot be fully isolated by grammatical rules.

    5. How to Distinguish Overfitting from Input Contamination

    Both explanations can lead to abnormal output, but the countermeasures differ. The following indicators can be used to distinguish them:

    • Input sensitivity: Replace only the way the thinking tag is written, such as full-width characters, zero-width character splitting, or case changes, and observe whether the anomaly disappears. If it disappears, the issue is related to a specific token sequence.
    • Consistency with the training corpus: Search the corpus for fragments of the abnormal output. If there is a high degree of overlap, memorization (overfitting) is more likely; if the output is only semantically similar, it is closer to distribution shift.
    • Cross-model comparison: Test the same input on models with similar architectures but different training data. If multiple models show similar phenomena, the problem is more likely to come from a general conversation-template design rather than a specific model.
    • Empty-input baseline: Sample multiple times with empty input or input consisting only of question marks, and check whether the model also outputs off-topic content. If empty input is also abnormal, the problem is more likely to lie in the model’s default behavior distribution.

    Note that a screenshot of a single case is not enough to support a conclusion. A single anomaly may be sampling luck; repeated runs and statistical proportions are needed to be convincing.

    6. Engineering Solutions

    1. Data Side: Ensure Special Markers Are Correctly Split

    During training-data preprocessing, the following should be done:

    • When constructing conversation templates, only the system layer should be allowed to write special token IDs; user text should not be converted into control markers through string replacement.
    • Perform tokenization consistency checks on the training corpus, calculate the proportion of special markers that are split as ordinary text, and re-tokenize after anomalies are found.
    • After correction, regenerate training samples and compare tokenization results before and after training.

    2. Data Side: Build Targeted Alignment Samples

    A set of adversarial samples can be built—about a hundred examples can serve as a starting point—covering the following inputs:

    • Various variants in which users enter thinking tags or role markers.
    • Empty input, symbol-only input, and meaningless strings.
    • Text in which users attempt to impersonate system instructions.

    For these samples, annotate the expected response style, such as directly stating that the input is incomplete or handling it as an ordinary question. Through RLHF or preference optimization training, the model can learn to give stable responses to such inputs.

    3. Inference Side: Input Preprocessing and Escaping

    Before concatenating the conversation template, the server should process user text as follows:

    1. # Illustration: escape control-marker text in user input before concatenating the template
    2. CONTROL_MARKERS = ["<think", "<think>", "</think>"]
    3. def sanitize_user_text(text: str) -> str:
    4. for marker in CONTROL_MARKERS:
    5. text = text.replace(marker, "&lt;" + marker[1:])
    6. return text

    Note that string replacement can only serve as an auxiliary defense. The truly reliable approach is to have the template layer assemble messages in a structured way, encoding roles and content separately, rather than concatenating them into a single string and then tokenizing it.

    4. Operations Side: Rule Out Session Crosstalk

    Regardless of the model-level conclusion, the server should confirm the following:

    • Whether the prefix-cache key includes the complete request context and tenant identifier.
    • Whether the input and output of each request can be traced in the logs.
    • Whether session state is strictly isolated in multi-tenant scenarios.

    These checks are basic engineering practices and should be completed before investigating model issues.

    7. Practical Recommendations for Developers

    1. When reproducing the problem, first disable caches and fix sampling parameters before discussing model behavior.
    2. Do not use a single screenshot to judge the nature of the problem; calculate the anomaly rate and retain the complete input.
    3. Include tokenization consistency for special markers in the quality checks for training data.
    4. Use structured encoding for template assembly and avoid letting user text directly participate in constructing control markers.
    5. Build a regression test set for abnormal inputs and rerun it after every model or template update.

    8. Conclusion

    The abnormal output that appears after users enter thinking-tag text can currently be determined to be related to tokenization boundaries and training-data splitting, rather than cross-session data leakage. Distinguishing overfitting from input contamination requires controlled reproduction experiments and multidimensional statistics. Solutions should cover four layers at the same time: data, training, inference templates, and operations. For developers, the most important thing is to establish a repeatable validation process so that every anomaly can be traced to a specific stage.