opik python_sdk.instructions.md

A set of code-review rules for Opik’s Python SDK, a library developers use to connect Python applications to Opik. It explains how the library separates its public interface, background processing, and web-service communication.

In plain words
What is it for?
Reviewing Python SDK changes involving tracing, feedback, datasets, experiments, searching, input validation, and communication with the Opik service. It also guides public API design.
Why use it?
It helps reviewers keep code in the correct part of the library and preserve the intended behavior of blocking and background operations. This makes changes easier to understand and less likely to break users of the SDK.

Instructions file for GitHub Copilot

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/comet-ml/opik/python_sdk
Clone the repo
git clone --depth 1 https://github.com/comet-ml/opik

Made for: GitHub Copilot.

Per session 8,537 This file is loaded in full into every session.
When invoked 8,537 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.08537 $0.08537
Opus 5 $0.04269 $0.04269
Sonnet 5 $0.01707 $0.01707
Haiku 4.5 $0.00854 $0.00854

Measured yesterday against content hash d330f7c68c26, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

opik python_sdk.instructions.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/instructions/python_sdk.instructions.md · 1,167 lines

How it starts

The opening of the file, as written. The whole thing — 1,167 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Opik Python SDK Code Review Guidelines

This document provides essential guidelines for reviewing Opik Python SDK code. It focuses on the most critical architectural patterns, design principles, and best practices that ensure code quality and maintainability.

🔧 Core Architecture Principles

Three-Layer Architecture

The SDK uses a strict 3-layer architecture. Always ensure code belongs to the correct layer:

Layer 1: Public API (opik.Opik, @opik.track)

  • User-facing interface, input validation, context management

Layer 2: Message Processing (observability operations only)

  • Background workers for trace/span/feedback operations

Layer 3: REST API Client

  • HTTP communication with Opik backend

Execution Paths

Asynchronous Path (traces, spans, feedback):

client.trace(name="test")           # Non-blocking, batched
client.log_traces_feedback_scores() # Background processing

Synchronous Path (datasets, experiments, search):

dataset = client.create_dataset(name="test")  # Blocking, returns immediately
traces = client.search_traces(...)           # Direct REST call

📋 API Design Standards

Opik.Opik is the Main Entry Point

# ✅ Good: Always use Opik as factory
client = opik.Opik()
experiment = client.create_experiment(name="test")
dataset = client.create_dataset(name="data")

# ❌ Bad: Direct instantiation
from opik.api_objects.experiment import Experiment
experiment = Experiment(name="test")  # Bypasses main API

Consistent Parameter Patterns

# ✅ Good: Follow established patterns
def create_experiment(self, name: str, description: Optional[str] = None)
def create_dataset(self, name: str, description: Optional[str] = None)

# ❌ Bad: Inconsistent ordering
def create_experiment(self, description: str, name: str)  # Wrong order
def create_dataset(self, name: str, desc: str)           # Different param name

Method Naming Conventions

  • CRUD: create_*, get_*, update_*, delete_*
  • Search: search_* for complex queries
  • Batch: batch_* for bulk operations

Read the full file on GitHub · 1,167 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 1,167 lines · 8,537 tokens per session scan A d330f7c68c26

Subscribe to this mod's changes

opik python_sdk.instructions.md is an instructions file published in the GitHub repository comet-ml/opik (21,685 stars, last pushed 2d ago), licensed Apache-2.0. It adds 8,537 tokens to every session, about $0.0427 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.