Bug type
Behavior bug (incorrect output/state without crash)
Summary
api.runtime.agent.runEmbeddedAgent(...) ignores the configured default model (agents.defaults.model) and hardcodes openai/gpt-5.5 as the primary provider/model when the caller does not pass provider/model, so plugin-triggered agent turns fail with No API key found for provider "openai" even when a different provider is configured and authenticated.
Steps to reproduce
- Install OpenClaw
2026.6.6 and configure a non-OpenAI default model, e.g. openclaw models set "anthropic/claude-sonnet-4-6" (writes agents.defaults.model.primary). Do not configure any OpenAI auth.
- From a native plugin, register a background service that calls the documented neutral helper without an explicit model:
const workspaceDir = (await api.runtime.agent.ensureAgentWorkspace()).dir;
await api.runtime.agent.runEmbeddedAgent({
sessionId: "repro:1",
runId: crypto.randomUUID(),
sessionFile: path.join(workspaceDir, "repro.jsonl"),
workspaceDir,
prompt: "summarize this",
timeoutMs: api.runtime.agent.resolveAgentTimeoutMs({ cfg: api.config }),
});
- Start the gateway (
openclaw gateway run) and trigger the run.
Expected behavior
The embedded run uses the configured default model (anthropic/claude-sonnet-4-6), matching the gateway's own resolution and the documented contract. The SDK runtime docs state:
runEmbeddedAgent(...) is the neutral helper for starting a normal OpenClaw agent turn from plugin code. It uses the same provider/model resolution and agent-harness selection as channel-triggered replies.
At startup the gateway logs the channel-reply resolution honoring the default:
[gateway] agent model: anthropic/claude-sonnet-4-6 (thinking=adaptive, fast=off)
Actual behavior
The embedded run resolves to openai/gpt-5.5 regardless of the configured default, and fails:
[plugins] folder-watch: add probe.txt -> running agent
[diagnostic] lane task error: lane=main ... error="ProviderAuthError: No API key found for provider "openai". Auth store: .../agents/main/agent/openclaw-agent.sqlite ..."
I verified the resolution does not consult agents.defaults.model three independent ways (OpenClaw 2026.6.6):
| Attempt |
Result |
openclaw models set anthropic/... (default model), no provider/model passed |
embedded run → openai ❌ |
pass full config snapshot to the call, no provider/model |
openai ❌ |
omit config entirely, no provider/model |
openai ❌ |
pass provider: "anthropic", model: "claude-sonnet-4-6" explicitly |
resolves anthropic ✅ (only auth missing) |
Note: passing model: "anthropic/claude-sonnet-4-6" (a canonical provider/model ref) without a separate provider produces FailoverError: Unknown model: openai/anthropic/claude-sonnet-4-6 — i.e. model is treated as a bare id and provider is prepended (defaulting to openai).
Root cause (code references, 2026.6.6 npm build)
Primary turn model is hardcoded in runEmbeddedAgent, dist/embedded-agent-L9tQiaO-.js:2286-2287:
let provider = (params.provider ?? "openai").trim() || "openai";
let modelId = (params.model ?? "gpt-5.5").trim() || "gpt-5.5";
Constants in dist/plugin-sdk/defaults-6FEupg54.d.ts:
declare const DEFAULT_PROVIDER = "openai";
declare const DEFAULT_MODEL = "gpt-5.5";
The only model-related config consulted on this path is the fallback chain (modelFallbacksOverride / hasEmbeddedRunConfiguredModelFallbacks) and the compaction model (agents.defaults.compaction.model, dist/compaction-runtime-context-DTO0IG8s.js:44-46). agents.defaults.model is never read for the primary model.
OpenClaw version
2026.6.6 (8c802aa)
Operating system
Reproduced on macOS (Darwin); originally observed on Windows 11
Install method
npm global (npm install -g openclaw@latest)
Model
Configured default: anthropic/claude-sonnet-4-6 (agents.defaults.model.primary); embedded run incorrectly uses openai/gpt-5.5
Provider / routing chain
openclaw -> embedded agent runner (runEmbeddedAgent) -> provider auth resolution for agent main
Logs, screenshots, and evidence
[gateway] agent model: anthropic/claude-sonnet-4-6 (thinking=adaptive, fast=off)
[plugins] folder-watch: add probe.txt -> running agent
[diagnostic] lane task error: lane=main durationMs=622 error="ProviderAuthError: No API key found for provider "openai". Auth store: /Users/<user>/.openclaw/agents/main/agent/openclaw-agent.sqlite (agentDir: /Users/<user>/.openclaw/agents/main/agent). Configure auth for this agent ..."
# with model:"anthropic/claude-sonnet-4-6" (canonical ref, no separate provider):
[diagnostic] lane task error: lane=main error="FailoverError: Unknown model: openai/anthropic/claude-sonnet-4-6"
Impact and severity
- Affected: any plugin that calls
api.runtime.agent.runEmbeddedAgent(...) without an explicit provider/model, for users whose configured default provider is not OpenAI.
- Severity: blocks the workflow — embedded agent turns never run; fails closed with a misleading "provider openai" auth error.
- Frequency: always (deterministic) when no explicit
provider/model is passed.
- Consequence: plugins silently route to OpenAI regardless of the user's configured provider; users must hardcode/pin a model per plugin. Also a documentation mismatch with the SDK runtime page's "same provider/model resolution as channel-triggered replies" claim.
Additional information
Workaround: pass provider and model to runEmbeddedAgent separately (split a provider/model ref into provider + bare model). A fix could have runEmbeddedAgent fall back to the agent's resolved agents.defaults.model (the same resolution used for the gateway agent model: line) before applying the openai/gpt-5.5 constants.
Bug type
Behavior bug (incorrect output/state without crash)
Summary
api.runtime.agent.runEmbeddedAgent(...)ignores the configured default model (agents.defaults.model) and hardcodesopenai/gpt-5.5as the primary provider/model when the caller does not passprovider/model, so plugin-triggered agent turns fail withNo API key found for provider "openai"even when a different provider is configured and authenticated.Steps to reproduce
2026.6.6and configure a non-OpenAI default model, e.g.openclaw models set "anthropic/claude-sonnet-4-6"(writesagents.defaults.model.primary). Do not configure any OpenAI auth.openclaw gateway run) and trigger the run.Expected behavior
The embedded run uses the configured default model (
anthropic/claude-sonnet-4-6), matching the gateway's own resolution and the documented contract. The SDK runtime docs state:At startup the gateway logs the channel-reply resolution honoring the default:
Actual behavior
The embedded run resolves to
openai/gpt-5.5regardless of the configured default, and fails:I verified the resolution does not consult
agents.defaults.modelthree independent ways (OpenClaw2026.6.6):openclaw models set anthropic/...(default model), noprovider/modelpassedopenai❌configsnapshot to the call, noprovider/modelopenai❌configentirely, noprovider/modelopenai❌provider: "anthropic",model: "claude-sonnet-4-6"explicitlyanthropic✅ (only auth missing)Note: passing
model: "anthropic/claude-sonnet-4-6"(a canonicalprovider/modelref) without a separateproviderproducesFailoverError: Unknown model: openai/anthropic/claude-sonnet-4-6— i.e.modelis treated as a bare id andprovideris prepended (defaulting toopenai).Root cause (code references,
2026.6.6npm build)Primary turn model is hardcoded in
runEmbeddedAgent,dist/embedded-agent-L9tQiaO-.js:2286-2287:Constants in
dist/plugin-sdk/defaults-6FEupg54.d.ts:The only model-related config consulted on this path is the fallback chain (
modelFallbacksOverride/hasEmbeddedRunConfiguredModelFallbacks) and the compaction model (agents.defaults.compaction.model,dist/compaction-runtime-context-DTO0IG8s.js:44-46).agents.defaults.modelis never read for the primary model.OpenClaw version
2026.6.6 (8c802aa)
Operating system
Reproduced on macOS (Darwin); originally observed on Windows 11
Install method
npm global (
npm install -g openclaw@latest)Model
Configured default:
anthropic/claude-sonnet-4-6(agents.defaults.model.primary); embedded run incorrectly usesopenai/gpt-5.5Provider / routing chain
openclaw -> embedded agent runner (runEmbeddedAgent) -> provider auth resolution for agent
mainLogs, screenshots, and evidence
Impact and severity
api.runtime.agent.runEmbeddedAgent(...)without an explicitprovider/model, for users whose configured default provider is not OpenAI.provider/modelis passed.Additional information
Workaround: pass
providerandmodeltorunEmbeddedAgentseparately (split aprovider/modelref intoprovider+ baremodel). A fix could haverunEmbeddedAgentfall back to the agent's resolvedagents.defaults.model(the same resolution used for the gatewayagent model:line) before applying theopenai/gpt-5.5constants.