Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions agentops/instrumentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ class InstrumentorConfig(TypedDict):
"class_name": "CrewaiInstrumentor",
"min_version": "0.56.0",
},
"autogen_agentchat": {
"module_name": "agentops.instrumentation.agentic.autogen",
"class_name": "AutoGenInstrumentor",
"min_version": "0.6.4",
},
"autogen": {
"module_name": "agentops.instrumentation.agentic.ag2",
"class_name": "AG2Instrumentor",
Expand Down Expand Up @@ -288,6 +293,15 @@ def _perform_instrumentation(package_name: str):
if not _should_instrument_package(package_name):
return

# If we are about to instrument the FIRST agentic library, set the flag **before** importing
# its instrumentor. This prevents re-entrancy where the agentic library imports a provider
# (e.g. ``openai``) while its own instrumentor module is still only *partially* initialised,
# which leads to the ``partially initialised module ... has no attribute`` circular-import
# error that users are seeing. We only set this once – subsequent calls will short-circuit
# in ``_should_instrument_package``.
if package_name in AGENTIC_LIBRARIES and not _has_agentic_library:
_has_agentic_library = True

# Get the appropriate configuration for the package
# Ensure package_name is a key in either PROVIDERS or AGENTIC_LIBRARIES
if package_name not in PROVIDERS and package_name not in AGENTIC_LIBRARIES:
Expand Down
65 changes: 65 additions & 0 deletions agentops/instrumentation/agentic/autogen/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""AutoGen Instrumentation Module

This module provides instrumentation for the original AutoGen framework (autogen_agentchat).
It creates create_agent spans that match the expected trace structure for AutoGen agents.

"""

from agentops.instrumentation.common import LibraryInfo

# Library information
_library_info = LibraryInfo(name="autogen_agentchat")
LIBRARY_NAME = _library_info.name
LIBRARY_VERSION = _library_info.version

# Import after defining constants to avoid circular imports
from .instrumentor import AutoGenInstrumentor # noqa: E402

# Import modular components for advanced users
from .agents import ( # noqa: E402
BaseChatAgentInstrumentor,
AssistantAgentInstrumentor,
UserProxyAgentInstrumentor,
CodeExecutorAgentInstrumentor,
SocietyOfMindAgentInstrumentor,
)
from .teams import ( # noqa: E402
RoundRobinGroupChatInstrumentor,
SelectorGroupChatInstrumentor,
SwarmInstrumentor,
)
from .utils import ( # noqa: E402
AutoGenSpanManager,
extract_agent_attributes,
safe_str,
safe_extract_content,
create_agent_span,
instrument_async_generator,
instrument_coroutine,
)

__all__ = [
# Main instrumentors
"AutoGenInstrumentor",
# Library info
"LIBRARY_NAME",
"LIBRARY_VERSION",
# Agent instrumentors
"BaseChatAgentInstrumentor",
"AssistantAgentInstrumentor",
"UserProxyAgentInstrumentor",
"CodeExecutorAgentInstrumentor",
"SocietyOfMindAgentInstrumentor",
# Team instrumentors
"RoundRobinGroupChatInstrumentor",
"SelectorGroupChatInstrumentor",
"SwarmInstrumentor",
# Utilities
"AutoGenSpanManager",
"extract_agent_attributes",
"safe_str",
"safe_extract_content",
"create_agent_span",
"instrument_async_generator",
"instrument_coroutine",
]
19 changes: 19 additions & 0 deletions agentops/instrumentation/agentic/autogen/agents/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""AutoGen agent instrumentation."""

from .common import (
CommonAgentWrappers,
BaseChatAgentInstrumentor,
AssistantAgentInstrumentor,
UserProxyAgentInstrumentor,
CodeExecutorAgentInstrumentor,
SocietyOfMindAgentInstrumentor,
)

__all__ = [
"CommonAgentWrappers",
"BaseChatAgentInstrumentor",
"AssistantAgentInstrumentor",
"UserProxyAgentInstrumentor",
"CodeExecutorAgentInstrumentor",
"SocietyOfMindAgentInstrumentor",
]
Loading
Loading