openclaw - 💡(How to fix) Fix Bug: Session falls to agents.defaults.model.primary after context compaction instead of using agentId's configured model [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#72275Fetched 2026-04-27 05:32:11
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Timeline (top)
closed ×1commented ×1

When context compaction fires in a long-running session bound to a specific agentId (e.g. agentId: main), the session silently downgrades to agents.defaults.model.primary instead of continuing on the agent's configured model. The downgrade is not surfaced to the user and persists for the remainder of the session.

Root Cause

When context compaction fires in a long-running session bound to a specific agentId (e.g. agentId: main), the session silently downgrades to agents.defaults.model.primary instead of continuing on the agent's configured model. The downgrade is not surfaced to the user and persists for the remainder of the session.

Fix Action

Workaround

Manually monitor active sessions for unexpected model changes (we added a heartbeat check as a mitigation). Send a STOP message to the session and restart it when downgrade is detected.

RAW_BUFFERClick to expand / collapse

Summary

When context compaction fires in a long-running session bound to a specific agentId (e.g. agentId: main), the session silently downgrades to agents.defaults.model.primary instead of continuing on the agent's configured model. The downgrade is not surfaced to the user and persists for the remainder of the session.

OpenClaw Version

2026.4.23 (confirmed); likely present in earlier versions

Steps to Reproduce

  1. Configure an agent in agents.list with a specific model (e.g. agentId: main, model.primary: claude-cli/claude-sonnet-4-6)
  2. Start a long-running session via a Telegram topic thread bound to that agent
  3. Allow the session to reach the compaction threshold — compaction fires automatically
  4. After compaction completes, observe the model the session is now using

Expected Behaviour

After compaction, the session should continue using the model configured for the bound agentId (claude-cli/claude-sonnet-4-6 in this case).

Actual Behaviour

After compaction, the session is running on agents.defaults.model.primary (ollama/gpt-oss:20b in this setup). The downgrade is silent — no notification, no log entry surfaced to the user.

Environment

  • Gateway mode: local
  • Session type: Telegram group topic thread (long-lived, bound to agentId: main)
  • Compaction mode: safeguard (compaction.mode: safeguard in agents.defaults)
  • agents.defaults.model.primary: ollama/gpt-oss:20b
  • agents.list.main.model.primary: claude-cli/claude-sonnet-4-6

Impact

  • Session silently degrades to a local model mid-conversation, with no indication to the user
  • Work product quality drops without warning (local model significantly less capable than configured model)
  • Requires manual intervention to restore the correct model (send STOP, restart session)
  • Post-compaction sessions bound to agentId: main are indistinguishable from agents.defaults sessions until quality degrades noticeably

Workaround

Manually monitor active sessions for unexpected model changes (we added a heartbeat check as a mitigation). Send a STOP message to the session and restart it when downgrade is detected.

Notes

This appears to be a model-resolution ordering issue: after compaction creates a new context, the session may be re-initialised using agents.defaults rather than re-resolving the agentId-specific config. The agentId binding is lost or not re-applied post-compaction.

extent analysis

TL;DR

The session silently downgrades to the default model after context compaction, likely due to a model-resolution ordering issue, and can be temporarily mitigated by manually monitoring and restarting affected sessions.

Guidance

  • Verify the agentId binding is correctly applied before and after compaction by checking the session configuration and model in use.
  • Investigate the model resolution logic to ensure it correctly re-applies the agentId-specific config after compaction.
  • Consider adding logging or notification mechanisms to surface model changes to the user, allowing for earlier detection and intervention.
  • Review the compaction.mode: safeguard configuration to determine if it contributes to the issue.

Example

No code snippet is provided as the issue does not include specific code references.

Notes

The provided workaround of manually monitoring sessions and sending a STOP message to restart them is a temporary mitigation. A more permanent solution would require addressing the underlying model-resolution ordering issue.

Recommendation

Apply the workaround of manually monitoring and restarting affected sessions until a more permanent fix can be implemented, as it allows for some mitigation of the issue while a full solution is developed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Bug: Session falls to agents.defaults.model.primary after context compaction instead of using agentId's configured model [1 comments, 2 participants]