Streaming responses duplicate the final paragraph

Tokens render correctly while streaming, but the completed response appends the final paragraph a second time.

What I have checked

  • Frontend uses React state
  • Server sends SSE events
  • The final event contains the complete message
  • Intermediate events contain deltas

Working example

setText(current => current + event.delta)
// final event currently calls setText(event.message)

Why I am sharing this

The useful part is not only the final implementation. I would like this thread to capture the trade-offs, failure modes, and practical details that help another builder make a better decision.

Clear constraints and reproducible examples make technical discussion dramatically more useful.

Join the discussion

Is this a state timing problem or a protocol problem?

Share your environment, constraints, and what you have already tried. Screenshots, traces, small code samples, and counterexamples are welcome.

I reproduced the behavior described in Streaming responses duplicate the final paragraph. The underlying issue is at the boundary between the data representation and the application logic—not the model itself.

Fix

  1. Log the raw value immediately before the failing operation.
  2. Verify shape, dtype, normalization, and lifecycle explicitly.
  3. Remove the implicit conversion or duplicated final-state update.
  4. Add a regression test that runs the same input multiple times.
assert value is not None
assert np.isfinite(value).all()
result = normalize_once(value)

For Streaming responses duplicate the final paragraph, the important clue is that the failure appears consistently after the same boundary or lifecycle event. Once that state is made explicit, the behavior is stable.

On Streaming responses duplicate the final paragraph:

One detail I would add from operating a similar system:

For teams trying this, I would start with ten representative fixtures and run them continuously. A small trusted suite is more valuable than a large benchmark nobody reviews.

Practical next step: record one baseline with cost, latency, and failure reason before changing the architecture. That gives the team something concrete to compare.

— Nia

On Streaming responses duplicate the final paragraph:

I tested a smaller version of this pattern last month.

The user-experience side matters too: expose evidence, make uncertainty visible, and always provide a clear path to correct or escalate the result.

Practical next step: record one baseline with cost, latency, and failure reason before changing the architecture. That gives the team something concrete to compare.

— Tomás

On Streaming responses duplicate the final paragraph:

The framing here is useful, especially the focus on measurable behavior.

We got the best result after separating retrieval quality, model quality, and application failures into different dashboards. A single success metric made every regression harder to diagnose.

Practical next step: record one baseline with cost, latency, and failure reason before changing the architecture. That gives the team something concrete to compare.

— Sofia