PauseFramework : creating an error-tolerant runtime
AI-assisted execution is here, prepare for the next generation in computing
Probably the ultimate wet dream of a game developer is a game that develops itself. I tried to make such a game using LLMs. I had a cute in-game box that said “buy a new game feature with 50 gold coins” (gold was the in-game currency). In this way the player could play forever, and more importantly, have content unique and tailored to his liking.
But pretty fast I realized that the AI just couldn’t code that well. It made a lot of errors, sometimes broke the code or format, and even when I provided it with in-game screenshots or the ability to run and play the game by itself, it didn’t perform well.
Usually what every programmer does is run the code, reach the certain block that throws an error, executes it, and changes the code. Why not delegate that to AI?
Introducing: Pause Framework, a tool for AI-assisted code execution. Let me start by saying that designing this framework is still a work in progress, I'm looking to optimize working with it.
The Core Mechanics
At its foundation, Pause Framework creates a safety net for JavaScript code execution. When code encounters a runtime error, instead of crashing, the framework intervenes with LLM assistance. Developers wrap potentially problematic code sections with the framework's pause.run() function, providing three key elements:
1. A Unique ID: For example, 'player-jump-logic' - this helps track the code block across executions
2. A Natural Language Description: Explaining what the code should accomplish
3. The JavaScript Function: The actual code to execute
Here's an implementation example:
await pause.run(
'enemy-ai-move-towards-player',
'The enemy should calculate its next move to get closer to the player',
() => {
let playerPos = getPlayerCoordinates();
let myPos = self.getCurrentPosition();
if (myPos.x < playerPos.x) {
moveRight();
}
}
);The Error Recovery Process
When an error occurs within pause.run(), the framework initiates a structured recovery process:
1. Error Interception: Catches the runtime error before it crashes the application
2. Context Collection:
- Error message and stack trace
- Original function code
- Function arguments
- The natural language description
3. LLM Consultation: Sends this context to an LLM, requesting a corrected version
4. Code Correction: Receives and attempts to execute the LLM's proposed fix
5. Persistence: If successful, saves the corrected version for future use
Example
Let's look at a practical example of how Pause Framework transforms error-prone code into more resilient execution:
Before (Traditional Implementation):
const calculatePlayerDamage = (player, enemy) => {
// This code might fail if enemy.stats is undefined
const baseDamage = player.stats.strength * 2;
const defense = enemy.stats.armor;
const finalDamage = Math.max(0, baseDamage - defense);
enemy.health -= finalDamage;
return finalDamage;
};
// Usage in game loop
try {
const damageDealt = calculatePlayerDamage(player, enemy);
console.log(`Dealt ${damageDealt} damage`);
} catch (error) {
console.error('Combat calculation failed:', error);
// Game might crash or enter invalid state
}After (With Pause Framework):
const initCombatSystem = (pause) => {
return {
calculatePlayerDamage: async (player, enemy) => {
return await pause.run(
'player-damage-calc',
'Calculate damage dealt by player to enemy based on strength and armor stats',
() => {
const baseDamage = player.stats.strength * 2;
const defense = enemy.stats.armor;
const finalDamage = Math.max(0, baseDamage - defense);
enemy.health -= finalDamage;
return finalDamage;
}
);
}
};
};
// Usage in game loop
const combat = initCombatSystem(pause);
const damageDealt = await combat.calculatePlayerDamage(player, enemy);
console.log(`Dealt ${damageDealt} damage`);If enemy.stats is undefined, instead of crashing, the framework will:
1. Catch the error
2. Provide the LLM with context about what the code should do
3. Get a corrected version that might look like:
// This code is stored inside the database after the old code fails, and will be executed on future runs inside the game
() => {
const baseDamage = player.stats?.strength ?? 1 * 2;
const defense = enemy.stats?.armor ?? 0;
const finalDamage = Math.max(0, baseDamage - defense);
enemy.health = (enemy.health ?? 100) - finalDamage;
return finalDamage;
}The corrected version adds null checks and default values, making the code more resilient to undefined properties. Once this correction proves successful, it's stored and automatically used in future executions with the same ID.
Opening up the discussion
I've made Pause Framework available on GitHub (link), inviting collaboration and discussion on this approach to error-tolerant runtime environments. While not a complete solution to the challenges of AI-generated code, it represents an experimental step toward more resilient software systems.
The framework serves as a practical exploration of how AI might contribute not just to code generation, but to the ongoing maintenance and stability of running applications. This intersection of runtime error handling and AI assistance presents interesting possibilities for the future of software development.


