Observability for Agent Spec with Opik
Open Agent Specification is a portable configuration language for defining agentic systems (agents, tools, and structured workflows).
Agent Spec Tracing is an extension of Agent Spec that standardizes how agent and flow executions emit traces. This makes it easier to analyze what happened (LLM calls, tool calls, and intermediate steps) across different runtimes and adapters.
Account Setup
Comet provides a hosted version of the Opik platform, simply create an account and grab your API Key.
You can also run the Opik platform locally, see the installation guide for more information.
Getting Started
Installation
To use Agent Spec with Opik, install opik and pyagentspec:
If you are using the LangGraph adapter (as in the example below), install the LangGraph extra as well:
If you are using another framework, you can install the respective extra for pyagentspec, according to the
installation instructions.
Configuring Opik
Configure the Opik Python SDK for your deployment type. See the Python SDK Configuration guide for detailed instructions on:
- CLI configuration:
opik configure - Code configuration:
opik.configure() - Self-hosted vs Cloud vs Enterprise setup
- Configuration files and environment variables
Configuring your LLM provider
In order to run the example below, you will need to configure your LLM provider API keys. For this example, we’ll use OpenAI. You can find or create your API keys in these pages:
You can set them as environment variables:
Or set them programmatically:
Tracing Agent Spec workflows with Opik
Opik provides an AgentSpecInstrumentor that connects Agent Spec Tracing to Opik.
Wrap your Agent Spec runtime execution in the instrumentor context to capture traces.
Agent Spec traces often include prompts, tool inputs/outputs, and messages. If you need to avoid logging sensitive
information, set mask_sensitive_information=True.
Once you run the script and interact with your agent, you can inspect the trace tree in Opik to debug tool usage, LLM generations, and intermediate steps.
Further improvements
If you would like to see us improve this integration, simply open a new feature request on Github.