#20868: fix: resolve {model} responsePrefix vars in non-agent-turn paths
size: S
trusted-contributor
Cluster:
Model Management Enhancements
## Summary
- seed responsePrefix template context with the agent default model/provider at context creation time
- keep runtime onModelSelected override behavior unchanged for agent-turn paths
- add regression tests for both default seeding and runtime override updates
## Problem
messages.responsePrefix templates like [{model}] could remain unresolved in non-agent-turn reply paths that never invoke onModelSelected.
## Fix
Initialize prefixContext with resolveDefaultModelForAgent() so {model}, {provider}, and {modelFull} are available before runtime model selection callbacks fire.
## Validation
- npm test -- src/channels/reply-prefix.test.ts
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes unresolved template variables in responsePrefix for non-agent-turn reply paths by seeding the prefix context with default model info at creation time. Also adds a `delayMs` option to `process send-keys` for paced PTY writes.
**Key changes:**
- `reply-prefix.ts`: Seeds `prefixContext` with default model/provider/thinkingLevel at initialization using `resolveDefaultModelForAgent()`
- `reply-prefix.test.ts`: Adds regression tests for both default seeding and runtime override behavior
- `bash-tools.process.ts`: Adds optional `delayMs` parameter to pace key token writes in PTY sessions (max 5000ms)
- `bash-tools.process.send-keys.e2e.test.ts`: Adds timing validation test for the paced write feature
<h3>Confidence Score: 5/5</h3>
- Safe to merge - well-tested bug fix with comprehensive regression tests
- The PR addresses a clear bug (unresolved template vars in non-agent-turn paths) with a clean solution that seeds default values at initialization. Both changes have good test coverage - regression tests validate the fix works, and E2E tests confirm the paced write feature. The implementation follows existing patterns and doesn't introduce breaking changes.
- No files require special attention
<sub>Last reviewed commit: 655a106</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22072: Fix responsePrefix {model} to use runtime model metadata
by graysurf · 2026-02-20
83.7%
#20712: fix(subagents): prioritize agent runtime default model over global ...
by sourcesavant · 2026-02-19
79.1%
#10608: fix(agents): honor spawn model override in gateway and session spaw...
by 1kuna · 2026-02-06
78.4%
#13376: fix: pass model directly to agent for sub-agent runs
by jrbobbyhansen-pixel · 2026-02-10
76.4%
#16838: fix: include configured fallbacks in model allowlist
by taw0002 · 2026-02-15
76.2%
#14744: fix(context): key MODEL_CACHE by provider/modelId to prevent collis...
by lailoo · 2026-02-12
76.1%
#20185: fix(model): recognize default/reset/clear keywords to clear session...
by yxshee · 2026-02-18
76.1%
#13626: fix(model): propagate provider model properties in fallback resolution
by mcaxtr · 2026-02-10
76.0%
#19328: Fix: preserve modelOverride in agent handler (#5369)
by CodeReclaimers · 2026-02-17
75.6%
#9905: fix: require provider prefix for models set without alias (#5790)
by petter-b · 2026-02-05
75.5%