Python scripts

Sandboxed in-flow scripting for custom logic.

Python nodes run restricted scripts during a turn. Use them to transform variables, compute branches, or format messages when declarative nodes are not enough.

Session access

Scripts read and write session variables through the provided context object. Avoid network calls — use Tool nodes for HTTP.

Execution trace

Successful script runs appear in the simulator trace even when they produce no user-visible message, so you can confirm the step executed.

# Example: format a balance message
balance = session.get("account_balance", 0)
session["message"] = f"Your balance is {balance:.2f}"