To get the most out of AgentOps, it is best to carefully consider what events to record - not simply record whatever your agent is logging. AgentOps offers two ways to record events:

@record_action Decorator

  • event_type (str): Type of the event.

To make AgentOps easier to integrate, we also provide a function decorator to automatically create and record an event for your function.

python
from agentops import record_action

@record_action('sample function being recorded')
def sample_function(...):
    ...

The decorator will record the function’s parameters, return values, and the time duration. We suggest using this on functions that take a long time and contain nested functions. For example, if you decorate a function that makes several OpenAI calls, then each OpenAI call will show in the replay graph as a child of the decorated function.

@record_tool Decorator

  • tool_name (str): The name of the tool represented by the python function

Additionally, we provide a function decorator to automatically create tool events for python functions.

python
from agentops import record_tool

@record_tool('SampleToolName')
def sample_tool(...):
    ...

The decorator will record the function’s parameters, returns, and the time duration. We suggest using this on functions that take a long time and contain nested functions. For example, if you decorate a function that makes several OpenAI calls, then each OpenAI call will show in the replay graph as a child of the decorated function.

record() Method

From this point, simply call the .record() method in the AgentOps client:

Record any child of the Event type or ErrorEvent.

python
from agentops import record, ActionEvent
record(ActionEvent("event_type1"))