Shared data models and interfaces for the Agent Analytics platform
The agent-analytics-common package provides standardized Pydantic-based data models and type definitions used across both the Agent Analytics SDK and backend platform. These models ensure consistency in how agent behavior, performance, and semantic information is represented throughout the observability pipeline.
This package serves as the foundation for the Agent Analytics ecosystem, defining the core interfaces for tasks, actions, metrics, issues, annotations, and other analytical artifacts.
The common package is automatically installed as a dependency when you install either the SDK or backend:
# Installed automatically with SDK
pip install "git+https://github.com/AgentToolkit/agent-analytics.git@main#subdirectory=sdk"
# Or installed automatically with backend
cd backend && npm run setupAll models are based on Pydantic for validation and serialization.
Represents a unit of work performed by an agent.
Key Classes:
Task- Base task model with timing, status, and hierarchyTaskKind- Classification of task intent (planning, retrieval, reasoning, action, etc.)TaskStatus- Execution status (success, failure, timeout, cancelled, unknown)TaskTag- Additional semantic tags (llm_call, tool_call, complex, manual, etc.)
Use Cases:
- Tracking hierarchical task decomposition
- Measuring task execution time and status
- Analyzing agent decision-making patterns
- Building task flow visualizations
Represents a concrete operation or mechanism by which work is performed.
Key Classes:
Action- Base action model with code, inputs, and outputsActionKind- Type of action mechanism (tool, llm, ml, vector_db, workflow, guardrail, human, other)ActionCode- Code metadata (language, schema, implementation body)WorkflowNodeType- Workflow node types (start, end, invoke, select, fork, join)CommandType- Action lifecycle commands (load, invoke, update, unload)
Use Cases:
- Tracking tool/API invocations
- Monitoring LLM calls and prompts
- Analyzing workflow execution paths
- Code versioning and provenance
Quantitative measurements and aggregations about agent performance.
Key Classes:
Metric- Base metric model with value, category, and typeMetricCategory- Metric classification (performance, quality, cost, security, human_in_the_loop)MetricType- Data type (numeric, distribution, string, time_series)
Use Cases:
- Performance monitoring (latency, throughput)
- Quality assessment (accuracy, hallucination rate)
- Cost tracking (token usage, API calls)
- Security metrics (guardrail triggers)
Problems, errors, or anomalies detected during agent execution.
Key Classes:
Issue- Base issue model with level, effect, and confidenceIssueLevel- Severity levels (critical, error, warning, info, debug)
Properties:
timestamp- When the issue was detectedeffect- Impact on the corresponding elementlevel- Severity classificationconfidence- Detection confidence (0-1 scale)
Use Cases:
- Error detection and tracking
- Anomaly monitoring
- Debugging failed executions
- Quality assurance
Semantic metadata describing data characteristics and context.
Key Classes:
-
DataAnnotation- Annotates input/output data with semantic meaning -
DataAnnotation.Type- Extensive enum of annotation types:Structural Classifications:
- Raw text, structured data, code snippets, multimodal data
Memory & Persistence:
- Short-term memory, long-term memory, RAG, static/dynamic data
Semantic & Functional:
- Hints, references, factual responses, analytical insights
- Creative generation, code generation, decision support
- Thought processes, explanations, summaries
Context & Provenance:
- User input, system prompt, tool output, retrieved context
- Source attribution, citations
Use Cases:
- Enriching traces with semantic context
- Tracking agent "thinking" and reasoning
- Documenting data provenance
- Supporting explainability and interpretability
Actionable suggestions for improving agent performance or behavior.
Key Classes:
Recommendation- Base recommendation model with impact level and effectsRecommendationLevel- Impact levels (critical, major, moderate, minor)
Properties:
timestamp- When the recommendation was generatedeffect- Expected benefits of implementing the recommendationlevel- Importance/priority classification
Use Cases:
- Performance optimization suggestions
- Configuration tuning recommendations
- Best practice guidance
- Automated remediation suggestions
Base class for all observable elements with common properties:
element_id- Unique identifiername- Human-readable namedescription- Detailed descriptionattributes- Key-value metadata
Extends Element with relationship tracking:
related_to_ids- Links to other elements (tasks, actions, etc.)
Workflow and execution flow representations:
Graph.Node- Nodes in execution graphsGraph.Edge- Connections between nodes
Discrete occurrences during agent execution.
External resources accessed by agents (databases, APIs, files).
Executable components within agent workflows.
Base interface for instrumentation units.
common/
├── src/
│ └── agent_analytics_common/
│ ├── __init__.py
│ └── interfaces/ # Data model definitions
│ ├── __init__.py
│ ├── action.py # Action models and enums
│ ├── annotations.py # Data annotation types
│ ├── elements.py # Base element classes
│ ├── events.py # Event models
│ ├── graph.py # Graph structures
│ ├── issues.py # Issue tracking models
│ ├── iunits.py # Instrumentation units
│ ├── metric.py # Metric definitions
│ ├── recommendations.py # Recommendation models
│ ├── relatable_element.py # Relational base class
│ ├── resources.py # Resource models
│ ├── runnable.py # Runnable interface
│ └── task.py # Task models and enums
├── setup.py # Package configuration
├── requirements.txt # Dependencies (pydantic)
└── README.md # This file
from agent_analytics_common.interfaces.task import Task, TaskKind, TaskStatus
from agent_analytics_common.interfaces.action import Action, ActionKind
from agent_analytics_common.interfaces.annotations import DataAnnotation
from agent_analytics_common.interfaces.issues import Issue, IssueLevel
from agent_analytics_common.interfaces.metric import Metric, MetricCategorytask = Task(
name="web_search",
description="Search for information using web API",
kind=TaskKind.RETRIEVAL,
status=TaskStatus.SUCCESS,
tags=[TaskTag.TOOL_CALL]
)issue = Issue(
name="timeout",
description="Search API timeout exceeded",
level=IssueLevel.WARNING,
effect=["Task delayed by 5 seconds"],
confidence=0.95
)annotation = DataAnnotation(
name="agent_thought",
annotation_type=DataAnnotation.Type.THOUGHT,
annotation_title="Reasoning Step",
annotation_content="I need to search for recent data before answering"
)- pydantic >= 2.0.0, < 3.0.0 - Data validation and serialization
- Pydantic-First: All models use Pydantic for validation, serialization, and type safety
- OpenTelemetry Alignment: Models align with OTEL semantic conventions where applicable
- Extensibility: Enums and base classes support custom extensions
- Immutability: Models are designed to be created once and remain unchanged
- Serialization: All models support JSON serialization for storage and transmission
When adding new models or extending existing ones:
- Use Pydantic
BaseModelas the foundation - Include comprehensive docstrings
- Define clear enum types for categorical fields
- Add JSON serialization methods (
from_dict,from_json,to_dict,to_json) - Maintain backward compatibility
Current version: 0.1.6
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.