agentloop-profiler 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. agentloop/__init__.py +136 -0
  2. agentloop/ablation_protocol.py +229 -0
  3. agentloop/ablations.py +564 -0
  4. agentloop/aggregate_cli.py +88 -0
  5. agentloop/aggregate_stats.py +175 -0
  6. agentloop/aggregates.py +532 -0
  7. agentloop/audit.py +39 -0
  8. agentloop/autoinstrument.py +145 -0
  9. agentloop/batch_experiments.py +295 -0
  10. agentloop/batching.py +95 -0
  11. agentloop/budget_types.py +335 -0
  12. agentloop/budgets.py +539 -0
  13. agentloop/calibration.py +872 -0
  14. agentloop/checkpoint_state.py +306 -0
  15. agentloop/checkpoint_store.py +86 -0
  16. agentloop/ci.py +202 -0
  17. agentloop/cli.py +1314 -0
  18. agentloop/client.py +228 -0
  19. agentloop/completion.py +345 -0
  20. agentloop/completion_types.py +199 -0
  21. agentloop/config.py +50 -0
  22. agentloop/context_controls.py +443 -0
  23. agentloop/context_experiments.py +337 -0
  24. agentloop/context_types.py +216 -0
  25. agentloop/costs.py +667 -0
  26. agentloop/cursor_validation.py +48 -0
  27. agentloop/decorators.py +445 -0
  28. agentloop/demo.py +300 -0
  29. agentloop/doctor.py +341 -0
  30. agentloop/drift.py +361 -0
  31. agentloop/drift_cli.py +147 -0
  32. agentloop/drift_types.py +110 -0
  33. agentloop/drift_windows.py +340 -0
  34. agentloop/entrypoint.py +201 -0
  35. agentloop/estimates.py +133 -0
  36. agentloop/events.py +75 -0
  37. agentloop/experiment_artifacts.py +80 -0
  38. agentloop/experiment_observations.py +169 -0
  39. agentloop/experiment_reports.py +545 -0
  40. agentloop/experiment_types.py +355 -0
  41. agentloop/experiments.py +392 -0
  42. agentloop/exporters.py +117 -0
  43. agentloop/finding_benchmark_types.py +131 -0
  44. agentloop/finding_benchmarks.py +424 -0
  45. agentloop/findings.py +419 -0
  46. agentloop/graph.py +464 -0
  47. agentloop/harness.py +825 -0
  48. agentloop/harness_bench/__init__.py +1 -0
  49. agentloop/harness_bench/cli.py +77 -0
  50. agentloop/harness_bench/drivers.py +96 -0
  51. agentloop/harness_bench/offline.py +507 -0
  52. agentloop/harness_evidence.py +585 -0
  53. agentloop/harness_usage.py +91 -0
  54. agentloop/html_report.py +860 -0
  55. agentloop/integrations/__init__.py +1 -0
  56. agentloop/integrations/crewai.py +144 -0
  57. agentloop/integrations/harbor/__init__.py +1 -0
  58. agentloop/integrations/harbor/atif.py +982 -0
  59. agentloop/integrations/harbor/atif_validation.py +329 -0
  60. agentloop/integrations/harbor/cli.py +207 -0
  61. agentloop/integrations/harbor/manifest.py +86 -0
  62. agentloop/integrations/harbor/trial_evidence.py +196 -0
  63. agentloop/integrations/harbor/trials.py +1109 -0
  64. agentloop/integrations/harbor/verifier.py +118 -0
  65. agentloop/integrations/langgraph.py +150 -0
  66. agentloop/integrations/langgraph_harness.py +466 -0
  67. agentloop/integrations/langgraph_recovery.py +366 -0
  68. agentloop/integrations/omnigent/__init__.py +1 -0
  69. agentloop/integrations/omnigent/cli.py +78 -0
  70. agentloop/integrations/omnigent/evidence.py +93 -0
  71. agentloop/integrations/omnigent/telemetry.py +422 -0
  72. agentloop/integrations/openai.py +415 -0
  73. agentloop/integrations/openai_agents.py +291 -0
  74. agentloop/integrations/sdk.py +82 -0
  75. agentloop/integrations/vercel_ai.py +83 -0
  76. agentloop/interoperability/__init__.py +5 -0
  77. agentloop/interoperability/artifacts.py +112 -0
  78. agentloop/interoperability/cli.py +59 -0
  79. agentloop/interoperability/cohort_evidence.py +175 -0
  80. agentloop/interoperability/cohorts.py +681 -0
  81. agentloop/interoperability/contracts.py +427 -0
  82. agentloop/interoperability/coordination.py +554 -0
  83. agentloop/interoperability/evidence.py +215 -0
  84. agentloop/interoperability/otlp_jsonl.py +775 -0
  85. agentloop/interoperability/otlp_validation.py +496 -0
  86. agentloop/interoperability/registry.py +561 -0
  87. agentloop/interoperability/validation.py +333 -0
  88. agentloop/intervention_service.py +110 -0
  89. agentloop/intervention_store.py +118 -0
  90. agentloop/interventions.py +190 -0
  91. agentloop/issues.py +90 -0
  92. agentloop/judgment_adapters.py +125 -0
  93. agentloop/judgment_benchmark_types.py +98 -0
  94. agentloop/judgment_benchmarks.py +606 -0
  95. agentloop/judgment_types.py +241 -0
  96. agentloop/judgment_views.py +38 -0
  97. agentloop/judgments.py +342 -0
  98. agentloop/loop_guards.py +274 -0
  99. agentloop/loop_types.py +66 -0
  100. agentloop/markdown.py +102 -0
  101. agentloop/metrics.py +342 -0
  102. agentloop/migrations.py +303 -0
  103. agentloop/model_routing.py +470 -0
  104. agentloop/onboarding.py +315 -0
  105. agentloop/operations.py +44 -0
  106. agentloop/optimizer.py +199 -0
  107. agentloop/otel.py +715 -0
  108. agentloop/otel_ids.py +81 -0
  109. agentloop/otel_semantics.py +134 -0
  110. agentloop/parallelism.py +141 -0
  111. agentloop/patches.py +603 -0
  112. agentloop/plan_export.py +126 -0
  113. agentloop/policy_promotion.py +325 -0
  114. agentloop/promotion_evidence.py +304 -0
  115. agentloop/promotion_types.py +209 -0
  116. agentloop/quality.py +446 -0
  117. agentloop/ranking.py +529 -0
  118. agentloop/recovery_evidence.py +96 -0
  119. agentloop/replay.py +753 -0
  120. agentloop/retention.py +375 -0
  121. agentloop/retention_types.py +113 -0
  122. agentloop/reuse_experiments.py +247 -0
  123. agentloop/routing_checks.py +116 -0
  124. agentloop/routing_types.py +241 -0
  125. agentloop/rules.py +396 -0
  126. agentloop/runtime.py +286 -0
  127. agentloop/savings.py +158 -0
  128. agentloop/scheduling_plan.py +99 -0
  129. agentloop/scheduling_types.py +169 -0
  130. agentloop/schema.py +257 -0
  131. agentloop/semantic_rules.py +200 -0
  132. agentloop/semantic_waste.py +345 -0
  133. agentloop/semantic_waste_types.py +88 -0
  134. agentloop/server.py +494 -0
  135. agentloop/store.py +1429 -0
  136. agentloop/structural_experiments.py +431 -0
  137. agentloop/structural_types.py +113 -0
  138. agentloop/structured_quality.py +1020 -0
  139. agentloop/studies.py +629 -0
  140. agentloop/study_statistics.py +58 -0
  141. agentloop/substitution_evidence.py +199 -0
  142. agentloop/substitution_export.py +190 -0
  143. agentloop/substitution_reports.py +407 -0
  144. agentloop/substitution_types.py +284 -0
  145. agentloop/substitutions.py +267 -0
  146. agentloop/timing.py +142 -0
  147. agentloop/tokens.py +188 -0
  148. agentloop/tool_scheduling.py +410 -0
  149. agentloop/trace_sources.py +31 -0
  150. agentloop/tracer.py +494 -0
  151. agentloop/value.py +306 -0
  152. agentloop/version.py +3 -0
  153. agentloop/workflow_types.py +264 -0
  154. agentloop/workflows.py +284 -0
  155. agentloop_profiler-0.1.0.dist-info/METADATA +513 -0
  156. agentloop_profiler-0.1.0.dist-info/RECORD +166 -0
  157. agentloop_profiler-0.1.0.dist-info/WHEEL +5 -0
  158. agentloop_profiler-0.1.0.dist-info/entry_points.txt +2 -0
  159. agentloop_profiler-0.1.0.dist-info/licenses/LICENSE +201 -0
  160. agentloop_profiler-0.1.0.dist-info/licenses/THIRD_PARTY_LICENSES.md +101 -0
  161. agentloop_profiler-0.1.0.dist-info/top_level.txt +2 -0
  162. dashboard/__init__.py +5 -0
  163. dashboard/app.py +922 -0
  164. dashboard/streamlit_compat.py +63 -0
  165. dashboard/trace_upload.py +57 -0
  166. dashboard/value_view.py +105 -0
