def METHOD_NAME(test_handler, mocker):
    # Arrange
    iteration_workflow = IterationWorkflow(has_task_queue=True)
    agent_config = {'constraints': 'Test constraint'}
    agent_execution_config = {'goal': 'Test goal', 'instruction': 'Test instruction'}
    prompt = 'Test prompt'
    task_queue = TaskQueue(queue_name='Test queue')
    agent_tools = []
    mocker.patch.object(AgentPromptBuilder, 'replace_main_variables', return_value='Test prompt')
    mocker.patch.object(AgentPromptBuilder, 'replace_task_based_variables', return_value='Test prompt')
    mocker.patch.object(task_queue, 'get_last_task_details', return_value={"task": "last task", "response": "last response"})
    mocker.patch.object(task_queue, 'get_first_task', return_value='Test task')
    mocker.patch.object(task_queue, 'get_tasks', return_value=[])
    mocker.patch.object(task_queue, 'get_completed_tasks', return_value=[])
    mocker.patch.object(TokenCounter, 'token_limit', return_value=1000)
    mocker.patch('superagi.agent.agent_iteration_step_handler.get_config', return_value=600)
    # Act
    test_handler.task_queue = task_queue
    result_prompt = test_handler._build_agent_prompt(iteration_workflow, agent_config, agent_execution_config,
                                                     prompt, agent_tools)
    # Assert
    assert result_prompt == 'Test prompt'
    AgentPromptBuilder.replace_main_variables.assert_called_once_with(prompt, agent_execution_config["goal"],
                                                                      agent_execution_config["instruction"],
                                                                      agent_config["constraints"], agent_tools, False)
    AgentPromptBuilder.replace_task_based_variables.assert_called_once()
    task_queue.get_last_task_details.assert_called_once()
    task_queue.get_first_task.assert_called_once()
    task_queue.get_tasks.assert_called_once()
    task_queue.get_completed_tasks.assert_called_once()
    TokenCounter.token_limit.assert_called_once()