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_function Decorator

  • event_type (str): Type of the event.

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

python
from agentops import record_function

@record_function('sample function being record')
def sample_function(...):
    ...

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"))