SIGN IN SIGN UP

fix(core): apply transformed model-call text deltas (#2469)

## Description

Fixes #2385.

`MiddlewareBase.onModelCall` can transform emitted
`TextBlockDeltaEvent`s, but those changes previously affected only the
external event stream. The final `Msg` was still built from unmodified
model chunks, causing native structured-output parsing to consume stale
text.

This change rebuilds accumulated response text from the transformed
model-call event stream before producing the final message. As a result,
middleware can normalize text—such as removing Markdown JSON
fences—before native structured-output parsing.

Added regression coverage for a model that streams fenced JSON across
multiple chunks. The middleware removes the fence deltas, and the test
verifies the final response contains valid JSON and deserializes into
structured data.
J
Joe Zou committed
702461070ddcab29dae7c7a2b130e323a106d020
Parent: 5700e5f
Committed by GitHub <noreply@github.com> on 7/31/2026, 12:53:31 PM