fix(cli): display correct model for sub-agents in sessions list#18660
Conversation
ed974fb to
98f4cad
Compare
|
Thanks for checking! After deeper investigation, I can confirm the bug is reproducible — but only under specific conditions. Root cause (confirmed in When Why the patch validator rejects the model:
Reproduction:
Why it works for you: Your test sub-agent's model ( Our PR fixes the display side by prioritizing |
|
Addendum: To be fully transparent — there is also a config-side workaround: adding the sub-agent's model to However, I still think it's a bug because:
The config workaround exists, but the silent failure is the real problem. |
86c3911 to
0fbebe0
Compare
|
Thanks for asking us to reproduce — it led us to find and fix a deeper root cause we would have missed otherwise. Really appreciate the thorough review 🙏 |
cc99eff to
6913320
Compare
3e66511 to
d3870f7
Compare
53d61e5 to
8ec1150
Compare
- Prioritize runtime session model (entry.model) over default fallback in resolveSessionModelRef so sessions list shows the actual model used - Fix patch validator to always permit the target agent's own configured model, even when absent from agents.defaults.models allowlist - Add regression tests for both fixes Fixes openclaw#18451
ce881ec to
ba54c5a
Compare
|
Merged via squash. Thanks @robbyczgw-cla! |
…claw#18660) Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: ba54c5a Co-authored-by: robbyczgw-cla <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
When user changes model via /model command, it sets modelOverride and providerOverride fields. sessions.list was returning the original model/modelProvider fields instead. This is a minimal fix. Upstream fixed this properly in openclaw#18660 using resolveSessionModelRef() which handles more edge cases.
…claw#18660) Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: ba54c5a Co-authored-by: robbyczgw-cla <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras


Fixes #18451
Problem
openclaw statusandsessions listdisplayed the primary/default model (e.g.claude-sonnet-4-6) for sub-agent sessions, even when those sub-agents were actually running on a different model (e.g.synthetic/hf:moonshotai/Kimi-K2.5).This made debugging and monitoring confusing — the displayed model did not match what was actually being used.
Root Cause
Two related issues:
Display side (
session-utils.ts):resolveSessionModelRef()fell back to the default primary model too early, ignoringentry.model(the runtime model recorded after the run).Patch validator side (
sessions-patch.ts): When spawning a sub-agent,sessions.patchis called with the target agent's model. The patch validator builds its allowlist fromagents.defaults.models. If the sub-agent's model is not in that global allowlist, the patch is rejected with"model not allowed"— silently treated as recoverable — andentry.modelis never set. The session then falls back to the default in the display.The root cause of the silent failure: a target agent's own configured model should always be permitted in its own session patch, regardless of the global allowlist.
Solution
Fix 1 — Display (
session-utils.ts):Prioritize
entry.model(runtime model) overmodelOverrideand default fallback inresolveSessionModelRef.Fix 2 — Patch validator (
sessions-patch.ts):When patching a sub-agent session, resolve the target agent's own configured model (
agents.list[id].model.primary) and pass it as a hint toresolveAllowedModelRef— so it is always accepted even if absent fromagents.defaults.models.Fix 3 — Allowlist parsing (
model-selection.ts):buildAllowedModelSetnow parsesdefaultModelviaparseModelRef()instead of treating it as a plain model id string, correctly handling full refs likesynthetic/hf:moonshotai/Kimi-K2.5.Changes
src/gateway/session-utils.ts: Prioritize runtime model inresolveSessionModelRef()src/commands/status.summary.ts: Use corrected model resolutionsrc/commands/sessions.ts: Use corrected model resolution in sessions listsrc/gateway/sessions-patch.ts: Pass target agent model as allowlist hintsrc/agents/model-selection.ts: ParsedefaultModelviaparseModelRef()src/gateway/session-utils.test.ts: Tests for runtime model prioritysrc/gateway/sessions-patch.test.ts: Regression test for allowlist fix (agentkimiwithsynthetic/hf:moonshotai/Kimi-K2.5, global allowlist only containsanthropic/claude-sonnet-4-6)Testing
pnpm test -- src/gateway/sessions-patch.test.ts✅pnpm test -- src/gateway/session-utils.test.ts✅pnpm check(format + lint + typecheck) ✅🤖 AI-assisted: Code changes by gpt-5.3-codex, PR description and verification by claude-sonnet-4-6