Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e663375
base instrumentation
fenilfaldu Jun 5, 2025
7273c4d
Refactored Agno instrumentation
fenilfaldu Jun 6, 2025
7939516
Merge branch 'main' into agno_instrumentation
fenilfaldu Jun 6, 2025
7c1865d
Merge branch 'main' into agno_instrumentation
Dwij1704 Jun 6, 2025
dd280a9
Merge branch 'main' into agno_instrumentation
fenilfaldu Jun 6, 2025
4799bdb
Merge branch 'main' into agno_instrumentation
fenilfaldu Jun 7, 2025
52b4fef
Merge branch 'main' into agno_instrumentation
fenilfaldu Jun 8, 2025
1731771
Code refactored
fenilfaldu Jun 8, 2025
b265aa3
Merge branch 'agno_instrumentation' of https://github.com/AgentOps-AI…
fenilfaldu Jun 8, 2025
03fc4cd
Merge branch 'main' into agno_instrumentation
fenilfaldu Jun 10, 2025
d20e161
Merge branch 'main' into agno_instrumentation
fenilfaldu Jun 10, 2025
f0ca16d
added v2 docs
fenilfaldu Jun 11, 2025
b9ff529
ruff checks
fenilfaldu Jun 11, 2025
0e49ad5
Merge branch 'main' into agno_instrumentation
fenilfaldu Jun 11, 2025
c1a7337
Merge branch 'main' into agno_instrumentation
dot-agi Jun 11, 2025
eca4d70
added docs
fenilfaldu Jun 11, 2025
83db674
Merge branch 'main' into agno_instrumentation
dot-agi Jun 11, 2025
5e25523
enhanced docs :)
fenilfaldu Jun 12, 2025
1d987b4
Merge branch 'main' into agno_instrumentation
fenilfaldu Jun 12, 2025
2a7f5fa
v2 docs updated
fenilfaldu Jun 12, 2025
c51303d
ruff checks
fenilfaldu Jun 12, 2025
ef6110d
some work for @fenilfaldu to follow
dot-agi Jun 12, 2025
650f9dd
docs final update
fenilfaldu Jun 12, 2025
65ba493
Delete examples/agno/agno_comprehensive_tutorial.py
fenilfaldu Jun 12, 2025
fc63f09
Delete examples/agno/agno_comprehensive_tutorial.ipynb
fenilfaldu Jun 12, 2025
91d6113
import agentops before library import
dot-agi Jun 12, 2025
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
5 changes: 5 additions & 0 deletions agentops/instrumentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ class InstrumentorConfig(TypedDict):
"min_version": "0.1.0",
"package_name": "google-adk", # Actual pip package name
},
"agno": {
"module_name": "agentops.instrumentation.agno",
"class_name": "AgnoInstrumentor",
"min_version": "0.1.0",
},
}

# Combine all target packages for monitoring
Expand Down
18 changes: 18 additions & 0 deletions agentops/instrumentation/agno/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Agno Agent instrumentation package."""

import logging

Check warning on line 3 in agentops/instrumentation/agno/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/__init__.py#L3

Added line #L3 was not covered by tests

from .instrumentor import AgnoInstrumentor

Check warning on line 5 in agentops/instrumentation/agno/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/__init__.py#L5

Added line #L5 was not covered by tests

logger = logging.getLogger(__name__)

Check warning on line 7 in agentops/instrumentation/agno/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/__init__.py#L7

Added line #L7 was not covered by tests

__version__ = "1.0.0"

Check warning on line 9 in agentops/instrumentation/agno/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/__init__.py#L9

Added line #L9 was not covered by tests

LIBRARY_NAME = "agno"
LIBRARY_VERSION = __version__

Check warning on line 12 in agentops/instrumentation/agno/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/__init__.py#L11-L12

Added lines #L11 - L12 were not covered by tests

__all__ = [

Check warning on line 14 in agentops/instrumentation/agno/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/__init__.py#L14

Added line #L14 was not covered by tests
"AgnoInstrumentor",
"LIBRARY_NAME",
"LIBRARY_VERSION",
]
14 changes: 14 additions & 0 deletions agentops/instrumentation/agno/attributes/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Agno Agent attributes package for span instrumentation."""

