mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-01 04:00:22 +00:00
feat(cron): add --tools flag for per-job tool allow-list (#58504)
Add toolsAllow field to cron agent-turn payloads, enabling users to restrict which tool schemas are sent to the model for a given cron job. When --tools is set: - Only listed tools are included in the provider request - promptMode is forced to 'minimal' (strips skills catalog, reply tags, heartbeat, messaging, docs, memory, model aliases, silent replies) - Dramatically reduces input tokens for small local models (~16K to ~800) CLI surface: - openclaw cron add --tools exec,read,write - openclaw cron edit <id> --tools exec - openclaw cron edit <id> --clear-tools (remove allow-list) Closes #58435 Co-authored-by: andyk-ms <andyk-ms@users.noreply.github.com>
This commit is contained in:
@@ -89,6 +89,7 @@ export function registerCronAddCommand(cron: Command) {
|
||||
.option("--model <model>", "Model override for agent jobs (provider/model or alias)")
|
||||
.option("--timeout-seconds <n>", "Timeout seconds for agent jobs")
|
||||
.option("--light-context", "Use lightweight bootstrap context for agent jobs", false)
|
||||
.option("--tools <csv>", "Comma-separated tool allow-list (e.g. exec,read,write)")
|
||||
.option("--announce", "Announce summary to a chat (subagent-style)", false)
|
||||
.option("--deliver", "Deprecated (use --announce). Announces a summary to a chat.")
|
||||
.option("--no-deliver", "Disable announce delivery and skip main-session summary")
|
||||
@@ -152,6 +153,13 @@ export function registerCronAddCommand(cron: Command) {
|
||||
timeoutSeconds:
|
||||
timeoutSeconds && Number.isFinite(timeoutSeconds) ? timeoutSeconds : undefined,
|
||||
lightContext: opts.lightContext === true ? true : undefined,
|
||||
toolsAllow:
|
||||
typeof opts.tools === "string" && opts.tools.trim()
|
||||
? opts.tools
|
||||
.split(",")
|
||||
.map((t: string) => t.trim())
|
||||
.filter(Boolean)
|
||||
: undefined,
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@ export function registerCronEditCommand(cron: Command) {
|
||||
.option("--timeout-seconds <n>", "Timeout seconds for agent jobs")
|
||||
.option("--light-context", "Enable lightweight bootstrap context for agent jobs")
|
||||
.option("--no-light-context", "Disable lightweight bootstrap context for agent jobs")
|
||||
.option("--tools <csv>", "Comma-separated tool allow-list (e.g. exec,read,write)")
|
||||
.option("--clear-tools", "Remove tool allow-list (use all tools)", false)
|
||||
.option("--announce", "Announce summary to a chat (subagent-style)")
|
||||
.option("--deliver", "Deprecated (use --announce). Announces a summary to a chat.")
|
||||
.option("--no-deliver", "Disable announce delivery")
|
||||
@@ -187,6 +189,8 @@ export function registerCronEditCommand(cron: Command) {
|
||||
Boolean(thinking) ||
|
||||
hasTimeoutSeconds ||
|
||||
typeof opts.lightContext === "boolean" ||
|
||||
typeof opts.tools === "string" ||
|
||||
opts.clearTools ||
|
||||
hasDeliveryModeFlag ||
|
||||
hasDeliveryTarget ||
|
||||
hasDeliveryAccount ||
|
||||
@@ -211,6 +215,14 @@ export function registerCronEditCommand(cron: Command) {
|
||||
opts.lightContext,
|
||||
typeof opts.lightContext === "boolean",
|
||||
);
|
||||
if (opts.clearTools) {
|
||||
payload.toolsAllow = null;
|
||||
} else if (typeof opts.tools === "string" && opts.tools.trim()) {
|
||||
payload.toolsAllow = opts.tools
|
||||
.split(",")
|
||||
.map((t: string) => t.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
patch.payload = payload;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user