# Text-splitters: add\_start\_index returns wrong position for duplicate chunks (#41190), happy to work on a fix

**URL:** <https://forum.langchain.com/t/text-splitters-add-start-index-returns-wrong-position-for-duplicate-chunks-41190-happy-to-work-on-a-fix/5140>\
**Category:** LangChain\
**Tags:** python-help\
**Created:** [November 9, 2026, 4:21pm UTC](https://forum.langchain.com/t/text-splitters-add-start-index-returns-wrong-position-for-duplicate-chunks-41190-happy-to-work-on-a-fix/5140 "2026-11-09T16:21:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SANJANAKUMARI83](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/sanjanakumari83/32/3819_2.png) [@SANJANAKUMARI83](https://forum.langchain.com/u/SANJANAKUMARI83)\
**Post date:** [November 9, 2026, 4:21pm UTC](https://forum.langchain.com/t/text-splitters-add-start-index-returns-wrong-position-for-duplicate-chunks-41190-happy-to-work-on-a-fix/5140/1 "2026-11-09T16:21:13Z")

</div>

Hi everyone! I’m Sanjana, an IIT Graduate , AI/ML engineer from India working on LLM systems and RAG pipelines, and I’m starting to contribute to LangChain.

I recently reported a bug in text-splitters: [text-splitters: add\_start\_index returns an earlier duplicate's position when a chunk is shorter than chunk\_overlap · Issue #41190 · langchain-ai/langchain · GitHub](https://github.com/langchain-ai/langchain/issues/41190)

When `add_start_index=True`, a chunk that is shorter than `chunk_overlap` and also appears earlier in the document gets the start index of that earlier occurrence instead of its own position. This matters for RAG setups that rely on `start_index` to map chunks back to the source text.

I’d be happy to open a PR for this. Before I do, I’d love feedback from the maintainers on whether the fix should go in how the search offset is advanced, or whether there’s a preferred approach.

I’d also appreciate pointers to other areas in text-splitters or the core library where help would be useful. Thanks!

---

<div class="post-metadata">

**Author:** ![virse\_ai](https://avatars.discourse-cdn.com/v4/letter/v/85f322/32.png) [@virse\_ai](https://forum.langchain.com/u/virse_ai)\
**Post date:** [November 9, 2026, 5:20pm UTC](https://forum.langchain.com/t/text-splitters-add-start-index-returns-wrong-position-for-duplicate-chunks-41190-happy-to-work-on-a-fix/5140/2 "2026-11-09T17:20:27Z")

</div>

If the current implementation searches from the beginning for each chunk, I’d try a forward search cursor anchored at the previous match, advancing by at least one character rather than by the full chunk length so overlapping chunks remain possible. A regression case with identical text at multiple offsets and a chunk shorter than the overlap should show whether the right occurrence is selected. It may also be worth checking offsets around Unicode characters and newlines, since Python indices count code points rather than bytes.
