def complete_runtime(
    runtime: Runtime,
    instance: pd.Series,
) -> 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'\n{"-" * 50} BEGIN Runtime Completion Fn {"-" * 50}\n')
    obs: CmdOutputObservation

    # Rewriting the test file to ignore any changes Agent may have made.
    script_name = f'{instance.instance_name}_test.py'
    with tempfile.TemporaryDirectory() as tmpdir:
        file_path = os.path.join(tmpdir, script_name)
        with open(file_path, 'w') as f:
            f.write(instance.test)
        runtime.copy_to(
            file_path,
            '/workspace',
        )
        logger.info(f'Running test file: {script_name}')

    action = CmdRunAction(command=f'python3 -m unittest {script_name}')
    logger.info(action, extra={'msg_type': 'ACTION'})
    obs = runtime.run_action(action)
    logger.info(obs, extra={'msg_type': 'OBSERVATION'})

    exit_code = 1
    if isinstance(obs, CmdOutputObservation):
        exit_code = obs.exit_code

    logger.info(f'\n{"-" * 50} END Runtime Completion Fn {"-" * 50}\n')

    runtime.close()

    return {
        'test_output': obs.content,
        'exit_code': exit_code,
    }
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/aider_bench/run_infer.py