ue_exec_safe
Run Python code in Unreal Engine and receive a structured JSON result with errors, warnings, and logs. It wraps your snippet in automatic error handling to prevent parse failures.
Instructions
Run a Python snippet inside Unreal Engine with automatic structured error handling.
Unlike the raw exec_python, this tool:
Wraps code in a try/except that always produces valid JSON
Returns a normalised StructuredResult with success, stage, message, outputs, warnings, errors, and log_tail
Is safe to call from the AI without worrying about parse failures
Your code should populate these variables: _result : dict — key/value outputs to return to the caller _warnings : list — non-fatal warnings _errors : list — error messages (also raised via exception)
Example code: import unreal bp = unreal.load_asset('/Game/Blueprints/BP_Player') if bp: _result['class_name'] = bp.get_class().get_name() else: _errors.append('Blueprint not found')
Args: code: Python snippet to execute in Unreal Engine stage_name: Descriptive name for the operation (used in result.stage)
Returns: JSON string with StructuredResult: { "success": true, "stage": "script", "message": "Operation completed", "outputs": {...}, "warnings": [], "errors": [], "log_tail": [] }
KB: see knowledge_base/32_AGENT_PLAYABLE_SLICE_RECIPE.md#overview Example: ue_exec_safe(code="Example")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| stage_name | No | script |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |