openclaw - 💡(How to fix) Fix Plugin SDK: expose sessionModelOverride in PluginHookAgentContext (before_model_resolve) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

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#57313Fetched 2026-04-08 01:51:08
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

When a user manually sets a model override via /model, the before_model_resolve hook has no way to detect this and correctly yields. The hook currently fires on every message and may overwrite the user-intended model with its own routing decision.

Root Cause

When a user manually sets a model override via /model, the before_model_resolve hook has no way to detect this and correctly yields. The hook currently fires on every message and may overwrite the user-intended model with its own routing decision.

Fix Action

Fix / Workaround

Workaround in use

RAW_BUFFERClick to expand / collapse

Summary

When a user manually sets a model override via /model, the before_model_resolve hook has no way to detect this and correctly yields. The hook currently fires on every message and may overwrite the user-intended model with its own routing decision.

Current state

  • PluginHookBeforeModelResolveEvent only exposes: { prompt: string }
  • PluginHookAgentContext only exposes: { agentId, sessionKey, sessionId, workspaceDir, trigger, channelId }
  • No field indicates whether a user-pinned model override is currently active for the session.

Workaround in use

We currently read agents/<agentId>/sessions/sessions.json directly to check for modelOverride / providerOverride per session key. This is fragile (depends on internal file format stability) and may break between releases.

Requested change

Add sessionModelOverride?: string and sessionProviderOverride?: string to PluginHookAgentContext so that before_model_resolve hooks can:

  1. detect when a user has pinned a model for the current session
  2. yield cleanly without fighting the user's explicit choice

Use case

A custom routing plugin (task-router) selects provider/model based on message intent. When the user explicitly pins a different model (e.g. for outage recovery), the plugin should detect the pin and skip its override. Without this field, plugins must work around the API using fragile internal state reads.

Impact

  • Affects all plugin authors implementing before_model_resolve
  • Mitigates model override conflicts in multi-provider failover setups
  • Related: per-session model resolution precedence contract

extent analysis

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Fix Plan

To address the issue, we need to add two!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! new fields!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! to the PluginHookAgentContext interface:

  • sessionModelOverride?: string
  • sessionProviderOverride?: string

Here's an example of how the updated interface could look:

interface PluginHookAgentContext {
  agentId: string;
  sessionKey: string;
  sessionId: string;
  workspaceDir: string;
  trigger: string;
  channelId: string;
  sessionModelOverride?: string;
  sessionProviderOverride?: string;
}

With these new fields, plugins can detect when a user has pinned a model for the current session and yield cleanly without overwriting the user's explicit choice.

Verification

To verify that the fix worked, you can:

  • Implement a before_model_resolve hook that checks for the presence of sessionModelOverride and sessionProviderOverride in the PluginHookAgentContext.
  • Test the hook with a user-pinned model override and verify that it yields correctly.
  • Test the hook without a user-p

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 Plugin SDK: expose sessionModelOverride in PluginHookAgentContext (before_model_resolve) [1 participants]