IAutomataTaskExecution

Overview

IAutomataTaskExecution is a class intended for executing general tasks. It serves as the driving mechanism for task execution, constructing a OpenAIAutomataAgent from a provided task and managing the agent’s lifecycle. This includes starting the execution of the agent, handling task failures and reattempting, and logging the status of the task.

The execute(task: Task) method is used to execute an instance of the Task class. The method performs a set of operations in an orderly manner. The task’s status is switched to RUNNING, after which an OpenAIAutomataAgent is constructed for the task and executed. If the execution finishes successfully, the task’s result is obtained, and its status is updated to SUCCESS. If an error occurs during execution, the task’s error field is updated, its status is updated to FAILED, and its retry number is incremented.

The OpenAIAutomataAgent is created using the _build_agent(task: AutomataTask) method. This agent is generated from the OpenAIAutomataAgentConfigBuilder using the task’s arguments.

Example

This example demonstrates how to create an instance of IAutomataTaskExecution and execute a task.

from automata.tasks.task_executor import IAutomataTaskExecution
from automata.tasks import AutomataTask

# create a task instance
task = AutomataTask(
    session_id="testing_session",
    kwargs={
        "instructions": "Translate the text from English to French",
        "text": "Hello world"
    }
)

# Create an instance of IAutomataTaskExecution and execute the task
task_executor = IAutomataTaskExecution()
agent = task_executor.execute(task)

Limitations

One of the known limitations of the IAutomataTaskExecution class is that it continues to attempt execution after errors. This could lead to undesired consequences in case of a persistent problem causing the task to fail repeatedly. Additionally, this class only accepts task instances of AutomataTask type. The execution fails if the task instance does not belong to this type.

Follow-up Questions:

  • How is the number of retries managed? Is there a set limit to the number of times a failed task is reattempted?

  • Is there a mechanism for intercepting and mitigating persistent errors during task execution?