Adding Tags

You can add tags when initializing AgentOps, whicreh is the most common approach:

import agentops

# Initialize AgentOps with tags
agentops.init(
    api_key="YOUR_API_KEY",
    default_tags=["production", "customer-service", "gpt-4"]
)

Alternatively, when using manual trace creation:

# Initialize without auto-starting a session
agentops.init(api_key="YOUR_API_KEY", auto_start_session=False)

# Later start a trace with specific tags (modern approach)
trace = agentops.start_trace(trace_name="test_workflow", default_tags=["development", "testing", "claude-3"])

Legacy approach using agentops.start_session(default_tags=["development", "testing", "claude-3"]) is deprecated and will be removed in v4.0. Use agentops.start_trace() instead.

Tag Use Cases

Tags can be used for various purposes:

Environment Identification

Tag sessions based on their environment:

default_tags=["production"] # or ["development", "staging", "testing"]

Feature Tracking

Tag sessions related to specific features or components:

default_tags=["search-functionality", "user-authentication", "content-generation"]

User Segmentation

Tag sessions based on user characteristics:

default_tags=["premium-user", "new-user", "enterprise-customer"]

Experiment Tracking

Tag sessions as part of specific experiments:

default_tags=["experiment-123", "control-group", "variant-A"]

Model Identification

Tag sessions with the models being used:

default_tags=["gpt-4", "claude-3-opus", "mistral-large"]

Viewing Tagged Sessions

In the AgentOps dashboard:

  1. Use the tag filter to select specific tags
  2. Combine multiple tags to refine your view
  3. Save filtered views for quick access

Best Practices

  • Use a consistent naming convention for tags
  • Include both broad categories and specific identifiers
  • Avoid using too many tags per session (3-5 is typically sufficient)
  • Consider using hierarchical tag structures (e.g., “env:production”, “model:gpt-4”)
  • Update your tagging strategy as your application evolves