from .agent import get_agent_run_attributes
from .team import get_team_run_attributes
from .tool import get_tool_execution_attributes
from .workflow import get_workflow_run_attributes, get_workflow_session_attributes

Check warning on line 6 in agentops/instrumentation/agno/attributes/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/__init__.py#L3-L6

Added lines #L3 - L6 were not covered by tests

__all__ = [

Check warning on line 8 in agentops/instrumentation/agno/attributes/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/__init__.py#L8

Added line #L8 was not covered by tests
"get_agent_run_attributes",
"get_team_run_attributes",
"get_tool_execution_attributes",
"get_workflow_run_attributes",
"get_workflow_session_attributes",
]
290 changes: 290 additions & 0 deletions agentops/instrumentation/agno/attributes/agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
"""Agno Agent run attributes handler."""

from typing import Optional, Tuple, Dict, Any

Check warning on line 3 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L3

Added line #L3 was not covered by tests

from agentops.instrumentation.common.attributes import AttributeMap
from agentops.semconv import SpanAttributes, WorkflowAttributes, AgentAttributes, ToolAttributes
from agentops.semconv.span_kinds import SpanKind as AgentOpsSpanKind

Check warning on line 7 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L5-L7

Added lines #L5 - L7 were not covered by tests


def get_agent_run_attributes(

Check warning on line 10 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L10

Added line #L10 was not covered by tests
args: Optional[Tuple] = None,
kwargs: Optional[Dict] = None,
return_value: Optional[Any] = None,
) -> AttributeMap:
"""Extract span attributes for Agent.run/arun calls.

Args:
args: Positional arguments passed to the run method (self, message, ...)
kwargs: Keyword arguments passed to the run method
return_value: The return value from the run method (RunResponse)

Returns:
A dictionary of span attributes to be set on the agent span
"""
attributes: AttributeMap = {}

Check warning on line 25 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L25

Added line #L25 was not covered by tests

# Initialize variables to avoid UnboundLocalError
agent_name = None

Check warning on line 28 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L28

Added line #L28 was not covered by tests

# Base attributes
attributes[SpanAttributes.AGENTOPS_SPAN_KIND] = AgentOpsSpanKind.WORKFLOW
attributes[SpanAttributes.LLM_SYSTEM] = "agno"
attributes[SpanAttributes.LLM_REQUEST_STREAMING] = "False"

Check warning on line 33 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L31-L33

Added lines #L31 - L33 were not covered by tests

# AgentOps entity attributes (matching CrewAI pattern)
attributes[SpanAttributes.AGENTOPS_ENTITY_NAME] = "Agent"

Check warning on line 36 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L36

Added line #L36 was not covered by tests

# Extract agent information from args[0] (self)
if args and len(args) >= 1:
agent = args[0]

Check warning on line 40 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L39-L40

Added lines #L39 - L40 were not covered by tests

# Core agent identification using AgentAttributes
if hasattr(agent, "agent_id") and agent.agent_id:
agent_id = str(agent.agent_id)
attributes[AgentAttributes.AGENT_ID] = agent_id
attributes["agno.agent.id"] = agent_id

Check warning on line 46 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L43-L46

Added lines #L43 - L46 were not covered by tests

if hasattr(agent, "name") and agent.name:
agent_name = str(agent.name)
attributes[AgentAttributes.AGENT_NAME] = agent_name
attributes["agno.agent.name"] = agent_name

Check warning on line 51 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L48-L51

Added lines #L48 - L51 were not covered by tests

if hasattr(agent, "role") and agent.role:
agent_role = str(agent.role)
attributes[AgentAttributes.AGENT_ROLE] = agent_role
attributes["agno.agent.role"] = agent_role

Check warning on line 56 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L53-L56

Added lines #L53 - L56 were not covered by tests

# Check if agent is part of a team
if hasattr(agent, "_team") and agent._team:
team = agent._team
if hasattr(team, "name") and team.name:
attributes["agno.agent.parent_team"] = str(team.name)
attributes["agno.agent.parent_team_display"] = f"Under {team.name}"
if hasattr(team, "team_id") and team.team_id:
attributes["agno.agent.parent_team_id"] = str(team.team_id)

Check warning on line 65 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L59-L65

Added lines #L59 - L65 were not covered by tests

# Model information using AgentAttributes
if hasattr(agent, "model") and agent.model:
model = agent.model
if hasattr(model, "id"):
model_id = str(model.id)
attributes[AgentAttributes.AGENT_MODELS] = model_id
attributes["agno.agent.model_id"] = model_id
attributes[SpanAttributes.LLM_RESPONSE_MODEL] = model_id

Check warning on line 74 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L68-L74

Added lines #L68 - L74 were not covered by tests

if hasattr(model, "provider"):
model_provider = str(model.provider)
attributes["agno.agent.model_provider"] = model_provider
attributes[SpanAttributes.LLM_REQUEST_MODEL] = model_id if hasattr(model, "id") else "unknown"

Check warning on line 79 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L76-L79

Added lines #L76 - L79 were not covered by tests

# Agent configuration details
agent_config = {}

Check warning on line 82 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L82

Added line #L82 was not covered by tests

if hasattr(agent, "description") and agent.description:
agent_config["description"] = str(agent.description)[:500] # Limit length

Check warning on line 85 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L84-L85

Added lines #L84 - L85 were not covered by tests

if hasattr(agent, "goal") and agent.goal:
agent_config["goal"] = str(agent.goal)[:500] # Limit length

Check warning on line 88 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L87-L88

Added lines #L87 - L88 were not covered by tests

if hasattr(agent, "instructions") and agent.instructions:
if isinstance(agent.instructions, list):
agent_config["instructions"] = " | ".join(str(i) for i in agent.instructions[:3]) # First 3

Check warning on line 92 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L90-L92

Added lines #L90 - L92 were not covered by tests
else:
agent_config["instructions"] = str(agent.instructions)[:500]

Check warning on line 94 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L94

Added line #L94 was not covered by tests

if hasattr(agent, "expected_output") and agent.expected_output:
agent_config["expected_output"] = str(agent.expected_output)[:300]

Check warning on line 97 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L96-L97

Added lines #L96 - L97 were not covered by tests

if hasattr(agent, "markdown"):
agent_config["markdown"] = str(agent.markdown)

Check warning on line 100 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L99-L100

Added lines #L99 - L100 were not covered by tests

if hasattr(agent, "reasoning"):
agent_config["reasoning"] = str(agent.reasoning)

Check warning on line 103 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L102-L103

Added lines #L102 - L103 were not covered by tests

if hasattr(agent, "stream"):
agent_config["stream"] = str(agent.stream)

Check warning on line 106 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L105-L106

Added lines #L105 - L106 were not covered by tests

if hasattr(agent, "retries"):
agent_config["max_retry_limit"] = str(agent.retries)

Check warning on line 109 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L108-L109

Added lines #L108 - L109 were not covered by tests

if hasattr(agent, "response_model") and agent.response_model:
agent_config[SpanAttributes.LLM_RESPONSE_MODEL] = str(agent.response_model.__name__)

Check warning on line 112 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L111-L112

Added lines #L111 - L112 were not covered by tests

if hasattr(agent, "show_tool_calls"):
agent_config["show_tool_calls"] = str(agent.show_tool_calls)

Check warning on line 115 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L114-L115

Added lines #L114 - L115 were not covered by tests

if hasattr(agent, "tool_call_limit") and agent.tool_call_limit:
agent_config["tool_call_limit"] = str(agent.tool_call_limit)

Check warning on line 118 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L117-L118

Added lines #L117 - L118 were not covered by tests

# Add agent config to attributes
for key, value in agent_config.items():
attributes[f"agno.agent.{key}"] = value

Check warning on line 122 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L121-L122

Added lines #L121 - L122 were not covered by tests

# Tools information
if hasattr(agent, "tools") and agent.tools:
tools_info = []
tool_names = []

Check warning on line 127 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L125-L127

Added lines #L125 - L127 were not covered by tests

for tool in agent.tools:
tool_dict = {}

Check warning on line 130 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L129-L130

Added lines #L129 - L130 were not covered by tests

if hasattr(tool, "name"):
tool_name = str(tool.name)
tool_dict["name"] = tool_name
tool_names.append(tool_name)
elif hasattr(tool, "__name__"):
tool_name = str(tool.__name__)
tool_dict["name"] = tool_name
tool_names.append(tool_name)
elif callable(tool):
tool_name = getattr(tool, "__name__", "unknown_tool")
tool_dict["name"] = tool_name
tool_names.append(tool_name)

