Skip to main content

Method signature

Parameters

This method takes no parameters.

Return value

Behavior

The resume() method performs the following actions:
  1. Agent Type Validation: Verifies that the current agent is of type “codex”
  2. Initialization Check: Ensures the CodexAgent instance is properly initialized
  3. Sandbox Resumption: Calls the underlying resumeSandbox() method to resume the paused sandbox

Examples

Basic Usage

With Error Handling

State Management Pattern

Auto-Resume on Activity

Scheduled Resume

Error handling

The method throws errors in the following cases:

Agent Type Error

Initialization Error

Example Error Handling

Use Cases

Morning Startup Routine

Resume sandboxes at the start of the workday:

On-Demand Resumption

Resume only when needed to save resources:

Recovery from Breaks

Resume after planned breaks or maintenance:

State Restoration

When a sandbox is resumed, all previously saved state is restored including:
  • File system contents (exactly as they were when paused)
  • Environment variables
  • Working directory
  • Previously installed packages

Performance Considerations

Resume Time

  • Cold Resume: First resume after a long pause may take 10-30 seconds
  • Warm Resume: Subsequent resumes are typically faster (5-15 seconds)
  • State Check: The sandbox performs internal state validation during resume

Resource Usage

Notes

  • State Continuity: All sandbox state is preserved and restored exactly as it was when paused
  • Process Restoration: Running processes are resumed from their paused state
  • Network Connections: Some network connections may need to be re-established
  • File System: All files and directories remain exactly as they were
  • Best Practice: Always resume before attempting to generate new code on a paused sandbox
  • Automatic Resume: Consider implementing automatic resume logic in your application flow