A run signifies the execution of an agent or a chain that takes multiple steps. It is a sequence of Steps, that, unlike other Step types, does not have to be part of a Thread. This is useful if you are monitoring non-conversational use cases. Interact with a Run inside a Thread here.

Runs are visualized as part of Thread on the Threads page, but they can also be viewed on their own Runs page on Literal AI. Here, all Runs are visualized, not only runs that are part of Threads. Runs have a unique ID (different from the Thread ID, since Runs are different from Threads). The Steps in a Run can be scored and tagged as usual.

The example in the following image shows a Run called Query of a RAG chatbot agent, that Retrieves context documents and Generates an answer using a GPT-4 model.

An example of a Run

An example of a Run on Literal AI

In the following code example you can see that you can tag steps with the type "Run", by writing @literal_client.step(type="run") in Python or @literal_client.step(type="run") in TypeScript:

import os
from literalai import LiteralClient

literal_client = LiteralClient(api_key=os.getenv("LITERAL_API_KEY"))

# Here you can define the type of the step as run
@literal_client.step(type="run")
def my_run():
    # Implement your custom logic here
    return "Success"
    
my_run()

# Network requests by the SDK are performed asynchronously.
# Invoke flush_and_stop() to guarantee the completion of all requests prior to the process termination.
# WARNING: If you run a continuous server, you should not use this method.
client.flush_and_stop()