LogoCua
Integrations

Observability

Trace CUA execution steps and sessions

Observability

CUA has a native integration with Laminar – open-source platform for tracing, evals, and labeling of autonomous AI agents. Read more about Laminar in the Laminar docs.

Setup

Register on Laminar Cloud or spin up a local instance and get the key from your project settings. Set the LMNR_PROJECT_API_KEY environment variable to your key.

pip install lmnr[all]
export LMNR_PROJECT_API_KEY=your-key

Usage

Then, initialize Laminar at the entry point of your application, register Laminar LiteLLM callback, and all steps of CUA will be automatically traced.

import os

import litellm

from agent import ComputerAgent
from computer import Computer
from lmnr import Laminar, LaminarLiteLLMCallback 

Laminar.initialize() 
litellm.callbacks.append(LaminarLiteLLMCallback()) 

computer = Computer(
    os_type="linux",
    provider_type="cloud",
    name=os.getenv("CUA_CONTAINER_NAME"),
    api_key=os.getenv("CUA_API_KEY"),
)

agent = ComputerAgent(
    model="openai/computer-use-preview",
    tools=[computer],
)

async def main():
    async for step in agent.run("Create a new file called 'test.txt' in the current directory"):
        print(step["output"])

if __name__ == "__main__":
    asyncio.run(main())

Viewing traces

You can view traces in the Laminar UI by going to the traces tab in your project. When you select a trace, you will see all the agent execution steps, including computer actions, LLM calls, and screenshots.

For each step, you will see the LLM call, the computer action. The computer actions are highlighted in the timeline in yellow.

Example trace in Laminar showing the litellm.response span and its output.

Was this page helpful?


On this page