# Topic summarization sends to LLM with messages with extra spaces inside words or links

**URL:** https://meta.discourse.org/t/topic-summarization-sends-to-llm-with-messages-with-extra-spaces-inside-words-or-links/411136
**Category:** Bug
**Tags:** ai, ai-summarize
**Created:** [August 28, 2026, 12:01pm UTC](https://meta.discourse.org/t/topic-summarization-sends-to-llm-with-messages-with-extra-spaces-inside-words-or-links/411136 "2026-08-28T12:01:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lilydjwg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilydjwg/32/515838_2.png) [@lilydjwg](https://meta.discourse.org/u/lilydjwg)
#### Post date: [August 28, 2026, 12:01pm UTC](https://meta.discourse.org/t/topic-summarization-sends-to-llm-with-messages-with-extra-spaces-inside-words-or-links/411136/1 "2026-08-28T12:01:42Z")

</div>

Recently I’ve enabled AI summarization on my own site and see how it works. I noticed that one summarization contained an invalid link:

```plaintext
[keyd](https://man.arch linux.org/man/extra/keyd/keyd.1.en)

```

It was weird. So I checked the AI logs. It turned out there were quite a few extra spaces in the request, e.g. `e nter`, `Ct rl`, `host s`, etc.

FYI the post is written in Chinese but contains a few English words. The space also may be inserted between Chinese charaters.

---

<div class="post-metadata">

### Author: ![lilydjwg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilydjwg/32/515838_2.png) [@lilydjwg](https://meta.discourse.org/u/lilydjwg)
#### Post date: [August 28, 2026, 12:11pm UTC](https://meta.discourse.org/t/topic-summarization-sends-to-llm-with-messages-with-extra-spaces-inside-words-or-links/411136/2 "2026-08-28T12:11:12Z")

</div>

It seems that it is caused by the `truncate` call in the `FoldContent` class.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [September 23, 2026, 5:10pm UTC](https://meta.discourse.org/t/topic-summarization-sends-to-llm-with-messages-with-extra-spaces-inside-words-or-links/411136/4 "2026-09-23T17:10:00Z")

</div>

thanks for the report @lilydjwg 👍

will be fixed by

> <https://github.com/discourse/discourse/pull/44047>
>
> Previously, \`FoldContent#truncate\` split every post in half and joined the halve…s back with a space, even when nothing needed truncating. Every post sent to the LLM had a stray space in its middle, breaking words and links (e.g. \`man.arch linux.org\`), which then leaked into summaries. For long posts, the second half kept its first 500 tokens instead of its last ones, so their endings were dropped.
> 
> This change sends posts that fit the 1000-token budget untouched and keeps the first and last 500 tokens of longer ones. It also removes the unused \`delete\_cached\_summaries!\` and stale comments.
> 
> https://meta.discourse.org/t/topic-summarization-sends-to-llm-with-messages-with-extra-spaces-inside-words-or-links/411136
