diff --git a/src/cmdforge/gui/pages/tool_builder_page.py b/src/cmdforge/gui/pages/tool_builder_page.py index 0155480..08535bd 100644 --- a/src/cmdforge/gui/pages/tool_builder_page.py +++ b/src/cmdforge/gui/pages/tool_builder_page.py @@ -558,7 +558,10 @@ class ToolBuilderPage(QWidget): def _get_step_variable_refs(self, step) -> set: """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 refs = set() @@ -567,15 +570,11 @@ class ToolBuilderPage(QWidget): pattern = r'\{(\w+)\}' if isinstance(step, PromptStep): - # Parse prompt template + # Parse prompt template - these ARE CmdForge substitutions matches = re.findall(pattern, step.prompt or "") refs.update(matches) - elif isinstance(step, CodeStep): - # Parse code for variable references - # 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) + # CodeStep: Don't parse - variables are available as Python vars directly + # and {var} syntax is typically Python string formatting return refs