@@ -0,0 +1 @@
1
+ """Optional integrations for external agent frameworks."""
@@ -0,0 +1,144 @@
1
+ from __future__ import annotations
2
+
3
+ import inspect
4
+ import time
5
+ from functools import wraps
6
+ from typing import Any
7
+
8
+ from agentloop.events import format_exception_detail, utc_now_iso
9
+ from agentloop.tracer import record_tool_call, trace_agent
10
+
11
+
12
+ def _patch_method(obj: Any, method_name: str, span_name: str, metadata: dict[str, Any]) -> bool:
13
+ method = getattr(obj, method_name, None)
14
+ if method is None or not callable(method):
15
+ return False
16
+ if getattr(method, "_agentloop_wrapped", False):
17
+ return True
18
+
19
+ if inspect.iscoroutinefunction(method):
20
+
21
+ @wraps(method)
22
+ async def async_wrapper(*args: Any, **kwargs: Any) -> Any:
23
+ started_at = utc_now_iso()
24
+ start = time.perf_counter()
25
+ status = "ok"
26
+ error = None
27
+ try:
28
+ return await method(*args, **kwargs)
29
+ except BaseException as exc: # noqa: BLE001 - record then propagate unchanged
30
+ status = "error"
31
+ error = format_exception_detail(exc)
32
+ raise
33
+ finally:
34
+ record_tool_call(
35
+ span_name,
36
+ started_at=started_at,
37
+ duration_ms=(time.perf_counter() - start) * 1000,
38
+ status=status,
39
+ error=error,
40
+ metadata=metadata,
41
+ )
42
+
43
+ async_wrapper._agentloop_wrapped = True # type: ignore[attr-defined]
44
+ setattr(obj, method_name, async_wrapper)
45
+ return True
46
+
47
+ @wraps(method)
48
+ def wrapper(*args: Any, **kwargs: Any) -> Any:
49
+ started_at = utc_now_iso()
50
+ start = time.perf_counter()
51
+ status = "ok"
52
+ error = None
53
+ try:
54
+ return method(*args, **kwargs)
55
+ except BaseException as exc: # noqa: BLE001 - record then propagate unchanged
56
+ status = "error"
57
+ error = format_exception_detail(exc)
58
+ raise
59
+ finally:
60
+ record_tool_call(
61
+ span_name,
62
+ started_at=started_at,
63
+ duration_ms=(time.perf_counter() - start) * 1000,
64
+ status=status,
65
+ error=error,
66
+ metadata=metadata,
67
+ )
68
+
69
+ wrapper._agentloop_wrapped = True # type: ignore[attr-defined]
70
+ setattr(obj, method_name, wrapper)
71
+ return True
72
+
73
+
74
+ def instrument_crew(crew: Any, *, name: str | None = None) -> Any:
75
+ """Wrap a CrewAI Crew-like object with AgentLoop tracing.
76
+
77
+ This patches `.kickoff(...)` and `.kickoff_async(...)` when present. CrewAI is
78
+ optional; the integration accepts any object with those methods.
79
+ """
80
+
81
+ run_name = name or getattr(crew, "name", None) or crew.__class__.__name__
82
+ metadata = {"integration": "crewai", "crew_name": str(run_name)}
83
+
84
+ kickoff = getattr(crew, "kickoff", None)
85
+ if (
86
+ kickoff is not None
87
+ and callable(kickoff)
88
+ and not getattr(kickoff, "_agentloop_wrapped", False)
89
+ ):
90
+
91
+ @wraps(kickoff)
92
+ def kickoff_wrapper(*args: Any, **kwargs: Any) -> Any:
93
+ with trace_agent(str(run_name), metadata=metadata):
94
+ return kickoff(*args, **kwargs)
95
+
96
+ kickoff_wrapper._agentloop_wrapped = True # type: ignore[attr-defined]
97
+ setattr(crew, "kickoff", kickoff_wrapper)
98
+
99
+ kickoff_async = getattr(crew, "kickoff_async", None)
100
+ if (
101
+ kickoff_async is not None
102
+ and callable(kickoff_async)
103
+ and not getattr(kickoff_async, "_agentloop_wrapped", False)
104
+ ):
105
+
106
+ @wraps(kickoff_async)
107
+ async def kickoff_async_wrapper(*args: Any, **kwargs: Any) -> Any:
108
+ with trace_agent(str(run_name), metadata=metadata):
109
+ return await kickoff_async(*args, **kwargs)
110
+
111
+ kickoff_async_wrapper._agentloop_wrapped = True # type: ignore[attr-defined]
112
+ setattr(crew, "kickoff_async", kickoff_async_wrapper)
113
+
114
+ return crew
115
+
116
+
117
+ def instrument_task(task: Any, *, name: str | None = None) -> Any:
118
+ """Patch common CrewAI task execution methods as tool-call spans."""
119
+
120
+ task_name = (
121
+ name
122
+ or getattr(task, "description", None)
123
+ or getattr(task, "name", None)
124
+ or task.__class__.__name__
125
+ )
126
+ metadata = {"integration": "crewai", "task_name": str(task_name)}
127
+ for method_name in ("execute", "execute_sync", "execute_async", "run"):
128
+ _patch_method(task, method_name, f"crewai.task.{method_name}", metadata)
129
+ return task
130
+
131
+
132
+ def instrument_agent(agent: Any, *, name: str | None = None) -> Any:
133
+ """Patch common CrewAI agent execution methods as tool-call spans."""
134
+
135
+ agent_name = (
136
+ name
137
+ or getattr(agent, "role", None)
138
+ or getattr(agent, "name", None)
139
+ or agent.__class__.__name__
140
+ )
141
+ metadata = {"integration": "crewai", "agent_name": str(agent_name)}
142
+ for method_name in ("execute_task", "run", "invoke"):
143
+ _patch_method(agent, method_name, f"crewai.agent.{method_name}", metadata)
144
+ return agent
@@ -0,0 +1 @@
1
+ """Read-only Harbor artifact adapters; Harbor is not a runtime dependency."""