def complete_runtime(
    runtime: Runtime,
    instance: pd.Series,  # this argument is not required, but it is used to get the workspace_dir_name
) -> dict[str, Any]:
    """Complete the runtime for the agent.

    This function is called before the runtime is used to run the agent.
    If you need to do something in the sandbox to get the correctness metric after
    the agent has run, modify this function.
    """
    logger.info(f'{"-" * 50} BEGIN Runtime Completion Fn {"-" * 50}')
    obs: CmdOutputObservation

    repo_url = instance['github']
    repo_name = repo_url.split('/')[-1]
    task_path = os.path.join('/workspace', repo_name, instance['path'][2:])

    # Evaluate the agent's script
    eval_script = os.path.join(task_path, 'run.sh')
    logger.info(f'Running evaluation script: {eval_script}')

    action = CmdRunAction(command=f'cat {eval_script}')
    logger.info(action, extra={'msg_type': 'ACTION'})
    obs = runtime.run_action(action)
    if obs.exit_code == 0:
        eval_script_content = obs.content
    else:
        logger.error(f'Error reading evaluation script: {obs.content}')
        eval_script_content = ''

    action = CmdRunAction(
        command=f'timeout 120s conda run -n {ID2CONDA[instance["github_id"]]} bash {eval_script}',
        timeout=600,
    )
    logger.info(action, extra={'msg_type': 'ACTION'})
    obs = runtime.run_action(action)
    if obs.exit_code == 0:
        eval_output = obs.content
    else:
        logger.error(f'Error running evaluation script: {obs.content}')
        eval_output = ''

    outputs = {
        'eval_script_content': eval_script_content,
        'eval_output': eval_output,
    }
    if obs.exit_code != 0 and obs.exit_code != 124:
        logger.warning(f'Evaluation script failed with exit code {obs.exit_code}')
        logger.warning(f'Output: {eval_output}')
        outputs['success'] = int(
            'KeyboardInterrupt' in eval_output
        )  # super-dainiu: assume ``KeyboardInterrupt`` is a success as is done in ML-Bench

    else:
        logger.info(f'Evaluation script succeeded with exit code {obs.exit_code}')
        logger.info(f'Output: {eval_output}')
        outputs['success'] = 1
    outputs['eval_exit_code'] = obs.exit_code

    logger.info(f'{"-" * 50} END Runtime Completion Fn {"-" * 50}')
    return outputs
Complete the runtime for the agent.

    This function is called before the runtime is used to run the agent.
    If you need to do something in the sandbox to get the correctness metric after
    the agent has run, modify this function.
    
evaluation/benchmarks/ml_bench/run_infer.py