Skip to main content
This page covers techniques for debugging issues with Enclave code execution.

Validation Debugging

Pre-validate Code

To see why a script is refused, run the steps of the enclave yourself: pre-scan the script as it was written, transform it, then validate the transformed code. (AgentScript allows a top-level return and await, which only parse once the script is wrapped.)
The enclave validates with its own list of allowed globals (your globals and toolNamespaces included), so a script that uses them is refused by this stand-alone validator and accepted by run(). The issues run() itself found are in result.error.data.issues.

View Transformed Code

See what the code looks like after transformation:

Runtime Debugging

Use Console Logging

A script may use console when the enclave has a consoleHandler, which receives each call as (level, message). The result has no captured output: collect the lines in the handler.
Without a consoleHandler, console is allowed only at PERMISSIVE and writes to the host process console.

Track Tool Calls

Log all tool calls in your handler:

Inspect Execution Stats

Error Debugging

Detailed Error Information

Error Code Reference

With doubleVm: { enabled: false } the code of a failing script is VM_EXECUTION_ERROR. See Error Codes.

Scoring Gate Debugging

Log Score Details

Test Scoring Separately

The gate of an enclave scores the transformed script and knows the enclave’s tool namespaces; a gate you create yourself sees callTool calls only, unless you pass it toolNamespaces.

Performance Debugging

Measure Tool Call Latency

Profile Memory Usage

Testing Scripts

Create a Test Harness