#22245: Fix responsePrefix correctness on failover + prevent duplicate prefixes
app: web-ui
gateway
size: S
Cluster:
Telegram Message Handling Fixes
## Summary
- **Duplicate prefix after failover (all dispatcher channels)**: `normalizeReplyPayload` prepend-only guard (`!text.startsWith(effectivePrefix)`) failed when the model changed between block and final replies, causing `[old] [new] msg`. Fixed by tracking `lastAppliedPrefix` in the dispatcher and stripping the old prefix before applying the new one, with whitespace boundary check to prevent false substring matches.
- **Webchat streaming deltas missing prefix**: `emitChatDelta` broadcast raw buffer text without prefix; only `emitChatFinal` applied it. Fixed by prepending the resolved prefix in delta broadcasts (buffer stays raw for the definitive final).
## Test plan
- [x] 5 unit tests in `reply-utils.test.ts` (strip-then-replace, no-strip-when-undefined, idempotency, whitespace-terminated prefix, substring edge case)
- [ ] Telegram `streamMode: "partial"` with forced failover: verify single prefix `[fallback]` instead of `[primary] [fallback]`
- [ ] Webchat with forced failover: verify streaming deltas and final both show fallback model prefix
- [ ] No-failover regression: verify prefix behavior unchanged when primary model succeeds
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Most Similar PRs
#20868: fix: resolve {model} responsePrefix vars in non-agent-turn paths
by Operative-001 · 2026-02-19
63.5%
#22072: Fix responsePrefix {model} to use runtime model metadata
by graysurf · 2026-02-20
63.1%
#17953: fix(telegram): prevent silent message loss and duplicate messages i...
by zuyan9 · 2026-02-16
62.8%
#20274: fix: add fallback delivery when stopSlackStream fails
by nova-openclaw-cgk · 2026-02-18
62.8%
#23761: fix: suppress partial NO_REPLY tokens at lifecycle boundary
by kami-saia · 2026-02-22
62.8%
#23800: fix: map HTTP 404 to model_not_found failover reason
by builtbyrobben · 2026-02-22
62.6%
#19648: fix: suppress silent-reply partial tokens during streaming
by bradleypriest · 2026-02-18
62.2%
#12211: fix(slack): prevent duplicate message delivery via block streaming ...
by junhoyeo · 2026-02-09
62.1%
#23144: fix(ui): strip reply directive tags from assistant messages in WebC...
by echoVic · 2026-02-22
62.0%
#18460: fix(telegram): send fallback when streamMode partial drops all mess...
by BinHPdev · 2026-02-16
61.8%