Check warning on line 143 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L132-L143

Added lines #L132 - L143 were not covered by tests

if hasattr(tool, "description"):
description = str(tool.description)
if len(description) > 200:
description = description[:197] + "..."
tool_dict["description"] = description

Check warning on line 149 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L145-L149

Added lines #L145 - L149 were not covered by tests

if tool_dict: # Only add if we have some info
tools_info.append(tool_dict)

Check warning on line 152 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L151-L152

Added lines #L151 - L152 were not covered by tests

# Set tool attributes
if tool_names:
attributes["agno.agent.tools_count"] = str(len(tool_names))

Check warning on line 156 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L155-L156

Added lines #L155 - L156 were not covered by tests

if tools_info:

Check warning on line 158 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L158

Added line #L158 was not covered by tests
# Instead of storing as JSON blob, set individual tool attributes
for i, tool in enumerate(tools_info):
prefix = f"agent.tool.{i}"
if "name" in tool:
attributes[f"{prefix}.{ToolAttributes.TOOL_NAME}"] = tool["name"]
if "description" in tool:
attributes[f"{prefix}.{ToolAttributes.TOOL_DESCRIPTION}"] = tool["description"]

Check warning on line 165 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L160-L165

Added lines #L160 - L165 were not covered by tests

# Memory and knowledge information
if hasattr(agent, "memory") and agent.memory:
memory_type = type(agent.memory).__name__
attributes["agno.agent.memory_type"] = memory_type

Check warning on line 170 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L168-L170

Added lines #L168 - L170 were not covered by tests

if hasattr(agent, "knowledge") and agent.knowledge:
knowledge_type = type(agent.knowledge).__name__
attributes["agno.agent.knowledge_type"] = knowledge_type

Check warning on line 174 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L172-L174

Added lines #L172 - L174 were not covered by tests

if hasattr(agent, "storage") and agent.storage:
storage_type = type(agent.storage).__name__
attributes["agno.agent.storage_type"] = storage_type

Check warning on line 178 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L176-L178

Added lines #L176 - L178 were not covered by tests

# Session information
if hasattr(agent, "session_id") and agent.session_id:
session_id = str(agent.session_id)
attributes["agno.agent.session_id"] = session_id

Check warning on line 183 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L181-L183

Added lines #L181 - L183 were not covered by tests

if hasattr(agent, "user_id") and agent.user_id:
user_id = str(agent.user_id)
attributes["agno.agent.user_id"] = user_id

Check warning on line 187 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L185-L187

Added lines #L185 - L187 were not covered by tests

# Extract run input information
if args and len(args) >= 2:
message = args[1] # The message argument
if message:
message_str = str(message)
if len(message_str) > 500:
message_str = message_str[:497] + "..."
attributes[WorkflowAttributes.WORKFLOW_INPUT] = message_str
attributes["agno.agent.input"] = message_str

Check warning on line 197 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L190-L197

Added lines #L190 - L197 were not covered by tests
# AgentOps entity input (matching CrewAI pattern)
attributes[SpanAttributes.AGENTOPS_ENTITY_INPUT] = message_str

Check warning on line 199 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L199

Added line #L199 was not covered by tests

# Extract kwargs information
if kwargs:
if kwargs.get("stream") is not None:
attributes[SpanAttributes.LLM_REQUEST_STREAMING] = str(kwargs["stream"])

Check warning on line 204 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L202-L204

Added lines #L202 - L204 were not covered by tests

if kwargs.get("session_id"):
attributes["agno.agent.run_session_id"] = str(kwargs["session_id"])

Check warning on line 207 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L206-L207

Added lines #L206 - L207 were not covered by tests

if kwargs.get("user_id"):
attributes["agno.agent.run_user_id"] = str(kwargs["user_id"])

Check warning on line 210 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L209-L210

Added lines #L209 - L210 were not covered by tests

# Extract return value information
if return_value:
if hasattr(return_value, "run_id") and return_value.run_id:
run_id = str(return_value.run_id)
attributes["agno.agent.run_id"] = run_id

Check warning on line 216 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L213-L216

