Skip to content

fix: use runtime model and per-agent thinking defaults in status (thanks @scoootscooob, @xaeon2026, @ysfbsf) - #55425

Merged
scoootscooob merged 3 commits into
openclaw:mainfrom
scoootscooob:codex/fix-51526-53826
Mar 27, 2026
Merged

scoootscooob merged 3 commits into
openclaw:mainfrom
scoootscooob:codex/fix-51526-53826

Conversation

@scoootscooob

@scoootscooob scoootscooob commented Mar 26, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Problem: session_status showed the configured default model instead of the persisted runtime session model when no explicit override was set, and both session_status and /status ignored per-agent thinkingDefault.
  • Why it matters: the status surfaces were misleading exactly when users were trying to debug model routing or agent defaults.
  • What changed: session_status now uses the persisted runtime session model for the status card fallback, aligns auth/usage lookup to that selected provider, and both status paths now merge per-agent thinkingDefault before falling back to global defaults.
  • What did NOT change (scope boundary): explicit session model override behavior is unchanged, and no new command, network, or config surface was added.

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

Root Cause / Regression History (if applicable)

  • Root cause: session_status built its selected model label from the configured default unless a session override existed, instead of using the persisted runtime model already stored on the session entry. Separately, both status paths only threaded agents.defaults into buildStatusMessage, which dropped per-agent thinkingDefault.
  • Missing detection / guardrail: there was no regression coverage that asserted the rendered status card against a persisted runtime model or a per-agent thinkingDefault.
  • Prior context (git blame, prior PR, issue, or refactor if known): unknown.
  • Why this regressed now: this appears to be a long-standing mismatch between runtime session state and status-card fallback logic rather than a new refactor regression.
  • If unknown, what was ruled out: verified this was not caused by explicit override handling; that path is still preserved.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/agents/openclaw-tools.session-status.test.ts and src/auto-reply/reply/commands-status.thinking-default.test.ts
  • Scenario the test should lock in: a session entry with a persisted runtime model but no override should render that runtime model in session_status, and both session_status and /status should render a per-agent thinkingDefault.
  • Why this is the smallest reliable guardrail: these tests exercise the real status-card builders at the session/tool seam without needing full channel or gateway end-to-end setup.
  • Existing test that already covers this (if any): none for these exact regressions.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

  • session_status now shows the persisted runtime model when it differs from the configured default and there is no explicit override.
  • session_status and /status now show the selected agent’s thinkingDefault instead of falling back to global defaults only.

Diagram (if applicable)

Before:
[persisted runtime model != configured default] -> [status fallback uses configured default] -> [misleading model line]
[agent-specific thinkingDefault] -> [status builder reads only agents.defaults] -> [Think line falls back incorrectly]

After:
[persisted runtime model != configured default] -> [status fallback uses runtime session model] -> [model line matches runtime]
[agent-specific thinkingDefault] -> [status builder resolves per-agent config first] -> [Think line matches agent]

Security Impact (required)

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

Repro + Verification

Environment

  • OS: Darwin 24.1.0 arm64
  • Runtime/container: node v25.2.1, pnpm 10.32.1
  • Model/provider: configured default openai/gpt-5.4; persisted runtime session model custom/runtime-model
  • Integration/channel (if any): local built runtime, WhatsApp-shaped status path
  • Relevant config (redacted): per-agent thinkingDefault: xhigh for agent kira

Steps

  1. Create a session entry with no explicit override, but with persisted runtime model fields set to custom/runtime-model.
  2. Configure an agent-specific thinkingDefault: xhigh.
  3. Run the real session_status tool and the /status builder.

Expected

  • session_status shows custom/runtime-model instead of the configured default.
  • Both status outputs show Think: xhigh.

Actual

  • Before this fix, session_status fell back to the configured default model and both status outputs ignored the per-agent thinking default.

Evidence

Attach at least one:

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

Built-runtime smoke on this branch:

{
  "runtimeModelLine": "🧠 Model: custom/runtime-model · 🔑 unknown",
  "sessionStatusThinkLine": "⚙️ Runtime: direct · Think: xhigh · elevated",
  "statusReplyThinkLine": "⚙️ Runtime: direct · Think: xhigh · elevated"
}

Scoped verification commands:

  • pnpm test -- src/agents/openclaw-tools.session-status.test.ts
  • pnpm test -- src/auto-reply/reply/commands-status.thinking-default.test.ts
  • pnpm test -- src/auto-reply/status.test.ts -t "shows selected model and active runtime model when they differ"
  • pnpm test -- src/gateway/session-utils.test.ts -t "prefers runtime model/provider from session entry"
  • pnpm build

Human Verification (required)

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

  • Verified scenarios: ran the targeted tests above, built the repo, and ran a built-runtime smoke that exercised both session_status and /status against a real on-disk session store.
  • Edge cases checked: no-override runtime-model fallback, per-agent thinking fallback, and provider/auth/usage lookup staying aligned to the selected provider in session_status.
  • What you did not verify: full pnpm check / pre-commit stack on current main is currently blocked by unrelated pnpm tsgo errors in extensions/discord/src/monitor/provider.lifecycle.test.ts; pnpm build was green.

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)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: status output could have changed for explicit override sessions.
    • Mitigation: the fallback switch only applies when there is no explicit session override; override handling is preserved and covered by adjacent existing behavior.
  • Risk: status auth/usage labels could drift when the runtime provider differs from the configured default.
    • Mitigation: session_status now uses the same selected provider for the card, auth label, and usage-provider lookup.

Acknowledgements

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Mar 26, 2026
@scoootscooob scoootscooob changed the title Status: fix runtime model and per-agent thinking display Status: fix runtime model and per-agent thinking defaults Mar 26, 2026
@scoootscooob scoootscooob changed the title Status: fix runtime model and per-agent thinking defaults fix: use runtime model and per-agent thinking defaults in status Mar 26, 2026

@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: d8f67f8491

ℹ️ 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 Resolved
@greptile-apps

greptile-apps Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes two related bugs in the status display surfaces (session_status tool and /status command): (1) the status card was falling back to the configured default model instead of the persisted runtime session model when no explicit override was set, and (2) both status paths ignored per-agent thinkingDefault, falling through to global agents.defaults only.\n\nKey changes:\n- session-status-tool.ts: uses resolveSessionModelIdentityRef to read the runtime model/modelProvider fields from the session entry, guarded by hasExplicitModelOverride so existing explicit-override behavior is unchanged; also calls resolveAgentConfig to supply per-agent thinkingDefault to buildStatusMessage.\n- commands-status.ts: same resolveAgentConfig call and thinkingDefault merge applied to buildStatusReply.\n- Two new targeted regression tests added — one asserting the runtime model appears in the card, one asserting per-agent thinkingDefault is rendered in the status text.\n\nThe buildStatusMessage mock is appropriately upgraded from a static stub to a captured spy so call arguments can be verified. The changes are minimal, well-scoped, and backward-compatible.

Confidence Score: 4/5

Safe to merge; the fix is minimal and well-guarded — explicit-override paths are unchanged and both status surfaces now correctly reflect runtime and per-agent state.

The logic changes are correct and tightly scoped. The hasExplicitModelOverride guard ensures pre-existing override behaviour is preserved. Both code paths have new regression tests. A one-point deduction reflects the minor test-isolation issue (module-scoped mockConfig mutation without restoration) that is unlikely to cause a CI failure today but is a latent hazard for future tests.

src/agents/openclaw-tools.session-status.test.ts — the per-agent thinking test modifies mockConfig without restoring it.

Important Files Changed

Filename Overview
src/agents/tools/session-status-tool.ts Introduces resolveSessionModelIdentityRef to derive the runtime provider/model from the persisted session entry when no explicit override is present, and threads per-agent thinkingDefault through to buildStatusMessage via resolveAgentConfig. Logic is correct and the hasExplicitModelOverride guard preserves the existing explicit-override path.
src/auto-reply/reply/commands-status.ts Adds resolveAgentConfig call and merges per-agent thinkingDefault ahead of the global agentDefaults.thinkingDefault fallback. Minimal, targeted change mirroring the fix in session-status-tool.ts.
src/agents/openclaw-tools.session-status.test.ts Upgrades buildStatusMessage mock to a captured spy and adds two targeted regression tests. Minor: the per-agent thinking test leaves mockConfig mutated for subsequent tests.
src/auto-reply/reply/commands-status.thinking-default.test.ts New integration-level test that exercises buildStatusReply end-to-end and asserts the rendered Think: xhigh line for a per-agent thinkingDefault. Well-isolated via granular vi.mock stubs.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/agents/openclaw-tools.session-status.test.ts
Line: 466-496

Comment:
**`mockConfig` not restored after mutation**

The "passes per-agent thinkingDefault" test assigns a new value to the module-scoped `mockConfig` but never restores it. Because `loadFreshOpenClawToolsForSessionStatusTest` (called in `beforeEach`) does not reset `mockConfig` to `createMockConfig()`, all subsequent tests in this describe block will run with a config that includes `agents.list: [{ id: "kira", thinkingDefault: "xhigh" }]`.

In practice this won't break existing tests (the kira entry won't match the default agent id used by `getSessionStatusTool("main")`), but it's a latent isolation hazard. Consider saving and restoring `mockConfig` around the mutation:

```suggestion
  it("passes per-agent thinkingDefault through to the status card", async () => {
    resetSessionStore({
      "agent:kira:main": {
        sessionId: "agent-thinking",
        updatedAt: 10,
      },
    });
    const savedConfig = mockConfig;
    mockConfig = {
      session: { mainKey: "main", scope: "per-sender" },
      agents: {
        defaults: {
          model: { primary: "openai/gpt-5.4" },
          models: {},
        },
        list: [
          {
            id: "kira",
            model: "openai/gpt-5.4",
            thinkingDefault: "xhigh",
          },
        ],
      },
      tools: {
        agentToAgent: { enabled: false },
      },
    };

    const tool = getSessionStatusTool("agent:kira:main");

    await tool.execute("call-agent-thinking", {});

    expect(buildStatusMessageMock).toHaveBeenCalledWith(
      expect.objectContaining({
        agentId: "kira",
        agent: expect.objectContaining({
          thinkingDefault: "xhigh",
        }),
      }),
    );
    mockConfig = savedConfig;
  });
```

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

