Inline citations nest progressively across turns in multi-turn chat ([[n]](url) → [ [[n]](url) ](url))
Describe the bug
In a multi-turn chat, inline citations render correctly on the first assistant turn ([[1]](url)) but become progressively nested on each follow-up turn, with the nesting deepening every turn.
To reproduce
- Start a chat with an assistant that has Search/citations enabled.
- Ask a question that returns a cited answer → first turn cites cleanly:
... humid [[1]](https://example.com). - Ask a follow-up in the same session →
... showers [ [[1]](https://example.com)](https://example.com). - Ask another follow-up →
... sunny [ [ [[5]](url)](url) ].
Expected behavior
Citations stay in the flat [[n]](url) rendered form on every turn.
Actual behavior
Each additional turn wraps the prior citation in another [ ... ](url) layer.
Root cause
The system prompt (onyx/prompts/chat_prompts.py) tells the model to cite with bare markers ([1]) and to not add links. But history assembly (_build_structured_assistant_message in onyx/chat/llm_step.py) replays prior assistant turns from msg.message, which is the persisted, already-rendered [[n]](url) form. The model is shown link-form citations in its own history, contradicting the prompt, imitates that form, and DynamicCitationProcessor then re-expands the bare marker inside — yielding [ [[1]](url) ](url). First turns are clean because there's no prior citation to imitate.
Fix
Proposed in #11933 — normalize replayed assistant history back to bare [n] markers before sending to the LLM.
Version
Self-hosted, main (reproduces on multi-turn cited chats).
Source: onyx-dot-app/onyx