Repository navigation
fix: use runtime model and per-agent thinking defaults in status (thanks @scoootscooob, @xaeon2026, @ysfbsf) - #55425
Conversation
There was a problem hiding this comment.
💡 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".
Greptile SummaryThis PR fixes two related bugs in the status display surfaces ( Confidence Score: 4/5Safe 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.
|
| 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
a89c225 to
80c6379
Compare
80c6379 to
76c218f
Compare
There was a problem hiding this comment.
💡 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".
| ? configured.provider | ||
| : (runtimeProviderForCard ?? ""); | ||
| const defaultModelForCard = hasExplicitModelOverride | ||
| ? configured.model | ||
| : (runtimeModelForCard || configured.model); |
There was a problem hiding this comment.
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 👍 / 👎.
782aef6 to
051a98c
Compare
Co-authored-by: xaeon2026 <[email protected]> Co-authored-by: youssef <[email protected]>
7909e2e to
061d7c7
Compare
|
Merged via squash.
Thanks @scoootscooob! |
…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
…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
…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
…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
…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
…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
…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
…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
…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
Summary
session_statusshowed the configured default model instead of the persisted runtime session model when no explicit override was set, and bothsession_statusand/statusignored per-agentthinkingDefault.session_statusnow 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-agentthinkingDefaultbefore falling back to global defaults.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
session_statusbuilt 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 threadedagents.defaultsintobuildStatusMessage, which dropped per-agentthinkingDefault.thinkingDefault.git blame, prior PR, issue, or refactor if known): unknown.Regression Test Plan (if applicable)
src/agents/openclaw-tools.session-status.test.tsandsrc/auto-reply/reply/commands-status.thinking-default.test.tssession_status, and bothsession_statusand/statusshould render a per-agentthinkingDefault.User-visible / Behavior Changes
session_statusnow shows the persisted runtime model when it differs from the configured default and there is no explicit override.session_statusand/statusnow show the selected agent’sthinkingDefaultinstead of falling back to global defaults only.Diagram (if applicable)
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation: N/ARepro + Verification
Environment
Darwin 24.1.0 arm64node v25.2.1,pnpm 10.32.1openai/gpt-5.4; persisted runtime session modelcustom/runtime-modelthinkingDefault: xhighfor agentkiraSteps
custom/runtime-model.thinkingDefault: xhigh.session_statustool and the/statusbuilder.Expected
session_statusshowscustom/runtime-modelinstead of the configured default.Think: xhigh.Actual
session_statusfell back to the configured default model and both status outputs ignored the per-agent thinking default.Evidence
Attach at least one:
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.tspnpm test -- src/auto-reply/reply/commands-status.thinking-default.test.tspnpm 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 buildHuman Verification (required)
What you personally verified (not just CI), and how:
session_statusand/statusagainst a real on-disk session store.session_status.pnpm check/ pre-commit stack on currentmainis currently blocked by unrelatedpnpm tsgoerrors inextensions/discord/src/monitor/provider.lifecycle.test.ts;pnpm buildwas green.Review Conversations
Compatibility / Migration
Yes)No)No)Risks and Mitigations
session_statusnow uses the same selected provider for the card, auth label, and usage-provider lookup.Acknowledgements