Call runtime.getCurrentScript().getRemainingUsage() at checkpoints in your script to monitor remaining units before expensive operations
For scheduled scripts, implement a rescue pattern: when remaining units fall below a safe threshold, save state to a custom record or script parameter and re-schedule the script to continue from that checkpoint
For map/reduce scripts, take advantage of built-in yielding — the platform automatically handles checkpointing between map, shuffle, reduce, and summarize stages, each with its own governance reset
Identify high-cost API calls (e.g. record.load, search.run) by checking the governance cost table in NetSuite documentation; batch or replace expensive calls where possible
Use search.runPaged() instead of search.run().each() for large searches to avoid exhausting governance on a single search traversal
Known gotchas
Governance unit limits differ significantly by script type: user event scripts have a much lower limit than scheduled scripts, and map/reduce stages each get their own allocation — consult the Script Type Usage Unit Limits table in Oracle's NetSuite documentation for current values, as they may be updated
The governance unit cost of an API call is fixed per call type, not per record; calling record.load 10 times costs more than loading 10 lines from a single loaded record
Deploying a script with a lower governance unit limit via the script deployment record overrides the script-type default; check deployment settings when debugging unexpected terminations
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp