fix(agents): resolve configured default model in runEmbeddedAgent (fixes #93419)#93428
Merged
vincentkoc merged 4 commits intoJun 16, 2026
Conversation
9d4cce8 to
7041c71
Compare
Member
|
Land-ready maintainer verification:
All relevant PR checks completed green. |
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jun 16, 2026
openclaw#93419) (openclaw#93428) * fix(agents): honor configured default model in embedded runs * fix(agents): resolve embedded defaults from runtime config * fix(agents): preserve embedded model routing semantics * test(agents): model current embedded attempts explicitly --------- Co-authored-by: Vincent Koc <25068+vincentkoc@users.noreply.github.com>
crh-code
pushed a commit
to crh-code/openclaw
that referenced
this pull request
Jun 18, 2026
openclaw#93419) (openclaw#93428) * fix(agents): honor configured default model in embedded runs * fix(agents): resolve embedded defaults from runtime config * fix(agents): preserve embedded model routing semantics * test(agents): model current embedded attempts explicitly --------- Co-authored-by: Vincent Koc <25068+vincentkoc@users.noreply.github.com>
badgerbees
pushed a commit
to badgerbees/openclaw
that referenced
this pull request
Jul 8, 2026
openclaw#93419) (openclaw#93428) * fix(agents): honor configured default model in embedded runs * fix(agents): resolve embedded defaults from runtime config * fix(agents): preserve embedded model routing semantics * test(agents): model current embedded attempts explicitly --------- Co-authored-by: Vincent Koc <25068+vincentkoc@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
runEmbeddedAgenthardcodesopenai/gpt-5.5as the default provider/model, ignoringagents.defaults.model.primary. Plugin-triggered embedded agent runs fail withNo API key found for provider "openai"even when a non-OpenAI default is configured and authenticated.src/agents/embedded-agent-runner/run.ts:747-748, the provider/model resolution chain isparams.provider ?? DEFAULT_PROVIDERandparams.model ?? DEFAULT_MODEL, with no check ofagents.defaults.model.primaryfrom the config.DEFAULT_PROVIDER/DEFAULT_MODEL, resolveagents.defaults.model.primaryviaresolveAgentModelPrimaryValueand parse the canonicalprovider/modelref withparseModelRef. The resolved provider/model are inserted into the fallback chain between explicit params and the hardcoded defaults.src/agents/embedded-agent-runner/run.ts— importresolveAgentModelPrimaryValueandparseModelRef; add configured-primary resolution step before the fallback chain.DEFAULT_PROVIDER/DEFAULT_MODELconstants indefaults.ts.modelFallbacksOverride).Reproduction
openclaw models set "anthropic/claude-sonnet-4-6".api.runtime.agent.runEmbeddedAgent({ ... })without passingproviderormodel.openai/gpt-5.5and fails withProviderAuthError: No API key found for provider "openai".anthropic/claude-sonnet-4-6, matching the configured default and the auto-reply pipeline resolution.Real behavior proof
Behavior or issue addressed (#93419):
runEmbeddedAgentnow resolvesagents.defaults.model.primaryfrom the config as the default provider/model when the caller does not pass explicitprovider/model, matching the documented contract that embedded runs use the same model resolution as channel-triggered replies.Real environment tested: Linux, Node 22 — in-memory test harness against the embedded agent runner.
Exact steps or command run after this patch:
node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.codex-app-server-recovery.test.ts src/agents/embedded-agent-runner/run.incomplete-turn.test.tsEvidence after fix:
Observed result after fix: The
runEmbeddedAgentInternalfunction now checksparams.config?.agents?.defaults?.modelviaresolveAgentModelPrimaryValuewhen neitherparams.providernorparams.modelis explicitly passed. The canonical model ref (e.g.,"anthropic/claude-sonnet-4-6") is parsed into{provider, model}viaparseModelRefand inserted into the fallback chain before the hardcodedDEFAULT_PROVIDER/DEFAULT_MODEL. All 121 existing embedded agent runner tests continue to pass, confirming no regressions in the execution, recovery, and compaction paths.What was not tested: A live plugin-triggered embedded agent run with a non-OpenAI configured default was not driven. The parseModelRef integration with live config was not exercised end-to-end.
Repro confirmation: Code-path analysis confirms the gap: before the fix, line 747-748 was
let provider = (params.provider ?? DEFAULT_PROVIDER)...andlet modelId = (params.model ?? DEFAULT_MODEL)...with no reference toagents.defaults.model. After the fix,resolveAgentModelPrimaryValue(params.config?.agents?.defaults?.model)is called and the result is parsed and inserted into the fallback chain.Risk / Mitigation
parseModelRefreturnsnullfor malformed model refs, causing a fallback to hardcoded defaults (same as before).Mitigation: When
configuredModelRefis null (invalid ref), the existing?? DEFAULT_PROVIDER/?? DEFAULT_MODELfallback is used, preserving backward compatibility.providerormodel.Mitigation: This is intentional — explicit caller parameters always take precedence over configured defaults, matching the principle of least surprise.
Change Type (select all)
Scope (select all touched areas)
Regression Test Plan
node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.codex-app-server-recovery.test.tsnode scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.incomplete-turn.test.tsReview Findings Addressed
N/A (initial submission)
Linked Issue/PR
Fixes #93419