Summary
When a user sets a per-session model override (e.g. via /model opus), then later runs /new or /reset, the model override persists in the session state. This causes the new session to start on the overridden model instead of the configured default, and the runtime metadata injected into the system prompt reflects the stale override.
Steps to reproduce
- Configure a default model (e.g. anthropic/claude-sonnet-4-6) in openclaw.json → agents.defaults.model.primary
- Override the session model via /model to something else (e.g. anthropic/claude-opus-4.6)
- Run /new to start a fresh session
- Observe the runtime line in the system prompt — model= still shows the override, not the default
Expected behavior
/new and /reset should start a clean session with the configured default model. Per-session model overrides should not carry over.
Actual behavior
The model key in ~/.openclaw/agents/main/sessions/sessions.json retains the override value across /new. The system prompt's runtime metadata is generated from this persisted value, so the agent sees model= and default_model=, leading to incorrect behavior.
OpenClaw version
OpenClaw 2026.2.19-2
Operating system
Linux 6.8.0-100-generic (x64)
Install method
Node: v22.22.0
Logs, screenshots, and evidence
### Evidence: Log excerpts and session state
**1. Config default model (`openclaw.json`)**
"agents": {
"defaults": {
"model": {
"primary": "anthropic/claude-sonnet-4-6"
}
}
}
**2. Session state after `/new` (`sessions.json`)**
Despite `/new` creating a fresh session (`e2a4cf37-...`), the model override persisted:
"agent:main:main": {
"sessionId": "e2a4cf37-339b-4264-a944-e6f078463f35",
"model": "anthropic/claude-opus-4.6",
...
}
**3. Gateway logs showing stale model on every run after `/new`**
Previous session (before `/new`) — runs on Opus as expected since override was set:
08:32:52.153 embedded run start: runId=105e5c3a provider=openrouter model=anthropic/claude-opus-4.6
08:32:59.863 embedded run start: runId=6c19c234 provider=openrouter model=anthropic/claude-opus-4.6
08:35:05.813 embedded run start: runId=c056cd49 provider=openrouter model=anthropic/claude-opus-4.6
08:37:01.117 embedded run start: runId=78e0f784 provider=openrouter model=anthropic/claude-opus-4.6
After `/new` — new sessionId (`e2a4cf37`), **still Opus**:
08:44:03.694 embedded run start: runId=c8d35c73 sessionId=e2a4cf37 provider=openrouter model=anthropic/claude-opus-4.6
08:44:55.291 embedded run start: runId=352f6c45 sessionId=e2a4cf37 provider=openrouter model=anthropic/claude-opus-4.6
08:45:30.886 embedded run start: runId=edd89d96 sessionId=e2a4cf37 provider=openrouter model=anthropic/claude-opus-4.6
08:47:45.078 embedded run start: runId=9d5be406 sessionId=e2a4cf37 provider=openrouter model=anthropic/claude-opus-4.6
08:52:40.782 embedded run start: runId=ab0871f6 sessionId=e2a4cf37 provider=openrouter model=anthropic/claude-opus-4.6
**4. `openclaw status` confirming the override (after `/new`)**
Sessions
┌────────────────────┬────────┬──────────┬─────────────────┬────────────────┐
│ Key │ Kind │ Age │ Model │ Tokens │
├────────────────────┼────────┼──────────┼─────────────────┼────────────────┤
│ agent:main:main │ direct │ just now │ claude-opus-4.6 │ 17k/1000k (2%) │
└────────────────────┴────────┴──────────┴─────────────────┴────────────────┘
**5. `session_status(model=default)` — resets live model but doesn't persist**
After calling `session_status(model=default)`, the in-flight model changed to Sonnet but `sessions.json` still contained:
"model": "anthropic/claude-opus-4.6"
**6. Runtime metadata injected into system prompt (stale)**
model=openrouter/anthropic/claude-opus-4.6 | default_model=anthropic/claude-sonnet-4-6
Impact and severity
No response
Additional information
Secondary issue — session_status(model=default) doesn't persist:
When the agent calls session_status with model=default to reset the override, it changes the live in-flight model but does not update the model field in sessions.json. This means:
• The current session runs on the correct model after the reset
• But openclaw status still shows the old override in the Sessions table
• A subsequent /new would again start with the stale override
Workaround:
Manually delete the "model" key from the session entry in sessions.json:
// Before (broken)
"agent:main:main": {
"model": "anthropic/claude-opus-4.6",
...
}
// After (fixed — falls back to config default)
"agent:main:main": {
...
}
Suggested fix:
• /new and /reset should delete the model key from the session state (or explicitly reset it to null/default)
• session_status(model=default) should also persist the removal of the model key to sessions.json, not just change it in memory
Summary
When a user sets a per-session model override (e.g. via /model opus), then later runs /new or /reset, the model override persists in the session state. This causes the new session to start on the overridden model instead of the configured default, and the runtime metadata injected into the system prompt reflects the stale override.
Steps to reproduce
Expected behavior
/new and /reset should start a clean session with the configured default model. Per-session model overrides should not carry over.
Actual behavior
The model key in ~/.openclaw/agents/main/sessions/sessions.json retains the override value across /new. The system prompt's runtime metadata is generated from this persisted value, so the agent sees model= and default_model=, leading to incorrect behavior.
OpenClaw version
OpenClaw 2026.2.19-2
Operating system
Linux 6.8.0-100-generic (x64)
Install method
Node: v22.22.0
Logs, screenshots, and evidence
Impact and severity
No response
Additional information
Secondary issue — session_status(model=default) doesn't persist:
When the agent calls session_status with model=default to reset the override, it changes the live in-flight model but does not update the model field in sessions.json. This means:
• The current session runs on the correct model after the reset
• But openclaw status still shows the old override in the Sessions table
• A subsequent /new would again start with the stale override
Workaround:
Manually delete the "model" key from the session entry in sessions.json:
// Before (broken)
"agent:main:main": {
"model": "anthropic/claude-opus-4.6",
...
}
// After (fixed — falls back to config default)
"agent:main:main": {
...
}
Suggested fix:
• /new and /reset should delete the model key from the session state (or explicitly reset it to null/default)
• session_status(model=default) should also persist the removal of the model key to sessions.json, not just change it in memory