With memory enabled, the Assistant incorrectly includes data from every response node in the context #21656

Open
opened 2026-02-21 20:13:43 -05:00 by yindo · 1 comment
Owner

Originally created by @xuhl945 on GitHub (Jan 14, 2026).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.11.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Create a workflow with nodes that output status information (e.g., node Start searching /node).
  2. Enable the Memory (Conversation History) feature.
  3. Complete an initial turn of conversation where these node outputs are generated.
  4. Ask a follow-up question (multi-turn conversation).

✔️ Expected Behavior

Intermediate node metadata or system-level status outputs should be filtered out from the conversation history. Only the final user input and assistant's actual answer should be sent to the LLM to maintain clean context.

Actual Behavior

The Assistant includes the raw node output data (e.g., node.../node) in the history sent to the LLM. When using models like DeepSeek-V3.2 (which have strong pattern-following capabilities), the model begins to mimic this internal tag format in its own responses.

Image Image
Originally created by @xuhl945 on GitHub (Jan 14, 2026). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.11.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Create a workflow with nodes that output status information (e.g., [[node]] Start searching [[/node]]). 2. Enable the Memory (Conversation History) feature. 3. Complete an initial turn of conversation where these node outputs are generated. 4. Ask a follow-up question (multi-turn conversation). ### ✔️ Expected Behavior Intermediate node metadata or system-level status outputs should be filtered out from the conversation history. Only the final user input and assistant's actual answer should be sent to the LLM to maintain clean context. ### ❌ Actual Behavior The Assistant includes the raw node output data (e.g., [[node]]...[[/node]]) in the history sent to the LLM. When using models like DeepSeek-V3.2 (which have strong pattern-following capabilities), the model begins to mimic this internal tag format in its own responses. <img width="396" height="1169" alt="Image" src="https://github.com/user-attachments/assets/c197f61a-4235-4683-8440-fa49409fc45a" /> <img width="418" height="1166" alt="Image" src="https://github.com/user-attachments/assets/b8ba9e2c-3dc5-438d-a731-29ac71998dfd" />
yindo added the 🐞 bugstale labels 2026-02-21 20:13:43 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 14, 2026):

Hi @xuhl945! I'm Dosu and I’m helping the dify team.

This bug is already tracked in the Dify repo: when memory is enabled, internal node output metadata (like [[node]]...[[/node]]) is included in the conversation context sent to the LLM, causing models to mimic these tags in their responses (source). The expected behavior is that only user inputs and assistant replies should be sent to the LLM, with all intermediate node metadata filtered out (source).

The technical root cause is that the TokenBufferMemory and AgentNode classes assemble conversation history by including the full assistant message content, without filtering out internal node tags. To work around this until a fix is released, you can patch TokenBufferMemory (or the extract_thread_messages function it uses) to sanitize message.answer and remove any [[node]]...[[/node]] blocks before including messages in the LLM context (source). This will prevent node metadata from leaking into prompts and being mimicked by the model.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 14, 2026): <!-- Greeting --> Hi @xuhl945! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> This bug is already tracked in the Dify repo: when memory is enabled, internal node output metadata (like `[[node]]...[[/node]]`) is included in the conversation context sent to the LLM, causing models to mimic these tags in their responses ([source](https://github.com/langgenius/dify/blob/2bfc54314eeede0352b2abe017a1138cd488e56a/api/core/memory/token_buffer_memory.py#L27-L244)). The expected behavior is that only user inputs and assistant replies should be sent to the LLM, with all intermediate node metadata filtered out ([source](https://github.com/langgenius/dify/issues/1542)). The technical root cause is that the TokenBufferMemory and AgentNode classes assemble conversation history by including the full assistant message content, without filtering out internal node tags. To work around this until a fix is released, you can patch TokenBufferMemory (or the extract_thread_messages function it uses) to sanitize `message.answer` and remove any `[[node]]...[[/node]]` blocks before including messages in the LLM context ([source](https://github.com/langgenius/dify/blob/2bfc54314eeede0352b2abe017a1138cd488e56a/api/core/memory/token_buffer_memory.py#L27-L244)). This will prevent node metadata from leaking into prompts and being mimicked by the model. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/db117119-9d47-4da2-a83a-300e5a954338?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/db117119-9d47-4da2-a83a-300e5a954338?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/db117119-9d47-4da2-a83a-300e5a954338?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/db117119-9d47-4da2-a83a-300e5a954338?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/db117119-9d47-4da2-a83a-300e5a954338?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/db117119-9d47-4da2-a83a-300e5a954338?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/db117119-9d47-4da2-a83a-300e5a954338?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20bug%20is%20already%20tracked%20in%20the%20Dify%20repo%3A%20when%20memory%20is%20enabled%2C%20internal%20node%20output%20metadata%20%28like%20%60%5B%5Bnode%5D%5D...%5B%5B/node%5D%5D%60%29%20is%20included%20in%20the%20conversation%20context%20sent%20to%20the%20LLM%2C%20causing%20models%20to%20mimic%20these%20tags%20in%20their%20responses%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/2bfc54314eeede0352b2abe017a1138cd488e56a/api/core/memory/token_buffer_memory.py%23L27-L244%29%29.%20The%20expected%20behavior%20is%20that%20only%20user%20inputs%20and%20assistant%20replies%20should%20be%20sent%20to%20the%20LLM%2C%20with%20all%20intermediate%20node%20metadata%20filtered%20out%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/issues/1542%29%29.%0A%0AThe%20technical%20root%20cause%20is%20that%20the%20TokenBufferMemory%20and%20AgentNode%20classes%20assemble%20conversation%20history%20by%20including%20the%20full%20assistant%20message%20content%2C%20without%20filtering%20out%20internal%20node%20tags.%20To%20work%20around%20this%20until%20a%20fix%20is%20released%2C%20you%20can%20patch%20TokenBufferMemory%20%28or%20the%20extract_thread_messages%20function%20it%20uses%29%20to%20sanitize%20%60message.answer%60%20and%20remove%20any%20%60%5B%5Bnode%5D%5D...%5B%5B/node%5D%5D%60%20blocks%20before%20including%20messages%20in%20the%20LLM%20context%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/2bfc54314eeede0352b2abe017a1138cd488e56a/api/core/memory/token_buffer_memory.py%23L27-L244%29%29.%20This%20will%20prevent%20node%20metadata%20from%20leaking%20into%20prompts%20and%20being%20mimicked%20by%20the%20model.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31022)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21656