openclaw - ✅(Solved) Fix [Bug]: Gateway continues selecting openrouter/... models after complete provider removal [3 pull requests, 1 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#56206Fetched 2026-04-08 01:43:36
View on GitHub
Comments
0
Participants
1
Timeline
10
Reactions
0
Participants
Timeline (top)
referenced ×5cross-referenced ×3labeled ×2

After migrating from OpenRouter to direct Anthropic API on OpenClaw v2026.3.24, the gateway still intermittently attempts openrouter/... models even though all OpenRouter configuration, environment variables, auth references, cache, and visible session artifacts have been removed. This appears to be a stale runtime/session/model-selection issue rather than current config drift.

Root Cause

I do not know whether that is relevant, but I am including it because the regenerated state may be influenced by built-in provider catalogs/defaults.

Fix Action

Fix / Workaround

Workarounds attempted • removed all visible OpenRouter references from config and environment • removed fallback chains • deleted cache • deleted sessions • deleted regenerated models.json • set Anthropic as default provider/model • started gateway in clean shell without OpenRouter env vars • avoided LaunchAgent and reproduced manually in foreground

PR fix notes

PR #56264: delete

Description (problem / solution / changelog)

delete

Changed files

  • 2026-03-28.md (added, +384/-0)
  • AGENTS.md (modified, +21/-0)
  • src/agents/command/session.ts (modified, +11/-0)
  • src/config/sessions/store-validation.test.ts (added, +151/-0)
  • src/config/sessions/store-validation.ts (added, +81/-0)
  • src/config/sessions/store.ts (modified, +15/-1)

PR #56269: delete

Description (problem / solution / changelog)

delete

Changed files

  • 2026-03-28.md (added, +384/-0)
  • AGENTS.md (modified, +21/-0)
  • src/agents/command/session.ts (modified, +11/-0)
  • src/config/sessions/store-validation.test.ts (added, +151/-0)
  • src/config/sessions/store-validation.ts (added, +81/-0)
  • src/config/sessions/store.ts (modified, +15/-1)

PR #56272: fix(sessions): sanitize stale provider/model references (#56206)

Description (problem / solution / changelog)

Fixes #56206

Problem

After removing a provider from configuration, the gateway continues to attempt using models from that provider because session entries retain stale provider/model references.

Solution

Add validation layer that sanitizes session entries when loaded.

Testing

8 unit tests, all passing.

Files Changed

  • src/config/sessions/store-validation.ts (new)
  • src/config/sessions/store-validation.test.ts (new)
  • src/config/sessions/store.ts (modified)
  • src/agents/command/session.ts (modified)

Changed files

  • extensions/telegram/package.json (modified, +11/-0)
  • src/agents/command/session.ts (modified, +12/-0)
  • src/config/sessions/store-validation.test.ts (added, +151/-0)
  • src/config/sessions/store-validation.ts (added, +81/-0)
  • src/config/sessions/store.ts (modified, +20/-1)

Code Example

Current default config block
From ~/.openclaw/openclaw.json:

{
  "model": {
    "primary": "anthropic/claude-sonnet-4-6",
    "fallbacks": []
  },
  "models": {
    "anthropic/claude-sonnet-4-6": {
      "alias": "sonnet"
    },
    "vllm/mlx-community/Qwen3-14B-4bit": {
      "alias": "qwen-mlx"
    },
    "vllm/mlx-community/Qwen3-Coder-30B-A3B-Instruct-4bit": {
      "alias": "qwen-coder"
    }
  }
}
This appears clean and does not include any openrouter/... entries.

Critical reproduction test
We opened a brand new terminal tab and verified:
env | grep OPENROUTER
returned nothing.

Then we killed all gateway processes and started the gateway manually in the foreground with:
node entry.js gateway --port 18889

Even in that clean-shell foreground run, Jack still returned:
All models failed (4): openrouter/google/gemini-2.5-flash: HTTP 401 | openrouter/deepseek/deepseek-v3.2: HTTP 401 | openrouter/anthropic/claude-sonnet-4-6: HTTP 401 | openrouter/anthropic/claude-opus-4-6: HTTP 401

Why this seems unexpected
At this point, the OpenRouter model attempts do not appear to be coming from:
	•	current environment variables
	•	visible config files
	•	auth profiles
	•	cache
	•	known fallback chains

That suggests stale runtime/session state, model-selection persistence, or bundled provider catalog behavior that is still surfacing openrouter/... model refs after provider removal.

Additional observation
The installed binary contains hardcoded default model constants such as:
const DEFAULT_GEMINI_MODEL = "gemini-2.5-flash";

I do not know whether that is relevant, but I am including it because the regenerated state may be influenced by built-in provider catalogs/defaults.

Questions for maintainers
	1.	Is there a known bug where stale model/provider state survives complete provider removal?
	2.	Can bundled provider catalogs surface openrouter/... model refs even when the provider is no longer configured?
	3.	Is there a hidden session or runtime state location that should also be cleared?
	4.	Is there a supported way to fully disable or deregister a bundled provider plugin?
	5.	Should deleting per-agent models.json be avoided in this situation?

Reproduction steps
	1.	Start with OpenClaw using OpenRouter
	2.	Migrate to direct Anthropic API
	3.	Remove all visible OpenRouter config/env/auth references
	4.	Confirm defaults only allow Anthropic + local vLLM models
	5.	Start gateway from a clean shell
	6.	Message an affected agent/channel
	7.	Observe attempts to use openrouter/... models anyway
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

After migrating from OpenRouter to direct Anthropic API on OpenClaw v2026.3.24, the gateway still intermittently attempts openrouter/... models even though all OpenRouter configuration, environment variables, auth references, cache, and visible session artifacts have been removed. This appears to be a stale runtime/session/model-selection issue rather than current config drift.

Steps to reproduce

•	OpenClaw version: 2026.3.24
•	OS: macOS
•	Hardware: Apple Silicon Mac Mini M4 Pro
•	Deployment mode: LaunchAgent-managed gateway, also reproduced by starting gateway manually in foreground
•	Slack used as primary communication channel
•	Multi-agent system with 37 agents

Expected behavior

The gateway should only select models allowed by current config. In this installation, that means: • anthropic/claude-sonnet-4-6 • local vllm/... models in the configured allowlist

It should not attempt any openrouter/... models once OpenRouter has been completely removed.

Actual behavior

Affected agents intermittently fail with errors like: All models failed (4): openrouter/google/gemini-2.5-flash: HTTP 401 | openrouter/deepseek/deepseek-v3.2: HTTP 401 | openrouter/anthropic/claude-sonnet-4-6: HTTP 401 | openrouter/anthropic/claude-opus-4-6: HTTP 401

We verified all of the following: • ~/.openclaw/openclaw.json contains zero openrouter strings • ~/.openclaw/.env contains no OPENROUTER_API_KEY • LaunchAgent plist contains no OPENROUTER_API_KEY • launchctl getenv OPENROUTER_API_KEY returns unset • shell startup files contain no OpenRouter references • cron environment contains no OpenRouter references • all auth-profiles.json files contain zero OpenRouter provider entries • openclaw secrets audit --json returns no OpenRouter findings • openclaw models fallbacks list shows zero fallbacks • cache directory was emptied • old backup configs were deleted • agent sessions were deleted • per-agent models.json files were deleted and allowed to regenerate

OpenClaw version

OpenClaw version: 2026.3.24

Operating system

macOS Tahoe 26.3.1

Install method

mac app

Model

anthropic/claude sonnet

Provider / routing chain

LaunchAgent-managed gateway, also reproduced by starting gateway manually in foreground

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Current default config block
From ~/.openclaw/openclaw.json:

{
  "model": {
    "primary": "anthropic/claude-sonnet-4-6",
    "fallbacks": []
  },
  "models": {
    "anthropic/claude-sonnet-4-6": {
      "alias": "sonnet"
    },
    "vllm/mlx-community/Qwen3-14B-4bit": {
      "alias": "qwen-mlx"
    },
    "vllm/mlx-community/Qwen3-Coder-30B-A3B-Instruct-4bit": {
      "alias": "qwen-coder"
    }
  }
}
This appears clean and does not include any openrouter/... entries.

Critical reproduction test
We opened a brand new terminal tab and verified:
env | grep OPENROUTER
returned nothing.

Then we killed all gateway processes and started the gateway manually in the foreground with:
node entry.js gateway --port 18889

Even in that clean-shell foreground run, Jack still returned:
All models failed (4): openrouter/google/gemini-2.5-flash: HTTP 401 | openrouter/deepseek/deepseek-v3.2: HTTP 401 | openrouter/anthropic/claude-sonnet-4-6: HTTP 401 | openrouter/anthropic/claude-opus-4-6: HTTP 401

Why this seems unexpected
At this point, the OpenRouter model attempts do not appear to be coming from:
	•	current environment variables
	•	visible config files
	•	auth profiles
	•	cache
	•	known fallback chains

That suggests stale runtime/session state, model-selection persistence, or bundled provider catalog behavior that is still surfacing openrouter/... model refs after provider removal.

Additional observation
The installed binary contains hardcoded default model constants such as:
const DEFAULT_GEMINI_MODEL = "gemini-2.5-flash";

I do not know whether that is relevant, but I am including it because the regenerated state may be influenced by built-in provider catalogs/defaults.

Questions for maintainers
	1.	Is there a known bug where stale model/provider state survives complete provider removal?
	2.	Can bundled provider catalogs surface openrouter/... model refs even when the provider is no longer configured?
	3.	Is there a hidden session or runtime state location that should also be cleared?
	4.	Is there a supported way to fully disable or deregister a bundled provider plugin?
	5.	Should deleting per-agent models.json be avoided in this situation?

Reproduction steps
	1.	Start with OpenClaw using OpenRouter
	2.	Migrate to direct Anthropic API
	3.	Remove all visible OpenRouter config/env/auth references
	4.	Confirm defaults only allow Anthropic + local vLLM models
	5.	Start gateway from a clean shell
	6.	Message an affected agent/channel
	7.	Observe attempts to use openrouter/... models anyway

Impact and severity

This causes fatal agent failures and makes provider migration unreliable, especially in multi-agent production setups.

Additional information

Workarounds attempted • removed all visible OpenRouter references from config and environment • removed fallback chains • deleted cache • deleted sessions • deleted regenerated models.json • set Anthropic as default provider/model • started gateway in clean shell without OpenRouter env vars • avoided LaunchAgent and reproduced manually in foreground

Request Please advise whether this is a known state-persistence bug and what exact file, command, or runtime state must be cleared to prevent openrouter/... models from being selected after full provider removal.

extent analysis

Fix Plan

To resolve the issue of stale runtime/session state or model-selection persistence, follow these steps:

  • Clear bundled provider catalogs: Check the OpenClaw codebase for any hardcoded default model constants or provider catalogs that may be surfacing openrouter/... model references. Update or remove these constants to prevent them from influencing the regenerated state.
  • Disable or deregister bundled provider plugins: Investigate if there's a supported way to fully disable or deregister the bundled OpenRouter provider plugin. This may involve updating the openclaw.json configuration file or using a command-line option.
  • Clear hidden session or runtime state locations: Identify and clear any hidden session or runtime state locations that may be storing stale OpenRouter provider references. This could include checking for temporary files, database entries, or other storage mechanisms used by OpenClaw.
  • Update the openclaw.json configuration file: Verify that the openclaw.json file only contains references to the desired providers (e.g., Anthropic and local vLLM models). Remove any unnecessary or stale entries.

Example code snippet to update the openclaw.json file:

{
  "model": {
    "primary": "anthropic/claude-sonnet-4-6",
    "fallbacks": []
  },
  "models": {
    "anthropic/claude-sonnet-4-6": {
      "alias": "sonnet"
    },
    "vllm/mlx-community/Qwen3-14B-4bit": {
      "alias": "qwen-mlx"
    },
    "vllm/mlx-community/Qwen3-Coder-30B-A3B-Instruct-4bit": {
      "alias": "qwen-coder"
    }
  }
}

Verification

To verify that the fix worked:

  • Start the gateway from a clean shell.
  • Message an affected agent/channel.
  • Observe the gateway's behavior to ensure it no longer attempts to use openrouter/... models.

Extra Tips

  • Regularly review and update the OpenClaw configuration files to prevent stale references from accumulating.
  • Consider implementing a mechanism to automatically clear or update the bundled provider catalogs and hidden session or runtime state locations when a provider is removed.
  • If issues persist, try debugging the OpenClaw codebase to identify the source of the stale references and update the code accordingly.

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…

FAQ

Expected behavior

The gateway should only select models allowed by current config. In this installation, that means: • anthropic/claude-sonnet-4-6 • local vllm/... models in the configured allowlist

It should not attempt any openrouter/... models once OpenRouter has been completely removed.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING