#10717: fix: skip response prefix with unresolved template variables in routeReply
stale
Cluster:
TUI and Tool Execution Fixes
## Summary
- When `routeReply` applies a `responsePrefix` containing template variables like `{model}`, it has no `ResponsePrefixContext` available to resolve them
- This causes raw template text (e.g. `[{model}]`) to appear in routed messages instead of being omitted
- Fix: use `hasTemplateVariables()` to detect unresolvable templates and skip the prefix entirely in that case
## Test plan
- [x] Added test: `skips responsePrefix containing unresolved template variables`
- [x] All 17 route-reply tests pass
- [x] Static prefix like `[openclaw]` continues to work as before
Closes #10672
Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Updates `routeReply()` to avoid applying `messages.responsePrefix` when it contains template variables (e.g. `{model}`), since route routing doesn’t have a `ResponsePrefixContext` to resolve them.
- Adds a regression test ensuring a templated prefix like `[{model}]` is omitted (message text remains unchanged) while static prefixes still apply.
- Implements the behavior by calling `hasTemplateVariables()` from the existing response prefix templating utility and passing `undefined` to `normalizeReplyPayload` when templates are detected.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Change is small, localized to `routeReply`, relies on an existing well-tested utility (`hasTemplateVariables`), and includes a regression test that captures the reported failure mode (templated prefixes leaking raw `{model}` text). No behavior changes for static prefixes, and the skip only triggers when template braces are present.
- No files require special attention
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#20868: fix: resolve {model} responsePrefix vars in non-agent-turn paths
by Operative-001 · 2026-02-19
74.3%
#22072: Fix responsePrefix {model} to use runtime model metadata
by graysurf · 2026-02-20
71.8%
#17647: fix: Display error messages instead of (no output) for non-Claude m...
by MisterGuy420 · 2026-02-16
70.6%
#17244: fix: strip TTS tags from agent replies before delivery (#14652)
by robbyczgw-cla · 2026-02-15
70.4%
#19576: fix: tighten isSilentReplyText to match whole-text only
by aldoeliacim · 2026-02-18
70.4%
#6059: fix #6044
by vivganes · 2026-02-01
70.3%
#15575: fix(heartbeat): suppress prefixed HEARTBEAT_OK ack replies (#15505)
by TsekaLuk · 2026-02-13
69.6%
#9905: fix: require provider prefix for models set without alias (#5790)
by petter-b · 2026-02-05
69.3%
#20185: fix(model): recognize default/reset/clear keywords to clear session...
by yxshee · 2026-02-18
69.1%
#23761: fix: suppress partial NO_REPLY tokens at lifecycle boundary
by kami-saia · 2026-02-22
69.0%