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:
parent
9c6b682c73
commit
0c966a8adb
|
|
@ -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(',')]
|
||||
|
|
|
|||
Loading…
Reference in New Issue