fix: Add variable substitution to code steps

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 <noreply@anthropic.com>
This commit is contained in:
rob 2025-12-07 02:59:35 -04:00
parent 9c6b682c73
commit 0c966a8adb
1 changed files with 5 additions and 2 deletions

View File

@ -67,12 +67,15 @@ def execute_code_step(step: CodeStep, variables: dict) -> tuple[dict, bool]:
Returns: Returns:
Tuple of (output_vars_dict, success) 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 # Create execution environment with variables
local_vars = dict(variables) local_vars = dict(variables)
try: try:
# Execute the code # Execute the code with substituted variables
exec(step.code, {"__builtins__": __builtins__}, local_vars) exec(code, {"__builtins__": __builtins__}, local_vars)
# Support comma-separated output vars (e.g., "a, b, c") # Support comma-separated output vars (e.g., "a, b, c")
output_vars = [v.strip() for v in step.output_var.split(',')] output_vars = [v.strip() for v in step.output_var.split(',')]