MCPcopy Create free account
hub / github.com/InternScience/InternAgent / load_resume_state

Function load_resume_state

launch_discovery.py:439–518  ·  view source on GitHub ↗

Load resume state from an existing launch folder. Args: resume_path: Path to the launch folder (e.g., results/TaskName/20260112_101127_launch) logger: Logger instance Returns: Dictionary containing: - completed_rounds: Number of completed rounds

(resume_path: str, logger)

Source from the content-addressed store, hash-verified

437# Resume State Detection
438# ============================================================================
439def load_resume_state(resume_path: str, logger) -> dict:
440 """
441 Load resume state from an existing launch folder.
442
443 Args:
444 resume_path: Path to the launch folder (e.g., results/TaskName/20260112_101127_launch)
445 logger: Logger instance
446
447 Returns:
448 Dictionary containing:
449 - completed_rounds: Number of completed rounds
450 - all_round_results: Results from completed rounds
451 - all_session_ids: Session IDs from completed rounds
452 - best_code_path: Best code path from incremental mode (if applicable)
453 - best_overall_performance: Best performance from incremental mode (if applicable)
454 - launch_id: The launch ID from the folder name
455 - config_overrides: Any config values that should be preserved
456 """
457 resume_state = {
458 'completed_rounds': 0,
459 'all_round_results': [],
460 'all_session_ids': [],
461 'best_code_path': None,
462 'best_overall_performance': None,
463 'launch_id': None,
464 'loop_mode': 'fresh',
465 'loop_rounds': 1,
466 'original_task_dir': None,
467 'base_output_dir': None,
468 'prompt_path': None
469 }
470
471 if not osp.exists(resume_path):
472 logger.error(f"Resume path does not exist: {resume_path}")
473 return resume_state
474
475 # Extract launch_id from folder name
476 resume_state['launch_id'] = osp.basename(resume_path)
477 resume_state['base_output_dir'] = osp.dirname(resume_path)
478
479 # Try to load discovery_summary.json
480 summary_path = osp.join(resume_path, "discovery_summary.json")
481 if osp.exists(summary_path):
482 try:
483 with open(summary_path, 'r') as f:
484 summary = json.load(f)
485
486 resume_state['completed_rounds'] = summary.get('total_rounds', 0)
487 resume_state['all_round_results'] = summary.get('rounds', [])
488 resume_state['all_session_ids'] = summary.get('sessions', [])
489 resume_state['loop_mode'] = summary.get('loop_mode', 'fresh')
490 resume_state['loop_rounds'] = summary.get('loop_rounds', 1)
491 resume_state['original_task_dir'] = summary.get('original_task_dir', summary.get('task_dir'))
492
493 # Load incremental mode state if available
494 if 'incremental_mode' in summary:
495 inc_state = summary['incremental_mode']
496 resume_state['best_code_path'] = inc_state.get('final_best_code_path')

Callers 1

mainFunction · 0.85

Calls 3

_scan_completed_roundsFunction · 0.85
loadMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected