This commit is contained in:
Glucksberg 2026-01-30 14:47:31 +00:00 committed by GitHub
commit 1fac95364e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 28 additions and 0 deletions

View File

@ -20,6 +20,7 @@ type ResolvedAgentConfig = {
workspace?: string;
agentDir?: string;
model?: AgentEntry["model"];
thinkingDefault?: AgentEntry["thinkingDefault"];
memorySearch?: AgentEntry["memorySearch"];
humanDelay?: AgentEntry["humanDelay"];
heartbeat?: AgentEntry["heartbeat"];
@ -103,6 +104,7 @@ export function resolveAgentConfig(
typeof entry.model === "string" || (entry.model && typeof entry.model === "object")
? entry.model
: undefined,
thinkingDefault: entry.thinkingDefault,
memorySearch: entry.memorySearch,
humanDelay: entry.humanDelay,
heartbeat: entry.heartbeat,

View File

@ -39,6 +39,7 @@ export async function applyInlineDirectiveOverrides(params: {
agentId: string;
agentDir: string;
agentCfg: AgentDefaults;
agentThinkingDefault?: ThinkLevel;
sessionEntry: SessionEntry;
sessionStore: Record<string, SessionEntry>;
sessionKey: string;
@ -74,6 +75,7 @@ export async function applyInlineDirectiveOverrides(params: {
agentId,
agentDir,
agentCfg,
agentThinkingDefault,
sessionEntry,
sessionStore,
sessionKey,
@ -147,6 +149,7 @@ export async function applyInlineDirectiveOverrides(params: {
}
const resolvedDefaultThinkLevel =
(sessionEntry?.thinkingLevel as ThinkLevel | undefined) ??
agentThinkingDefault ??
(agentCfg?.thinkingDefault as ThinkLevel | undefined) ??
(await modelState.resolveDefaultThinkingLevel());
const currentThinkLevel = resolvedDefaultThinkLevel;

View File

@ -88,6 +88,7 @@ export async function resolveReplyDirectives(params: {
agentDir: string;
workspaceDir: string;
agentCfg: AgentDefaults;
agentThinkingDefault?: ThinkLevel;
sessionCtx: TemplateContext;
sessionEntry: SessionEntry;
sessionStore: Record<string, SessionEntry>;
@ -112,6 +113,7 @@ export async function resolveReplyDirectives(params: {
cfg,
agentId,
agentCfg,
agentThinkingDefault,
agentDir,
workspaceDir,
sessionCtx,
@ -341,6 +343,7 @@ export async function resolveReplyDirectives(params: {
const resolvedThinkLevel =
(directives.thinkLevel as ThinkLevel | undefined) ??
(sessionEntry?.thinkingLevel as ThinkLevel | undefined) ??
agentThinkingDefault ??
(agentCfg?.thinkingDefault as ThinkLevel | undefined);
const resolvedVerboseLevel =
@ -411,6 +414,7 @@ export async function resolveReplyDirectives(params: {
agentId,
agentDir,
agentCfg,
agentThinkingDefault,
sessionEntry,
sessionStore,
sessionKey,

View File

@ -1,4 +1,5 @@
import {
resolveAgentConfig,
resolveAgentDir,
resolveAgentWorkspaceDir,
resolveSessionAgentId,
@ -10,6 +11,7 @@ import { type OpenClawConfig, loadConfig } from "../../config/config.js";
import { defaultRuntime } from "../../runtime.js";
import { resolveCommandAuthorization } from "../command-auth.js";
import type { MsgContext } from "../templating.js";
import type { ThinkLevel } from "../thinking.js";
import { SILENT_REPLY_TOKEN } from "../tokens.js";
import { applyMediaUnderstanding } from "../../media-understanding/apply.js";
import { applyLinkUnderstanding } from "../../link-understanding/apply.js";
@ -39,6 +41,8 @@ export async function getReplyFromConfig(
config: cfg,
});
const agentCfg = cfg.agents?.defaults;
const perAgentConfig = resolveAgentConfig(cfg, agentId);
const agentThinkingDefault = perAgentConfig?.thinkingDefault as ThinkLevel | undefined;
const sessionCfg = cfg.session;
const { defaultProvider, defaultModel, aliasIndex } = resolveDefaultModel({
cfg,
@ -148,6 +152,7 @@ export async function getReplyFromConfig(
agentDir,
workspaceDir,
agentCfg,
agentThinkingDefault,
sessionCtx,
sessionEntry,
sessionStore,

View File

@ -24,6 +24,8 @@ export type AgentConfig = {
workspace?: string;
agentDir?: string;
model?: AgentModelConfig;
/** Per-agent default thinking level (overrides agents.defaults.thinkingDefault). */
thinkingDefault?: "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
memorySearch?: MemorySearchConfig;
/** Human-like delay between block replies for this agent. */
humanDelay?: HumanDelayConfig;

View File

@ -414,6 +414,17 @@ export const AgentModelSchema = z.union([
})
.strict(),
]);
export const ThinkingDefaultSchema = z
.union([
z.literal("off"),
z.literal("minimal"),
z.literal("low"),
z.literal("medium"),
z.literal("high"),
z.literal("xhigh"),
])
.optional();
export const AgentEntrySchema = z
.object({
id: z.string(),
@ -422,6 +433,7 @@ export const AgentEntrySchema = z
workspace: z.string().optional(),
agentDir: z.string().optional(),
model: AgentModelSchema.optional(),
thinkingDefault: ThinkingDefaultSchema,
memorySearch: MemorySearchSchema,
humanDelay: HumanDelaySchema.optional(),
heartbeat: HeartbeatSchema,