Skip to content

Fix session_status runtime model display - #51610

Closed
xaeon2026 wants to merge 1 commit into
openclaw:mainfrom
xaeon2026:fix-session-status-runtime-model
Closed

xaeon2026 wants to merge 1 commit into
openclaw:mainfrom
xaeon2026:fix-session-status-runtime-model

Conversation

@xaeon2026

Copy link
Copy Markdown
Contributor

Fix session_status to show runtime session model instead of agent default

Summary

This PR fixes session_status reporting the agent default model on the 🧠 Model: line even when the session store already records a different runtime model.

Before this change:

  • openclaw sessions could show the correct runtime model
  • session_status could still show the configured default model

After this change:

  • session_status resolves the session runtime model via resolveSessionModelIdentityRef(...)
  • when there is no explicit per-session override, the status card uses that runtime identity
  • auth/usage provider selection is aligned to the same resolved model provider

Root Cause

session_status was constructing its card from resolveDefaultModelForAgent(...) plus providerOverride/modelOverride, but it ignored sessionEntry.modelProvider/model.

So a persisted runtime switch such as:

  • default: openai-codex/gpt-5.4
  • actual session runtime: anthropic/claude-opus-4-6

would still render the default model in the status card.

Fix

In src/agents/tools/session-status-tool.ts:

  • import and use resolveSessionModelIdentityRef(...)
  • derive selectedProviderForCard from:
    • providerOverride
    • else runtime modelProvider
    • else configured default provider
  • derive selectedModelForCard from:
    • modelOverride
    • else runtime model
  • build the status card primary model from that resolved pair
  • use the same provider for auth/usage lookup

Tests

Added regression coverage in:

  • src/agents/openclaw-tools.session-status.test.ts

New test verifies that when the session entry contains:

  • modelProvider: "anthropic"
  • model: "claude-sonnet-4-5"

the status card shows:

  • 🧠 Model: anthropic/claude-sonnet-4-5

and does not fall back to the configured default model line.

Verification

Ran:

  • pnpm exec vitest run src/agents/openclaw-tools.session-status.test.ts
  • pnpm exec vitest run src/gateway/session-utils.test.ts -t "resolveSessionModelIdentityRef"

Both passed locally.

Issue

Closes #51526

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Mar 21, 2026
@greptile-apps

greptile-apps Bot commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes session_status always rendering the configured-default model on the 🧠 Model: line, even when the session store already recorded a different runtime model via modelProvider/model fields. The fix introduces resolveSessionModelIdentityRef into the status card derivation path, so the resolved provider and model correctly reflect the actual session runtime state.

  • Core fix (session-status-tool.ts lines 370–373): resolveSessionModelIdentityRef is now called to derive runtimeModelRef, and selectedProviderForCard/selectedModelForCard are built with the priority providerOverride > runtimeModelRef.provider > configured.provider (and modelOverride > runtimeModelRef.model). This also aligns the auth/usage provider lookup (usageProvider) with the corrected provider.
  • Regression test (openclaw-tools.session-status.test.ts): New test verifies that a session entry carrying modelProvider: "anthropic" and model: "claude-sonnet-4-5" produces a card containing 🧠 Model: anthropic/claude-sonnet-4-5 and not the configured default. Notably, the test uses the real resolveSessionModelIdentityRef implementation (not a stub) because the session-utils.js mock spreads ...actual.
  • Minor edge case: When a session has a stale runtime model/modelProvider from a previous run alongside an in-flight modelOverride (but no providerOverride), the displayed provider may come from the old runtime run rather than the override's expected provider. This is a transient state and the pre-existing behavior was worse (always showing the configured default), so it is not a regression.

Confidence Score: 4/5

  • PR is safe to merge; it correctly fixes the primary regression with a targeted, well-tested change.
  • The fix is logically correct for the primary case (runtime model without overrides) and the regression test exercises the real implementation. A minor edge-case inconsistency (stale runtime provider shown alongside an in-flight model override when providerOverride is absent) was identified, but it is transient, pre-existing in spirit, and does not affect normal usage paths.
  • No files require special attention beyond the P2 style note on src/agents/tools/session-status-tool.ts lines 371–373.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/agents/tools/session-status-tool.ts
Line: 371-373

Comment:
**Potential provider/model mismatch in edge case**

When a session has a runtime `model`/`modelProvider` from a previous run AND an explicit `modelOverride` (but no `providerOverride`), the derived values can be inconsistent:

- `selectedProviderForCard` → `runtimeModelRef.provider` (the *previous run's* provider)
- `selectedModelForCard` → `entry.modelOverride` (the new model override)

This produces a label like `anthropic/gpt-4o` until the next run updates `entry.model`/`entry.modelProvider`. The window is transient and the pre-PR state was worse (always showing the configured default), but aligning both values from the same source would be cleaner:

```typescript
const selectedProviderForCard =
  resolved.entry.providerOverride?.trim() ||
  (resolved.entry.modelOverride ? undefined : runtimeModelRef.provider) ||
  configured.provider;
const selectedModelForCard =
  resolved.entry.modelOverride?.trim() || runtimeModelRef.model;
```

Or alternatively, derive the provider from the model override's string when `providerOverride` is absent but `modelOverride` is present (similar to how `resolveSessionModelRef` does it via `parseModelRef`).

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: "Fix session_status r..."

Comment on lines +371 to +373
const selectedProviderForCard =
resolved.entry.providerOverride?.trim() || runtimeModelRef.provider || configured.provider;
const selectedModelForCard = resolved.entry.modelOverride?.trim() || runtimeModelRef.model;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Potential provider/model mismatch in edge case

When a session has a runtime model/modelProvider from a previous run AND an explicit modelOverride (but no providerOverride), the derived values can be inconsistent:

  • selectedProviderForCard → runtimeModelRef.provider (the previous run's provider)
  • selectedModelForCard → entry.modelOverride (the new model override)

This produces a label like anthropic/gpt-4o until the next run updates entry.model/entry.modelProvider. The window is transient and the pre-PR state was worse (always showing the configured default), but aligning both values from the same source would be cleaner:

const selectedProviderForCard =
  resolved.entry.providerOverride?.trim() ||
  (resolved.entry.modelOverride ? undefined : runtimeModelRef.provider) ||
  configured.provider;
const selectedModelForCard =
  resolved.entry.modelOverride?.trim() || runtimeModelRef.model;

Or alternatively, derive the provider from the model override's string when providerOverride is absent but modelOverride is present (similar to how resolveSessionModelRef does it via parseModelRef).

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/tools/session-status-tool.ts
Line: 371-373

Comment:
**Potential provider/model mismatch in edge case**

When a session has a runtime `model`/`modelProvider` from a previous run AND an explicit `modelOverride` (but no `providerOverride`), the derived values can be inconsistent:

- `selectedProviderForCard` → `runtimeModelRef.provider` (the *previous run's* provider)
- `selectedModelForCard` → `entry.modelOverride` (the new model override)

This produces a label like `anthropic/gpt-4o` until the next run updates `entry.model`/`entry.modelProvider`. The window is transient and the pre-PR state was worse (always showing the configured default), but aligning both values from the same source would be cleaner:

```typescript
const selectedProviderForCard =
  resolved.entry.providerOverride?.trim() ||
  (resolved.entry.modelOverride ? undefined : runtimeModelRef.provider) ||
  configured.provider;
const selectedModelForCard =
  resolved.entry.modelOverride?.trim() || runtimeModelRef.model;
```

Or alternatively, derive the provider from the model override's string when `providerOverride` is absent but `modelOverride` is present (similar to how `resolveSessionModelRef` does it via `parseModelRef`).

How can I resolve this? If you propose a fix, please make it concise.

@scoootscooob

Copy link
Copy Markdown
Member

Thanks for the earlier runtime-model fix here.

I folded the overlapping session_status runtime-model work from #51610 into #55425 and added Co-authored-by credit so the consolidated branch preserves attribution when it lands.

I’m consolidating on #55425 because it carries the same core fix plus the follow-up review correction for legacy sessions where the runtime model is known but the provider is unknown.

PR: #55425

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session_status shows default model instead of runtime session model

2 participants