Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -385,6 +385,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
29 changes: 29 additions & 0 deletions agentops/instrumentation/agno/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""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

# Export attribute handlers for external use
from .attributes.agent import get_agent_run_attributes
from .attributes.team import get_team_run_attributes, get_team_public_run_attributes
from .attributes.tool import get_tool_execution_attributes
from .attributes.metrics import get_metrics_attributes

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L8 - L11 were not covered by tests

logger = logging.getLogger(__name__)

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

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/__init__.py#L13

Added line #L13 was not covered by tests

__version__ = "1.0.0"

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

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/__init__.py#L15

Added line #L15 was not covered by tests

LIBRARY_NAME = "agno"
LIBRARY_VERSION = __version__

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

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/__init__.py#L17-L18

Added lines #L17 - L18 were not covered by tests

__all__ = [

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

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/__init__.py#L20

Added line #L20 was not covered by tests
"AgnoInstrumentor",
"LIBRARY_NAME",
"LIBRARY_VERSION",
"get_agent_run_attributes",
"get_team_run_attributes",
"get_team_public_run_attributes",
"get_tool_execution_attributes",
"get_metrics_attributes",
]
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",
]
294 changes: 294 additions & 0 deletions agentops/instrumentation/agno/attributes/agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
"""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
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["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["agent.tools_names"] = ",".join(tool_names[:5]) # Limit to first 5
attributes["agno.agent.tools_count"] = str(len(tool_names))

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L155 - L157 were not covered by tests

if tools_info:
import json

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L159 - L160 were not covered by tests

try:

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L162 was not covered by tests
# Limit to first 3 tools to avoid overly long attributes
limited_tools = tools_info[:3]
tools_json = json.dumps(limited_tools)
attributes[AgentAttributes.AGENT_TOOLS] = tools_json
except:

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

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L164-L167

Added lines #L164 - L167 were not covered by tests
# Fallback if JSON serialization fails
attributes[AgentAttributes.AGENT_TOOLS] = str(tools_info)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L169 was 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 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, "knowledge") and agent.knowledge:
knowledge_type = type(agent.knowledge).__name__
attributes["agno.agent.knowledge_type"] = knowledge_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

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

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

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L180-L182

Added lines #L180 - L182 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 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

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 191 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L189-L191

Added lines #L189 - L191 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 201 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L194-L201

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L203 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 208 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L206 - L208 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L210 - L211 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L213 - L214 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 220 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L217 - L220 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 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, "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 228 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L226 - L228 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 235 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L230 - L235 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 239 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L237-L239

Added lines #L237 - L239 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 245 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L242-L245

Added lines #L242 - L245 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 248 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L247 - L248 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L250 - L252 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 259 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L254-L259

Added lines #L254 - L259 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 265 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L261 - L265 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 268 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L267 - L268 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L270 was not covered by tests

if tool_exec_dict:
tool_executions.append(tool_exec_dict)

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L272 - L273 were not covered by tests

if tool_executions:

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L275 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 280 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/agno/attributes/agent.py#L277-L280

Added lines #L277 - L280 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L283 was not covered by tests

# Add display name for better UI visualization
if agent_name:

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#L286

Added line #L286 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 290 in agentops/instrumentation/agno/attributes/agent.py

View check run for this annotation

Codecov / codecov/patch

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

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L292 was not covered by tests

return attributes

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L294 was not covered by tests
Loading
Loading