惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
GbyAI
GbyAI
P
Proofpoint News Feed
B
Blog
MyScale Blog
MyScale Blog
V
V2EX
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
量子位
Jina AI
Jina AI
博客园 - 叶小钗
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
罗磊的独立博客
L
LangChain Blog
I
InfoQ
云风的 BLOG
云风的 BLOG
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
人人都是产品经理
人人都是产品经理
小众软件
小众软件
V
Visual Studio Blog
月光博客
月光博客
The Cloudflare Blog
雷峰网
雷峰网

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(gateway): expose agent thinking defaults · openclaw/o...
jbetala7 · 2026-05-31 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -4101,21 +4101,30 @@ public struct AgentSummary: Codable, Sendable {

41014101

public let workspace: String?

41024102

public let model: [String: AnyCodable]?

41034103

public let agentruntime: [String: AnyCodable]?

4104+

public let thinkinglevels: [[String: AnyCodable]]?

4105+

public let thinkingoptions: [String]?

4106+

public let thinkingdefault: String?

41044107
41054108

public init(

41064109

id: String,

41074110

name: String?,

41084111

identity: [String: AnyCodable]?,

41094112

workspace: String?,

41104113

model: [String: AnyCodable]?,

4111-

agentruntime: [String: AnyCodable]?)

4114+

agentruntime: [String: AnyCodable]?,

4115+

thinkinglevels: [[String: AnyCodable]]? = nil,

4116+

thinkingoptions: [String]? = nil,

4117+

thinkingdefault: String? = nil)

41124118

{

41134119

self.id = id

41144120

self.name = name

41154121

self.identity = identity

41164122

self.workspace = workspace

41174123

self.model = model

41184124

self.agentruntime = agentruntime

4125+

self.thinkinglevels = thinkinglevels

4126+

self.thinkingoptions = thinkingoptions

4127+

self.thinkingdefault = thinkingdefault

41194128

}

41204129
41214130

private enum CodingKeys: String, CodingKey {

@@ -4125,6 +4134,9 @@ public struct AgentSummary: Codable, Sendable {

41254134

case workspace

41264135

case model

41274136

case agentruntime = "agentRuntime"

4137+

case thinkinglevels = "thinkingLevels"

4138+

case thinkingoptions = "thinkingOptions"

4139+

case thinkingdefault = "thinkingDefault"

41284140

}

41294141

}

41304142
Original file line numberDiff line numberDiff line change

@@ -1,6 +1,7 @@

11

import { Value } from "typebox/value";

22

import { describe, expect, it } from "vitest";

33

import {

4+

AgentsListResultSchema,

45

SkillsProposalInspectResultSchema,

56

ToolsEffectiveResultSchema,

67

} from "./agents-models-skills.js";

@@ -28,6 +29,31 @@ function toolsEffectiveResult() {

2829

};

2930

}

3031
32+

describe("AgentsListResultSchema", () => {

33+

it("accepts resolved per-agent thinking metadata", () => {

34+

const result = {

35+

defaultId: "main",

36+

mainKey: "main",

37+

scope: "per-sender",

38+

agents: [

39+

{

40+

id: "investment-master",

41+

name: "Investment Master",

42+

model: { primary: "deepseek/deepseek-v4-flash" },

43+

thinkingLevels: [

44+

{ id: "off", label: "off" },

45+

{ id: "xhigh", label: "xhigh" },

46+

],

47+

thinkingOptions: ["off", "xhigh"],

48+

thinkingDefault: "xhigh",

49+

},

50+

],

51+

};

52+
53+

expect(Value.Check(AgentsListResultSchema, result)).toBe(true);

54+

});

55+

});

56+
3157

