From 0c966a8adbb311424e34529c41f32b9e0f2c76bc Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 7 Dec 2025 02:59:35 -0400 Subject: [PATCH] fix: Add variable substitution to code steps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code steps were executing with literal {variable} placeholders instead of substituted values. Now substitute_variables() is called on the code before execution, matching the behavior of prompt steps. This fixes issues like {outputfile} being treated as a Python set literal or written as a literal filename. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/smarttools/runner.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/smarttools/runner.py b/src/smarttools/runner.py index be80139..22f3191 100644 --- a/src/smarttools/runner.py +++ b/src/smarttools/runner.py @@ -67,12 +67,15 @@ def execute_code_step(step: CodeStep, variables: dict) -> tuple[dict, bool]: Returns: Tuple of (output_vars_dict, success) """ + # Substitute variables in code (like {outputfile} -> actual value) + code = substitute_variables(step.code, variables) + # Create execution environment with variables local_vars = dict(variables) try: - # Execute the code - exec(step.code, {"__builtins__": __builtins__}, local_vars) + # Execute the code with substituted variables + exec(code, {"__builtins__": __builtins__}, local_vars) # Support comma-separated output vars (e.g., "a, b, c") output_vars = [v.strip() for v in step.output_var.split(',')]