Skip to content

Agents: show runtime model in session status - #51706

Closed
08820048 wants to merge 2 commits into
openclaw:mainfrom
08820048:fix-session-status-runtime-model-51526
Closed

08820048 wants to merge 2 commits into
openclaw:mainfrom
08820048:fix-session-status-runtime-model-51526

Conversation

@08820048

Copy link
Copy Markdown

Summary

  • Problem: session_status showed the configured default model even when the session store already recorded a different runtime model.
  • Why it matters: this made model routing, fallback, auth, and billing debugging misleading because session_status disagreed with openclaw sessions.
  • What changed: session_status now resolves its main model line from the runtime session model when no explicit per-session override is set, and the regression test covers that case.
  • What did NOT change (scope boundary): no model routing behavior changed, no auth flow changed, and no session persistence format changed.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

session_status now shows the runtime session model on the 🧠 Model: line when the session store has a persisted runtime model and there is no explicit per-session model override.

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS 26.4
  • Runtime/container: local zsh shell
  • Model/provider: N/A
  • Integration/channel (if any): agent session_status
  • Relevant config (redacted): default model openai-codex/gpt-5.4, session store runtime model anthropic/claude-opus-4-6

Steps

  1. Create a session entry whose persisted runtime model differs from the configured default model.
  2. Run session_status for that session.
  3. Inspect the 🧠 Model: line.

Expected

  • The 🧠 Model: line matches the runtime model stored on the session entry.

Actual

  • Before: session_status showed the configured default model.
  • After: session_status shows the persisted runtime session model unless an explicit per-session override exists.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: confirmed the tool now feeds the status card with the runtime model identity resolver instead of the default-model-only path, and added a regression test that asserts anthropic/claude-opus-4-6 wins over default openai-codex/gpt-5.4.
  • Edge cases checked: explicit per-session modelOverride still remains higher priority than runtime fallback; usage provider lookup now follows the same selected provider as the card.
  • What you did not verify: in this Codex terminal, pnpm test -- src/agents/openclaw-tools.session-status.test.ts started Vitest but hung before process exit, so I did not get a clean local wrapper completion signal even though the regression test was added.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert commit 48959d6c8
  • Files/config to restore: src/agents/tools/session-status-tool.ts, src/agents/openclaw-tools.session-status.test.ts
  • Known bad symptoms reviewers should watch for: session_status showing the wrong model when runtime model and default model differ.

Risks and Mitigations

  • Risk: sessions with unusual persisted model strings but no provider may rely on provider inference behavior.
    • Mitigation: the change uses the existing shared resolveSessionModelIdentityRef(...) helper that already backs other session model displays.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S 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 showing the configured default model instead of the runtime model that was actually used for a session. The fix introduces a two-tier resolution in session-status-tool.ts: when no explicit modelOverride is stored on the session entry, resolveSessionModelIdentityRef is called to surface the runtime entry.model/entry.modelProvider fields (the same helper already used elsewhere for session model display). The existing modelOverride path is preserved and now also correctly feeds modelForCard into defaultLabel, closing a secondary inconsistency where the model card could show the wrong model even with an explicit override.

Key observations:

  • resolveSessionModelIdentityRef returns { provider?: string; model: string } — the optional provider is safely handled with || configured.provider on line 383.
  • The regression test is end-to-end: it exercises the real resolveSessionModelIdentityRef implementation (the mock spreads actual and only stubs loadCombinedSessionStoreForGateway) and asserts both the positive and negative model strings.
  • No routing, auth, or persistence behavior is changed; the scope is exactly the card-building block.

Confidence Score: 5/5

  • This PR is safe to merge — the change is narrowly scoped to the status card display path with no behavioral, auth, or persistence side effects.
  • The fix is small and surgical (two new variables + reusing an existing helper), the optional provider field is handled defensively, the regression test exercises the real helper implementation, and no routing or auth logic was touched. No blocking issues were found.
  • No files require special attention.

