Overview

Executions in Julep represent instances of tasks that have been initiated with specific inputs. They embody the lifecycle of a task, managing its progression through various states from initiation to completion. Understanding executions is crucial for effectively managing and monitoring the behavior of your AI agents and their workflows.

Components

Executions are comprised of several key components that work together to manage and monitor the state of a task:

  • Execution ID: A unique identifier for each execution instance.
  • Task ID: The identifier of the task being executed.
  • Input: The inputs provided to the task at the time of execution.
  • Status: The current state of the execution (e.g., queued, running, succeeded).
  • Output: The result produced by the execution upon completion.
  • Transitions: The sequence of state changes that the execution undergoes.

Execution Configuration options

OptionTypeDescriptionDefault
task_idstringThe ID of the task to executeRequired
inputobjectThe input to the taskRequired
metadataobjectAdditional metadata for the execution instancenull

Lifecycle of an Execution

An execution follows a well-defined lifecycle, transitioning through various states from start to finish. Understanding these states helps in monitoring and managing task executions effectively.

Execution Statuses

Executions can exist in one of the following statuses:

StatusDescription
queuedThe execution is queued and waiting to start.
startingThe execution is starting.
runningThe execution is currently running.
awaiting_inputThe execution is suspended and awaiting user input to resume.
succeededThe execution has completed successfully.
failedThe execution has failed due to an error.
cancelledThe execution has been cancelled by the user or system.

Execution State Machine

The state transitions of an execution are governed by a state machine that ensures proper progression and handling of different scenarios.

Execution State Transitions

Executions in Julep follow a specific state transition model. The transitions are governed by both the execution status and the transition type:

  • Init: The execution is initialized.
  • Start: The execution begins.
  • Step: A step within the execution is executed.
  • Wait: The execution is waiting for an external input.
  • Resume: The execution resumes after waiting.
  • Finish: The execution completes successfully.
  • Error: The execution encounters an error.
  • Cancel: The execution is cancelled.

Transition Types

Transition TypeDescription
initInitializes the execution.
startStarts the execution process.
stepExecutes a step within the task.
waitPauses execution waiting for external input.
resumeResumes execution after a wait.
finishMarks the execution as successfully completed.
errorMarks the execution as failed due to an error.
cancelCancels the execution.

Creating an Execution

To create an execution for a specific task, use the following method in the SDKs.

Check out the API reference here or SDK reference (Python here or JavaScript here for more details on different operations you can perform on executions.

Monitoring an Execution

After initiating an execution, it’s essential to monitor its progress and handle its completion or failure appropriately.

To view more details about the status of the execution and how it is transitioning between states, you can use list the transitions of an execution.

Example:

Check out the API reference here or SDK reference (Python here or JavaScript here for more details on different operations you can perform on executions.

Updating/Cancelling an Execution

To update or cancel an execution, you can use the change_status method in the SDKs.

Example:

Check out the API reference here or SDK reference (Python here or JavaScript here for more details on different operations you can perform on executions.

Best Practices

Handle All Statuses

  • 1. Execution Statuses: Ensure your application gracefully handles all possible execution statuses, including failed and cancelled.

Polling Interval

  • 1. Polling Interval: Choose an appropriate polling interval to balance responsiveness and API usage.

Logging

  • 1. Logging: Maintain detailed logs of execution statuses and outputs for auditing and debugging purposes.

Next Steps