-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdebug_telemetry_double.py
More file actions
69 lines (57 loc) · 2.06 KB
/
debug_telemetry_double.py
File metadata and controls
69 lines (57 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
"""
Debug double-counting in telemetry.
"""
from praisonaiagents import Agent, Task, PraisonAIAgents
from praisonaiagents.telemetry import get_telemetry
# Get telemetry instance
telemetry = get_telemetry()
# Clear any existing metrics by flushing
telemetry.flush()
print("Starting fresh telemetry tracking...\n")
# Create ONE agent
print("Creating 1 agent...")
agent = Agent(
name="SingleAgent",
role="Test Role",
goal="Test Goal",
instructions="Test instructions"
)
# Create ONE task
print("Creating 1 task...")
task = Task(
description="Single test task",
expected_output="Test output",
agent=agent
)
# Create workflow with ONE agent and ONE task
print("Creating workflow with 1 agent and 1 task...")
workflow = PraisonAIAgents(
agents=[agent],
tasks=[task],
process="sequential"
)
# Check metrics before running
metrics_before = telemetry.get_metrics()
print(f"\nMetrics BEFORE running workflow:")
print(f" Agent executions: {metrics_before['metrics']['agent_executions']}")
print(f" Task completions: {metrics_before['metrics']['task_completions']}")
# Run the workflow
print("\nRunning workflow...")
result = workflow.start()
# Check metrics after running
metrics_after = telemetry.get_metrics()
print(f"\nMetrics AFTER running workflow:")
print(f" Agent executions: {metrics_after['metrics']['agent_executions']} (expected: 1)")
print(f" Task completions: {metrics_after['metrics']['task_completions']} (expected: 1)")
if metrics_after['metrics']['agent_executions'] > 1:
print("\n❌ ISSUE: Agent executions are being double-counted!")
print(" Possible causes:")
print(" - Agent method is being called multiple times")
print(" - Instrumentation is being applied twice")
print(" - Multiple tracking calls for same execution")
if metrics_after['metrics']['task_completions'] > 1:
print("\n❌ ISSUE: Task completions are being double-counted!")
print(" Possible causes:")
print(" - Task completion is tracked in multiple places")
print(" - Instrumentation is being applied twice")