ExperimentalMarkdownSyntaxTextSplitter mutates results returned by previous split_text calls
Author: Iris070119Created Sep 16, 2026Updated Sep 17, 2026
Labelsbugtext-splittersexternal
Submission checklist
- This is a bug, not a usage question.
- I added a clear and descriptive title that summarizes this issue.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangChain rather than my code.
- The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
- This is not related to the langchain-community package.
- I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.
Package (Required)
- langchain
- langchain-openai
- langchain-anthropic
- langchain-classic
- langchain-core
- langchain-model-profiles
- langchain-tests
- langchain-text-splitters
- langchain-chroma
- langchain-deepseek
- langchain-exa
- langchain-fireworks
- langchain-groq
- langchain-huggingface
- langchain-mistralai
- langchain-nomic
- langchain-ollama
- langchain-openrouter
- langchain-perplexity
- langchain-qdrant
- langchain-xai
- Other / not sure / general
Related Issues / PRs
No response
Reproduction Steps / Example Code (Python)
from langchain_text_splitters import ExperimentalMarkdownSyntaxTextSplitter
splitter = ExperimentalMarkdownSyntaxTextSplitter()
first = splitter.split_text("first document\n")
first_before = [document.page_content for document in first]
second = splitter.split_text("second document\n")
first_after = [document.page_content for document in first]
print("same list:", first is second)
print("first result before second call:", first_before)
print("first result after second call:", first_after)
Error Message and Stack Trace (if applicable)
No exception is raised. The previously returned list is silently mutated.
Description
ExperimentalMarkdownSyntaxTextSplitter.split_text() returns its internal
self.chunks list directly.
At the beginning of the next split_text() call, the implementation executes
self.chunks.clear(). Because the caller's previously returned value and
self.chunks refer to the same list object, processing a second document clears
and replaces the result returned for the first document.
Actual output:
same list: True
first result before second call: ['first document\n']
first result after second call: ['second document\n']
### System Info
System Information
------------------
> OS: Windows
> OS Version: 10.0.26200
> Python Version: 3.13.3 (main, May 30 2025, 05:37:00) [MSC v.1943 64 bit (AMD64)]
Package Information
-------------------
> langchain_core: 1.6.3
> langsmith: 0.12.5
> langchain_classic: 1.0.8
> langchain_huggingface: 1.2.2
> langchain_protocol: 0.0.19
> langchain_text_splitters: 1.1.2
Optional packages not installed
-------------------------------
> deepagents
> deepagents-cli
Other Dependencies
------------------
> anyio: 4.15.1
> distro: 1.9.0
> httpx: 0.28.1
> httpx2: 2.13.0
> huggingface-hub: 1.31.0
> jsonpatch: 1.33
> orjson: 3.12.0
> packaging: 26.3
> pydantic: 2.13.5
> pyyaml: 6.0.3
> requests: 2.34.2
> requests-toolbelt: 1.0.0
> sniffio: 1.3.1
> sqlalchemy: 2.0.54
> tenacity: 9.1.4
> tokenizers: 0.23.2
> typing-extensions: 4.16.0
> uuid-utils: 0.17.1
> websockets: 17.1
> xxhash: 4.0.1
> zstandard: 0.25.0
### Social handles (optional)
_No response_
Source: langchain-ai/langchain