Added lines #L213 - L216 were not covered by tests

if hasattr(return_value, "session_id") and return_value.session_id:
session_id = str(return_value.session_id)
attributes["agno.agent.response_session_id"] = session_id

Check warning on line 220 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L218-L220

Added lines #L218 - L220 were not covered by tests

if hasattr(return_value, "agent_id") and return_value.agent_id:
agent_id = str(return_value.agent_id)
attributes["agno.agent.response_agent_id"] = agent_id

Check warning on line 224 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L222-L224

Added lines #L222 - L224 were not covered by tests

if hasattr(return_value, "content") and return_value.content:
content = str(return_value.content)
if len(content) > 500:
content = content[:497] + "..."
attributes[WorkflowAttributes.WORKFLOW_OUTPUT] = content
attributes["agno.agent.output"] = content

Check warning on line 231 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L226-L231

Added lines #L226 - L231 were not covered by tests

if hasattr(return_value, "event") and return_value.event:
event = str(return_value.event)
attributes["agno.agent.event"] = event

Check warning on line 235 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L233-L235

Added lines #L233 - L235 were not covered by tests

# Tool executions from the response
if hasattr(return_value, "tools") and return_value.tools:
tool_executions = []
for tool_exec in return_value.tools:
tool_exec_dict = {}

Check warning on line 241 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L238-L241

Added lines #L238 - L241 were not covered by tests

if hasattr(tool_exec, "tool_name") and tool_exec.tool_name:
tool_exec_dict["name"] = str(tool_exec.tool_name)

Check warning on line 244 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L243-L244

Added lines #L243 - L244 were not covered by tests

if hasattr(tool_exec, "tool_args") and tool_exec.tool_args:
try:
import json

Check warning on line 248 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L246-L248

Added lines #L246 - L248 were not covered by tests

args_str = json.dumps(tool_exec.tool_args)
if len(args_str) > 200:
args_str = args_str[:197] + "..."
tool_exec_dict["parameters"] = args_str
except:
tool_exec_dict["parameters"] = str(tool_exec.tool_args)

Check warning on line 255 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L250-L255

Added lines #L250 - L255 were not covered by tests

if hasattr(tool_exec, "result") and tool_exec.result:
result_str = str(tool_exec.result)
if len(result_str) > 200:
result_str = result_str[:197] + "..."
tool_exec_dict["result"] = result_str

Check warning on line 261 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L257-L261

Added lines #L257 - L261 were not covered by tests

if hasattr(tool_exec, "tool_call_error") and tool_exec.tool_call_error:
tool_exec_dict["error"] = str(tool_exec.tool_call_error)

Check warning on line 264 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L263-L264

Added lines #L263 - L264 were not covered by tests

tool_exec_dict["status"] = "success" # Default to success

Check warning on line 266 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L266

Added line #L266 was not covered by tests

if tool_exec_dict:
tool_executions.append(tool_exec_dict)

Check warning on line 269 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L268-L269

Added lines #L268 - L269 were not covered by tests

if tool_executions:

Check warning on line 271 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L271

Added line #L271 was not covered by tests
# Add tool executions (limit to first 3)
limited_executions = tool_executions[:3]
for i, tool_exec in enumerate(limited_executions):
for key, value in tool_exec.items():
attributes[f"agno.agent.tool_execution.{i}.{key}"] = value

Check warning on line 276 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L273-L276

Added lines #L273 - L276 were not covered by tests

# Workflow type
attributes[WorkflowAttributes.WORKFLOW_TYPE] = "agent_run"

Check warning on line 279 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L279

Added line #L279 was not covered by tests

# Add display name for better UI visualization
if agent_name:

Check warning on line 282 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L282

Added line #L282 was not covered by tests
# Check if we have parent team info
parent_team = attributes.get("agno.agent.parent_team")
if parent_team:
attributes["agno.agent.display_name"] = f"{agent_name} (Agent under {parent_team})"

Check warning on line 286 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L284-L286

Added lines #L284 - L286 were not covered by tests
else:
attributes["agno.agent.display_name"] = f"{agent_name} (Agent)"

Check warning on line 288 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L288

Added line #L288 was not covered by tests

return attributes

Check warning on line 290 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L290

Added line #L290 was not covered by tests
Loading
Loading