Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sebslight
Copy link
Member

Summary

Adds support for dynamic template variables in messages.responsePrefix that resolve at runtime with the actual model used (including after fallback).

Supported Template Variables

All variables are case-insensitive:

Variable Description Example
{model} Short model name claude-opus-4-5, gpt-4o
{modelFull} Full model identifier anthropic/claude-opus-4-5
{provider} Provider name anthropic, openai
{thinkingLevel} / {think} Thinking level high, low, off
{identity.name} / {identityName} Agent identity name (from config)

Example

{
  messages: {
    responsePrefix: "[{model} | think:{thinkingLevel}]"
  }
}

Output: [claude-opus-4-5 | think:high] Here's my response...

Key Features

  • Variables show the actual model used after fallback, not the intended model
  • Unresolved variables remain as literal text (safe degradation)
  • Case-insensitive variable matching

Test Plan

  • All 27 new unit tests pass
  • All responsePrefix integration tests pass (25 tests)
  • Build passes
  • Lint passes

Fixes #923

…claw#923)

Adds support for template variables in `messages.responsePrefix` that
resolve dynamically at runtime with the actual model used (including
after fallback).

Supported variables (case-insensitive):
- {model} - short model name (e.g., "claude-opus-4-5", "gpt-4o")
- {modelFull} - full model identifier (e.g., "anthropic/claude-opus-4-5")
- {provider} - provider name (e.g., "anthropic", "openai")
- {thinkingLevel} or {think} - thinking level ("high", "low", "off")
- {identity.name} or {identityName} - agent identity name

Example: "[{model} | think:{thinkingLevel}]" → "[claude-opus-4-5 | think:high]"

Variables show the actual model used after fallback, not the intended
model. Unresolved variables remain as literal text.

Implementation:
- New module: src/auto-reply/reply/response-prefix-template.ts
- Template interpolation in normalize-reply.ts via context provider
- onModelSelected callback in agent-runner-execution.ts
- Updated all 6 provider message handlers (web, signal, discord,
  telegram, slack, imessage)
- 27 unit tests covering all variables and edge cases
- Documentation in docs/gateway/configuration.md and JSDoc

Fixes openclaw#923
@sebslight sebslight marked this pull request as draft January 15, 2026 04:06
@sebslight sebslight marked this pull request as ready for review January 15, 2026 04:37
@steipete steipete assigned steipete and unassigned steipete Jan 15, 2026
@steipete
Copy link
Contributor

Thanks Seb, this looks useful!

@steipete steipete merged commit 7d4f2d9 into openclaw:main Jan 15, 2026
10 of 22 checks passed
@steipete
Copy link
Contributor

Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test\n- Land commit: 3f0603d\n- Merge commit: 7d4f2d9\n\nThanks @sebslight!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Dynamic variables in responsePrefix (model, thinking level)

2 participants