Reviews (1): Last reviewed commit: "Status: fix runtime model and per-agent ..." | Re-trigger Greptile

@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: 76c218f602

ℹ️ 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 +429 to +433
? configured.provider
: (runtimeProviderForCard ?? "");
const defaultModelForCard = hasExplicitModelOverride
? configured.model
: (runtimeModelForCard || 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 Keep configured model as selected when fallback is active

When a session has no explicit override but is currently on a runtime fallback (for example fallbackNoticeSelectedModel=openai/..., fallbackNoticeActiveModel=anthropic/..., and entry.modelProvider/model reflect the fallback), this change makes session_status treat the runtime model as the selected model. That causes buildStatusMessage to see selected and active as equal, so resolveActiveFallbackState no longer emits the fallback line, hiding an active fallback condition from users. This is a behavior regression from the previous tool output and makes fallback debugging less accurate.

Useful? React with 👍 / 👎.

@scoootscooob
scoootscooob force-pushed the codex/fix-51526-53826 branch 3 times, most recently from 782aef6 to 051a98c Compare March 27, 2026 00:42
@scoootscooob scoootscooob changed the title fix: use runtime model and per-agent thinking defaults in status fix: use runtime model and per-agent thinking defaults in status (thanks @scoootscooob, @xaeon2026, @ysfbsf) Mar 27, 2026
@scoootscooob
scoootscooob force-pushed the codex/fix-51526-53826 branch from 7909e2e to 061d7c7 Compare March 27, 2026 00:47
@scoootscooob
scoootscooob merged commit cc359d4 into openclaw:main Mar 27, 2026
8 checks passed
@scoootscooob

Copy link
Copy Markdown
Member Author

Merged via squash.

Thanks @scoootscooob!

pxnt pushed a commit to pxnt/openclaw that referenced this pull request Mar 27, 2026
…nks @scoootscooob, @xaeon2026, @ysfbsf) (openclaw#55425)

Merged via squash.

Prepared head SHA: 061d7c7
Co-authored-by: scoootscooob <[email protected]>
Co-authored-by: scoootscooob <[email protected]>
Reviewed-by: @scoootscooob
godlin-gh pushed a commit to YouMindInc/openclaw that referenced this pull request Mar 27, 2026
…nks @scoootscooob, @xaeon2026, @ysfbsf) (openclaw#55425)

Merged via squash.

Prepared head SHA: 061d7c7
Co-authored-by: scoootscooob <[email protected]>
Co-authored-by: scoootscooob <[email protected]>
Reviewed-by: @scoootscooob
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…nks @scoootscooob, @xaeon2026, @ysfbsf) (openclaw#55425)

Merged via squash.

Prepared head SHA: 061d7c7
Co-authored-by: scoootscooob <[email protected]>
Co-authored-by: scoootscooob <[email protected]>
Reviewed-by: @scoootscooob
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…nks @scoootscooob, @xaeon2026, @ysfbsf) (openclaw#55425)

Merged via squash.

Prepared head SHA: 061d7c7
Co-authored-by: scoootscooob <[email protected]>
Co-authored-by: scoootscooob <[email protected]>
Reviewed-by: @scoootscooob
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…nks @scoootscooob, @xaeon2026, @ysfbsf) (openclaw#55425)

Merged via squash.

Prepared head SHA: 061d7c7
Co-authored-by: scoootscooob <[email protected]>
Co-authored-by: scoootscooob <[email protected]>
Reviewed-by: @scoootscooob
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
…nks @scoootscooob, @xaeon2026, @ysfbsf) (openclaw#55425)

Merged via squash.

Prepared head SHA: 061d7c7
Co-authored-by: scoootscooob <[email protected]>
Co-authored-by: scoootscooob <[email protected]>
Reviewed-by: @scoootscooob
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
…nks @scoootscooob, @xaeon2026, @ysfbsf) (openclaw#55425)

Merged via squash.

Prepared head SHA: 061d7c7
Co-authored-by: scoootscooob <[email protected]>
Co-authored-by: scoootscooob <[email protected]>
Reviewed-by: @scoootscooob
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
…nks @scoootscooob, @xaeon2026, @ysfbsf) (openclaw#55425)

Merged via squash.

Prepared head SHA: 061d7c7
Co-authored-by: scoootscooob <[email protected]>
Co-authored-by: scoootscooob <[email protected]>
Reviewed-by: @scoootscooob
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
…nks @scoootscooob, @xaeon2026, @ysfbsf) (openclaw#55425)

Merged via squash.

Prepared head SHA: 061d7c7
Co-authored-by: scoootscooob <[email protected]>
Co-authored-by: scoootscooob <[email protected]>
Reviewed-by: @scoootscooob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Per-agent thinkingDefault ignored in /status and session_status display session_status shows default model instead of runtime session model

1 participant