Fix false positives in variable dependency validation
Only parse {variable} patterns in PromptSteps, not CodeSteps.
In CodeSteps, variables are available directly as Python variables
(e.g., use `input` not `{input}`). The {var} syntax in code is
typically Python f-string or .format() syntax, not CmdForge
template substitution.
This fixes false positives like artifact-ai where Python f-strings
like f"{format_guide}" were incorrectly flagged as missing CmdForge
variable references.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
b8760eb208
commit
260ebf1b2f
|
|
@ -558,7 +558,10 @@ class ToolBuilderPage(QWidget):
|
||||||
def _get_step_variable_refs(self, step) -> set:
|
def _get_step_variable_refs(self, step) -> set:
|
||||||
"""Extract variable references from a step.
|
"""Extract variable references from a step.
|
||||||
|
|
||||||
Parses {variable} patterns from prompt templates and code.
|
Parses {variable} patterns from prompt templates.
|
||||||
|
Note: CodeSteps are NOT parsed because variables are available directly
|
||||||
|
as Python variables, and {var} in code is typically Python f-string
|
||||||
|
or .format() syntax, not CmdForge substitution.
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
refs = set()
|
refs = set()
|
||||||
|
|
@ -567,15 +570,11 @@ class ToolBuilderPage(QWidget):
|
||||||
pattern = r'\{(\w+)\}'
|
pattern = r'\{(\w+)\}'
|
||||||
|
|
||||||
if isinstance(step, PromptStep):
|
if isinstance(step, PromptStep):
|
||||||
# Parse prompt template
|
# Parse prompt template - these ARE CmdForge substitutions
|
||||||
matches = re.findall(pattern, step.prompt or "")
|
matches = re.findall(pattern, step.prompt or "")
|
||||||
refs.update(matches)
|
refs.update(matches)
|
||||||
elif isinstance(step, CodeStep):
|
# CodeStep: Don't parse - variables are available as Python vars directly
|
||||||
# Parse code for variable references
|
# and {var} syntax is typically Python string formatting
|
||||||
# In code, variables are accessed directly, but we also check for {var} patterns
|
|
||||||
# since the code might use string formatting
|
|
||||||
matches = re.findall(pattern, step.code or "")
|
|
||||||
refs.update(matches)
|
|
||||||
|
|
||||||
return refs
|
return refs
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue