#12634·onyx

Inline citations nest progressively across turns in multi-turn chat ([[n]](url) → [ [[n]](url) ](url))

Author: pineywoodsCreated Jul 1, 2026Updated Sep 15, 2026
LabelsStale

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

  1. Start a chat with an assistant that has Search/citations enabled.
  2. Ask a question that returns a cited answer → first turn cites cleanly: ... humid [[1]](https://example.com).
  3. Ask a follow-up in the same session → ... showers [ [[1]](https://example.com)](https://example.com).
  4. 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).