describe("ToolsEffectiveResultSchema", () => {

3258

it("accepts runtime tool quarantine notices", () => {

3359

const result = {

Original file line numberDiff line numberDiff line change

@@ -56,6 +56,19 @@ export const AgentSummarySchema = Type.Object(

5656

{ additionalProperties: false },

5757

),

5858

),

59+

thinkingLevels: Type.Optional(

60+

Type.Array(

61+

Type.Object(

62+

{

63+

id: NonEmptyString,

64+

label: NonEmptyString,

65+

},

66+

{ additionalProperties: false },

67+

),

68+

),

69+

),

70+

thinkingOptions: Type.Optional(Type.Array(NonEmptyString)),

71+

thinkingDefault: Type.Optional(NonEmptyString),

5972

},

6073

{ additionalProperties: false },

6174

);

Original file line numberDiff line numberDiff line change

@@ -77,6 +77,7 @@ const DEFAULTED_OPTIONAL_INIT_PARAM_ENTRIES: readonly [string, readonly string[]

7777

["MessageActionParams", ["inboundTurnKind"]],

7878

["CronRunLogEntry", ["errorReason", "failureNotificationDelivery"]],

7979

["ExecApprovalRequestParams", ["requireDeliveryRoute", "suppressDelivery"]],

80+

["AgentSummary", ["thinkingLevels", "thinkingOptions", "thinkingDefault"]],

8081

];

8182
8283

const DEFAULTED_OPTIONAL_INIT_PARAMS: Record<string, Set<string>> = Object.fromEntries(

Original file line numberDiff line numberDiff line change

@@ -52,7 +52,7 @@ import {

5252

isConfiguredAgent,

5353

updateAgentConfigEntry,

5454

} from "./agents-config-mutations.js";

55-

import type { GatewayRequestHandlers, RespondFn } from "./types.js";

55+

import type { GatewayRequestContext, GatewayRequestHandlers, RespondFn } from "./types.js";

5656
5757

const BOOTSTRAP_FILE_NAMES = [

5858

DEFAULT_AGENTS_FILENAME,

@@ -72,6 +72,41 @@ const agentsHandlerDeps = {

7272

isWorkspaceSetupCompleted,

7373

};

7474
75+

let loggedSlowAgentsListCatalog = false;

76+
77+

const AGENTS_LIST_MODEL_CATALOG_TIMEOUT_MS = 750;

78+
79+

async function loadOptionalAgentsListModelCatalog(

80+

context: GatewayRequestContext,

81+

): Promise<Awaited<ReturnType<GatewayRequestContext["loadGatewayModelCatalog"]>> | undefined> {

82+

let timeout: NodeJS.Timeout | undefined;

83+

const timedOut = Symbol("agents-list-model-catalog-timeout");

84+

const timeoutPromise = new Promise<typeof timedOut>((resolve) => {

85+

timeout = setTimeout(() => resolve(timedOut), AGENTS_LIST_MODEL_CATALOG_TIMEOUT_MS);

86+

timeout.unref?.();

87+

});

88+

try {

89+

const result = await Promise.race([

90+

context.loadGatewayModelCatalog().catch(() => undefined),

91+

timeoutPromise,

92+

]);

93+

if (result === timedOut) {

94+

if (!loggedSlowAgentsListCatalog) {

95+

loggedSlowAgentsListCatalog = true;

96+

context.logGateway.debug(

97+

`agents.list continuing without model catalog after ${AGENTS_LIST_MODEL_CATALOG_TIMEOUT_MS}ms`,

98+

);

99+

}

100+

return undefined;

101+

}

102+

return Array.isArray(result) ? result : undefined;

103+

} finally {

104+

if (timeout) {

105+

clearTimeout(timeout);

106+

}

107+

}

108+

}

109+
75110

export const testing = {

76111

setDepsForTests(

77112

overrides: Partial<{

@@ -451,7 +486,7 @@ async function buildIdentityMarkdownOrRespondUnsafe(params: {

451486

}

452487
453488

export const agentsHandlers: GatewayRequestHandlers = {

454-

"agents.list": ({ params, respond, context }) => {

489+

"agents.list": async ({ params, respond, context }) => {

455490

if (!validateAgentsListParams(params)) {

456491

respond(

457492

false,

@@ -465,7 +500,8 @@ export const agentsHandlers: GatewayRequestHandlers = {

465500

}

466501
467502

const cfg = context.getRuntimeConfig();

468-

const result = listAgentsForGateway(cfg);

503+

const modelCatalog = await loadOptionalAgentsListModelCatalog(context);

504+

const result = listAgentsForGateway(cfg, modelCatalog);

469505

respond(true, result, undefined);

470506

},

471507

"agents.create": async ({ params, respond, context }) => {

Original file line numberDiff line numberDiff line change

@@ -1481,6 +1481,56 @@ describe("gateway session utils", () => {

14811481

const ops = result.agents.find((agent) => agent.id === "ops");

14821482

expect(ops?.model).toEqual({ primary: "anthropic/claude-opus-4-6" });

14831483

});

1484+
1485+

test("listAgentsForGateway reports per-agent thinking defaults from the agent model", () => {

1486+

const cfg = {

1487+

session: { mainKey: "main" },

1488+

agents: {

1489+

defaults: {

1490+

model: { primary: "minimax/MiniMax-M2.7" },

1491+

thinkingDefault: "off",

1492+

},

1493+

list: [

1494+

{ id: "main", default: true },

1495+

{

1496+

id: "investment-master",

1497+

model: { primary: "deepseek/deepseek-v4-flash" },

1498+

thinkingDefault: "xhigh",

1499+

},

1500+

],

1501+

},

1502+

} as OpenClawConfig;

1503+
1504+

const result = listAgentsForGateway(cfg);

1505+

const agent = result.agents.find((row) => row.id === "investment-master");

1506+
1507+

expect(agent?.model).toEqual({ primary: "deepseek/deepseek-v4-flash" });

1508+

expect(agent?.thinkingDefault).toBe("xhigh");

1509+

expect(agent?.thinkingLevels?.map((level) => level.id)).toEqual(

1510+

expect.arrayContaining(["off", "minimal", "low", "medium", "high", "xhigh"]),

1511+

);

1512+

expect(agent?.thinkingOptions).toEqual(agent?.thinkingLevels?.map((level) => level.label));

1513+

});

1514+
1515+

test("listAgentsForGateway uses the model catalog for per-agent thinking metadata", () => {

1516+

const cfg = {

1517+

session: { mainKey: "main" },

1518+

agents: {

1519+

defaults: {

1520+

model: { primary: "local/custom-reasoner" },

1521+

},

1522+

list: [{ id: "main", default: true }],

1523+

},

1524+

} as OpenClawConfig;

1525+
1526+

const result = listAgentsForGateway(cfg, [

1527+

{ provider: "local", id: "custom-reasoner", name: "Custom Reasoner", reasoning: true },

1528+

]);

1529+

const agent = result.agents.find((row) => row.id === "main");

1530+
1531+

expect(agent?.thinkingDefault).toBe("medium");

1532+

expect(agent?.thinkingLevels?.map((level) => level.id)).toContain("medium");

1533+

});

14841534

});

14851535
14861536

describe("resolveSessionModelRef", () => {

Original file line numberDiff line numberDiff line change

@@ -1167,7 +1167,10 @@ function resolveGatewayAgentModel(

11671167

};

11681168

}

11691169
1170-

export function listAgentsForGateway(cfg: OpenClawConfig): {

1170+

export function listAgentsForGateway(

1171+

cfg: OpenClawConfig,

1172+

modelCatalog?: ModelCatalogEntry[],

1173+

): {

11711174

defaultId: string;

11721175

mainKey: string;

11731176

scope: SessionScope;

@@ -1219,6 +1222,11 @@ export function listAgentsForGateway(cfg: OpenClawConfig): {

12191222

const meta = configuredById.get(id);

12201223

const model = resolveGatewayAgentModel(cfg, id);

12211224

const resolvedModel = resolveDefaultModelForAgent({ cfg, agentId: id });

1225+

const thinkingLevels = listThinkingLevelOptions(

1226+

resolvedModel.provider,

1227+

resolvedModel.model,

1228+

modelCatalog,

1229+

);

12221230

return Object.assign(

12231231

{

12241232

id,

@@ -1233,6 +1241,15 @@ export function listAgentsForGateway(cfg: OpenClawConfig): {

12331241

sessionKey: resolveAgentMainSessionKey({ cfg, agentId: id }),

12341242

acpRuntime: false,

12351243

}),

1244+

thinkingLevels,

1245+

thinkingOptions: thinkingLevels.map((level) => level.label),

1246+

thinkingDefault: resolveGatewaySessionThinkingDefault({

1247+

cfg,

1248+

provider: resolvedModel.provider,

1249+

model: resolvedModel.model,

1250+

agentId: id,

1251+

modelCatalog,

1252+

}),

12361253

},

12371254

model ? { model } : {},

12381255

);

Original file line numberDiff line numberDiff line change

@@ -8,6 +8,7 @@ import type { PluginSessionExtensionProjection } from "../plugins/host-hooks.js"

88

import type {

99

GatewayAgentRuntime,

1010

GatewayAgentRow as SharedGatewayAgentRow,

11+

GatewayThinkingLevelOption,

1112

SessionsListResultBase,

1213

SessionsPatchResultBase,

1314

} from "../shared/session-types.js";

@@ -22,11 +23,6 @@ export type GatewaySessionsDefaults = {

2223

thinkingDefault?: string;

2324

};

2425
25-

type GatewayThinkingLevelOption = {

26-

id: string;

27-

label: string;

28-

};

29-
3026

export type SessionRunStatus = "running" | "done" | "failed" | "killed" | "timeout";

3127
3228

type SubagentRunState = "active" | "interrupted" | "historical";

Original file line numberDiff line numberDiff line change

@@ -17,13 +17,21 @@ export type GatewayAgentRuntime = {

1717

source: "env" | "agent" | "defaults" | "model" | "provider" | "implicit" | "session-key";

1818

};

1919
20+

export type GatewayThinkingLevelOption = {

21+

id: string;

22+

label: string;

23+

};

24+
2025

export type GatewayAgentRow = {

2126

id: string;

2227

name?: string;

2328

identity?: GatewayAgentIdentity;

2429

workspace?: string;

2530

model?: GatewayAgentModel;

2631

agentRuntime?: GatewayAgentRuntime;

32+

thinkingLevels?: GatewayThinkingLevelOption[];

33+

thinkingOptions?: string[];

34+

thinkingDefault?: string;

2735

};

2836
2937

export type SessionsListResultBase<TDefaults, TRow> = {

Original file line numberDiff line numberDiff line change

@@ -862,6 +862,16 @@ function resolveThinkingTargetModel(state: AppViewState): {

862862

};

863863

}

864864
865+

function sessionModelMatchesDefaults(

866+

row: SessionsListResult["sessions"][number] | undefined,

867+

defaults: SessionsListResult["defaults"] | undefined,

868+

): boolean {

869+

return (

870+

(!row?.modelProvider || row.modelProvider === defaults?.modelProvider) &&

871+

(!row?.model || row.model === defaults?.model)

872+

);

873+

}

874+
865875

function buildThinkingOptions(

866876

levels: readonly GatewayThinkingLevelOption[],

867877

currentOverride: string,

@@ -944,17 +954,22 @@ export function resolveChatThinkingSelectState(state: AppViewState): ChatThinkin

944954

typeof persisted === "string" && persisted.trim()

945955

? (normalizeThinkLevel(persisted) ?? persisted.trim())

946956

: "";

957+

const defaults = state.sessionsResult?.defaults;

947958

const { provider, model } = resolveThinkingTargetModel(state);

948959

const levels = resolveThinkingLevelOptions(

949960

activeRow,

950-

state.sessionsResult?.defaults,

961+

defaults,

951962

provider,

952963

model,

953964

state.chatModelCatalog ?? [],

954965

);

966+

const defaultFromSessionDefaults =

967+

(!activeRow || sessionModelMatchesDefaults(activeRow, defaults)) && defaults?.thinkingDefault

968+

? defaults.thinkingDefault

969+

: undefined;

955970

const defaultLevel =

956971

activeRow?.thinkingDefault ??

957-

state.sessionsResult?.defaults?.thinkingDefault ??

972+

defaultFromSessionDefaults ??

958973

(provider && model

959974

? resolveThinkingDefaultForModel({

960975

provider,