fix: detect skippable steps by checking individual template vars

Previously checked if the entire resolved arg was empty, which missed
cases like patchTemplate where {{persona}} resolves to empty but the
overall JSON string is not empty. Now checks each {{param}} reference
individually — if any referenced param is empty, the step is skipped.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
zhixian
2026-02-17 23:40:07 +09:00
parent 99c505c179
commit b04b9c01b6

View File

@@ -107,13 +107,16 @@ export function resolveSteps(
if (step.action === "config_patch") {
resolved.params = params;
}
// A step is skippable if any of its template args resolved to empty string
const skippable = Object.entries(step.args).some(([key, origValue]) => {
if (typeof origValue === "string" && origValue.includes("{{")) {
const rv = resolved[key];
return typeof rv === "string" && rv.trim() === "";
}
return false;
// A step is skippable if any template variable in its args references an empty param
const skippable = Object.values(step.args).some((origValue) => {
if (typeof origValue !== "string") return false;
const matches = origValue.match(/\{\{(\w+)\}\}/g);
if (!matches) return false;
return matches.some((m) => {
const paramId = m.slice(2, -2);
const val = params[paramId];
return val !== undefined && val.trim() === "";
});
});
const actionDef = getAction(step.action);
const description = actionDef?.describe(resolved) || step.label;