Skip to content

Commit ab03267

Browse files
committed
fix: simplify gateway model startup modes
1 parent 34f805a commit ab03267

4 files changed

Lines changed: 95 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Docs: https://docs.openclaw.ai
5959

6060
### Fixes
6161

62-
- Gateway/startup: include the resolved thinking, reasoning, and fast-mode defaults in the `agent model` startup log line so operator logs show which mode new sessions will inherit.
62+
- Gateway/startup: include resolved thinking and fast-mode defaults in the `agent model` startup log line, defaulting unset startup thinking to `medium` without mixing in reasoning visibility.
6363
- Gateway/watch: suppress sync-I/O trace output during `pnpm gateway:watch --benchmark` unless explicitly requested, so CPU profiling no longer floods the terminal with stack traces.
6464
- Gateway/watch: when benchmark sync-I/O tracing is explicitly enabled, tee trace blocks to the benchmark output log and filter them from the terminal pane while keeping normal Gateway logs visible.
6565
- Agents/OpenAI: default direct OpenAI Responses models to the SSE transport instead of WebSocket auto-selection, preventing pi runtime chat turns from hanging on servers where the WebSocket path stalls while the OpenAI HTTP stream works. Thanks @vincentkoc.

docs/gateway/logging.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ At startup, the Gateway logs the resolved default agent model together with the
1919
mode defaults that affect new sessions, for example:
2020

2121
```text
22-
agent model: openai-codex/gpt-5.5 (thinking=medium, reasoning=off, fast=on)
22+
agent model: openai-codex/gpt-5.5 (thinking=medium, fast=on)
2323
```
2424

2525
`thinking` comes from the default agent, model params, or global agent default;
26-
`reasoning` comes from the default agent or global reasoning default; and `fast`
27-
comes from the default agent or model `fastMode` params.
26+
when it is unset, the startup summary shows `medium`. `fast` comes from the
27+
default agent or model `fastMode` params.
2828

2929
## File-based logger
3030

src/gateway/server-startup-log.test.ts

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe("gateway startup log", () => {
4949
expect(warn).not.toHaveBeenCalled();
5050
});
5151

52-
it("logs configured model mode defaults with the startup model", () => {
52+
it("logs configured model thinking and fast mode defaults with the startup model", () => {
5353
const info = vi.fn();
5454
const warn = vi.fn();
5555

@@ -78,15 +78,50 @@ describe("gateway startup log", () => {
7878
});
7979

8080
expect(info).toHaveBeenCalledWith(
81-
"agent model: openai-codex/gpt-5.5 (thinking=medium, reasoning=stream, fast=on)",
81+
"agent model: openai-codex/gpt-5.5 (thinking=medium, fast=on)",
8282
expect.objectContaining({
8383
consoleMessage: expect.stringContaining(
84-
"agent model: openai-codex/gpt-5.5 (thinking=medium, reasoning=stream, fast=on)",
84+
"agent model: openai-codex/gpt-5.5 (thinking=medium, fast=on)",
8585
),
8686
}),
8787
);
8888
});
8989

90+
it("defaults unset startup thinking to medium", () => {
91+
expect(
92+
formatAgentModelStartupDetails({
93+
cfg: {
94+
agents: {
95+
defaults: {
96+
model: "openai-codex/gpt-5.5",
97+
},
98+
list: [{ id: "main", default: true, fastModeDefault: true }],
99+
},
100+
},
101+
provider: "openai-codex",
102+
model: "gpt-5.5",
103+
}),
104+
).toBe("thinking=medium, fast=on");
105+
});
106+
107+
it("preserves explicit startup thinking off", () => {
108+
expect(
109+
formatAgentModelStartupDetails({
110+
cfg: {
111+
agents: {
112+
defaults: {
113+
models: {
114+
"openai-codex/gpt-5.5": { params: { thinking: "off", fastMode: true } },
115+
},
116+
},
117+
},
118+
},
119+
provider: "openai-codex",
120+
model: "gpt-5.5",
121+
}),
122+
).toBe("thinking=off, fast=on");
123+
});
124+
90125
it("uses default agent mode overrides in the startup model details", () => {
91126
expect(
92127
formatAgentModelStartupDetails({
@@ -105,7 +140,7 @@ describe("gateway startup log", () => {
105140
provider: "openai",
106141
model: "gpt-5.5",
107142
}),
108-
).toBe("thinking=high, reasoning=off, fast=on");
143+
).toBe("thinking=high, fast=on");
109144
});
110145

111146
it("logs a compact listening line with loaded plugin ids and duration", () => {

src/gateway/server-startup-log.ts

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@ import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js";
44
import { resolveFastModeState } from "../agents/fast-mode.js";
55
import {
66
resolveConfiguredModelRef,
7-
resolveReasoningDefault,
87
resolveThinkingDefault,
8+
legacyModelKey,
9+
modelKey,
910
} from "../agents/model-selection.js";
1011
import type { OpenClawConfig } from "../config/types.openclaw.js";
1112
import { getResolvedLoggerSettings } from "../logging.js";
1213
import { collectEnabledInsecureOrDangerousFlags } from "../security/dangerous-config-flags.js";
1314

15+
type StartupThinkLevel =
16+
| "off"
17+
| "minimal"
18+
| "low"
19+
| "medium"
20+
| "high"
21+
| "xhigh"
22+
| "adaptive"
23+
| "max";
24+
1425
export function logGatewayStartup(params: {
1526
cfg: OpenClawConfig;
1627
bindHost: string;
@@ -57,35 +68,65 @@ export function logGatewayStartup(params: {
5768
}
5869
}
5970

71+
function normalizeStartupThinkLevel(value: unknown): StartupThinkLevel | undefined {
72+
return value === "off" ||
73+
value === "minimal" ||
74+
value === "low" ||
75+
value === "medium" ||
76+
value === "high" ||
77+
value === "xhigh" ||
78+
value === "adaptive" ||
79+
value === "max"
80+
? value
81+
: undefined;
82+
}
83+
84+
function resolveExplicitStartupThinking(params: {
85+
cfg: OpenClawConfig;
86+
provider: string;
87+
model: string;
88+
defaultAgentThinking: unknown;
89+
}): StartupThinkLevel | undefined {
90+
const models = params.cfg.agents?.defaults?.models;
91+
const canonicalKey = modelKey(params.provider, params.model);
92+
const legacyKey = legacyModelKey(params.provider, params.model);
93+
return (
94+
normalizeStartupThinkLevel(params.defaultAgentThinking) ??
95+
normalizeStartupThinkLevel(models?.[canonicalKey]?.params?.thinking) ??
96+
normalizeStartupThinkLevel(legacyKey ? models?.[legacyKey]?.params?.thinking : undefined) ??
97+
normalizeStartupThinkLevel(params.cfg.agents?.defaults?.thinkingDefault)
98+
);
99+
}
100+
60101
export function formatAgentModelStartupDetails(params: {
61102
cfg: OpenClawConfig;
62103
provider: string;
63104
model: string;
64105
}): string {
65106
const defaultAgentId = resolveDefaultAgentId(params.cfg);
66107
const defaultAgentConfig = resolveAgentConfig(params.cfg, defaultAgentId);
67-
const thinking =
68-
defaultAgentConfig?.thinkingDefault ??
108+
const explicitThinking = resolveExplicitStartupThinking({
109+
cfg: params.cfg,
110+
provider: params.provider,
111+
model: params.model,
112+
defaultAgentThinking: defaultAgentConfig?.thinkingDefault,
113+
});
114+
const resolvedThinking =
115+
explicitThinking ??
69116
resolveThinkingDefault({
70117
cfg: params.cfg,
71118
provider: params.provider,
72119
model: params.model,
73120
});
74-
const reasoning =
75-
defaultAgentConfig?.reasoningDefault ??
76-
params.cfg.agents?.defaults?.reasoningDefault ??
77-
resolveReasoningDefault({
78-
provider: params.provider,
79-
model: params.model,
80-
});
121+
const thinking = explicitThinking ?? (resolvedThinking === "off" ? "medium" : resolvedThinking);
81122
const fast = resolveFastModeState({
82123
cfg: params.cfg,
83124
provider: params.provider,
84125
model: params.model,
85126
agentId: defaultAgentId,
86127
});
87128

88-
return `thinking=${thinking}, reasoning=${reasoning}, fast=${fast.enabled ? "on" : "off"}`;
129+
return `thinking=${thinking}, fast=${fast.enabled ? "on" : "off"}`;
89130
}
90131

91132
function formatReadyDetails(

0 commit comments

Comments
 (0)