Last reviewed commit: "Agents: show runtime..."

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 48959d6c8c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/tools/session-status-tool.ts Outdated
@@ -419,7 +435,7 @@ export function createSessionStatusTool(opts?: {
: `🕒 Time zone: ${userTimezone}`;

const agentDefaults = cfg.agents?.defaults ?? {};
const defaultLabel = `${configured.provider}/${configured.model}`;
const defaultLabel = `${providerForCard}/${modelForCard}`;

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 Badge Preserve selected model to keep fallback status visible

Setting defaultLabel to providerForCard/modelForCard makes the selected model equal the runtime model whenever a session has entry.model but no per-session override. In buildStatusMessage, fallback visibility is computed from selected-vs-active model mismatch plus fallbackNotice* state, so this change suppresses the ↪️ Fallback: line for active fallback sessions (the selected model is no longer the configured default). This regresses debugging for real fallback scenarios where the session is still running a non-selected model.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in a40015f87. The status card now keeps selected-model semantics for fallback detection and only uses a display-only runtime model when there is no active fallback state, so the fallback line remains visible. Added regression coverage in src/auto-reply/status.test.ts and src/agents/openclaw-tools.session-status.test.ts.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a40015f87d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/tools/session-status-tool.ts Outdated
Comment on lines 383 to 385
const providerForCard = resolvedCardModel.provider?.trim() || configured.provider;
const modelForCard = resolvedCardModel.model.trim();
const usageProvider = resolveUsageProviderId(providerForCard);

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 Badge Preserve unknown runtime provider in session status

When resolveSessionModelIdentityRef(...) returns only a model (for legacy entries where entry.modelProvider is missing/ambiguous), this fallback injects configured.provider, so status can emit synthetic refs like openai/claude-sonnet-4-6 and then resolve auth/usage against the wrong provider. In the new runtime-model display path this becomes user-visible misinformation; provider should remain unset in this branch instead of defaulting to the configured provider.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d16c9c390e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +456 to 460
const defaultProviderForCard = hasExplicitModelOverride || preserveFallbackStatus
? configured.provider
: (runtimeProviderForCard ?? "");
const defaultModelForCard = hasExplicitModelOverride
const defaultModelForCard = hasExplicitModelOverride || preserveFallbackStatus
? configured.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 Badge Use fallback-selected model instead of global default

Fresh evidence: the new preserveFallbackStatus branch hardcodes configured.provider/configured.model whenever fallback notice fields are present. That only works when the selected model is the global default; for sessions selected through channel/group routing (no explicit modelOverride persisted), fallbackNoticeSelectedModel can differ, so fallback matching in buildStatusMessage fails and session_status shows the wrong model/provider and hides the fallback line. Preserve the selected model from the stored fallback-selected ref rather than forcing the global default here.

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: merged #55425 already shipped the original persisted-runtime-model session_status fix, while the remaining selected-vs-active/fallback display concern is tracked by #42690 and this stale branch still has a fallback-selection bug.

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Review details

Best possible solution:

Keep the shipped #55425 behavior for the original symptom and pursue the selected/default-versus-active runtime display in #42690 or an equivalent current-main replacement targeting src/status.

Do we have a high-confidence way to reproduce the issue?

Yes. The PR defect has a high-confidence static reproduction: use fallback notice fields from a channel/group-selected route that differs from the global default, then the branch passes the wrong selected ref and fallback matching fails.

Is this the best way to solve the issue?

No. The branch is not the best fix because it edits stale status surfaces and couples fallback preservation to global defaults; the maintainable fix is a current src/status split between selected-model semantics and display/runtime identity.

Security review:

Security review cleared: The diff is limited to status rendering and tests and does not alter secrets, workflows, dependencies, install scripts, package metadata, or code execution paths.

What I checked:

Likely related people:

  • scoootscooob: Credited on merged fix: use runtime model and per-agent thinking defaults in status (thanks @scoootscooob, @xaeon2026, @ysfbsf) #55425, which shipped persisted runtime model display for session_status and touched the same tool/test behavior. (role: introduced shipped overlapping behavior; confidence: high; commits: 061d7c7ac0a3; files: src/agents/tools/session-status-tool.ts, src/agents/openclaw-tools.session-status.test.ts)
  • dutifulbob: Credited on fix: extract shared session status runtime #65807, which moved shared session status text into the current src/status split that this stale PR now needs to target. (role: recent adjacent maintainer; confidence: medium; commits: f027bd640a78; files: src/status/status-text.ts, src/status/status-message.ts, src/agents/tools/session-status.runtime.ts)
  • Peter Steinberger: Local current-main blame/log for central status files points mostly to grafted snapshot commits, which is useful routing context but weaker than feature-specific PR history. (role: current snapshot maintainer; confidence: low; commits: 0cd12d17d4c0, 6147e1b91d3e; files: src/agents/tools/session-status-tool.ts, src/status/status-text.ts, src/status/status-message.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 62b20e7fa2ed.

@clawsweeper

clawsweeper Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes:

This PR changes session_status and status rendering tests so the status card uses a persisted runtime session model when no explicit session override exists, then adds a follow-up attempt to keep active fallback details visible when runtime and selected models differ.

Required change before merge:

This is a narrow replacement candidate: the remaining defect is localized to status display semantics and tests, but the source PR is stale and should be translated to the current src/status split rather than merged as-is.

Review details

Best possible solution:

Land a focused current-main replacement that keeps ordinary runtime model display, separates display-only runtime identity from selected-model semantics in the src/status APIs, preserves unknown-provider display without fabricating provider refs, and keeps active fallback visibility correct for explicit overrides plus channel/group-selected fallback sessions.

Acceptance criteria:

  • pnpm test -- src/agents/openclaw-tools.session-status.test.ts
  • pnpm test -- src/auto-reply/status.test.ts -t "runtime|fallback|channel override"
  • pnpm check:changed in Testbox before handoff because this touches runtime/status behavior

What I checked:

Likely related people:

  • scoootscooob: Authored the merged fix: use runtime model and per-agent thinking defaults in status (thanks @scoootscooob, @xaeon2026, @ysfbsf) #55425 fix that shipped the persisted runtime model display path and touched the same session_status behavior now under review. (role: introduced shipped overlapping behavior; confidence: high; commits: 061d7c7ac0a3, #55425; files: src/agents/tools/session-status-tool.ts, src/agents/openclaw-tools.session-status.test.ts)
  • dutifulbob: Credited for fix: extract shared session status runtime #65807, which moved shared status text into the current src/status module split that this stale PR now needs to target. (role: recent adjacent maintainer; confidence: medium; commits: #65807; files: src/status/status-text.ts, src/status/status-message.ts, src/agents/tools/session-status.runtime.ts)
  • Peter Steinberger: Local current-main blame for the relevant status/session lines points to the grafted current snapshot commit; this is useful for routing but weaker than feature-specific PR history. (role: current snapshot maintainer; confidence: low; commits: a972c9ec; files: src/agents/tools/session-status-tool.ts, src/status/status-text.ts, src/status/status-message.ts)

Remaining risk / open question:

  • The adjacent open Heartbeat model leaks into user session status/runtime model #74217 heartbeat/runtime-model report may require a broader distinction between normal user-turn selection and background/internal runtime snapshots; that should not be silently folded into this PR without maintainer judgment.
  • The source branch is stale against the current src/status split, so a replacement or rebase needs current-code review rather than applying the old src/auto-reply/status.ts patch directly.

Codex review notes: model gpt-5.5, reasoning high; reviewed against acae48b790fa.

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: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session_status shows default model instead of runtime session model

1 participant