Skip to content
Merged
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
7 changes: 6 additions & 1 deletion py/src/braintrust/integrations/agno/test_agno.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ def test_agno_agent_tools_metadata_placement(memory_logger):
Agent = agent_module.Agent
OpenAIChat = openai_module.OpenAIChat

def get_weather(city: str) -> str:
def get_weather(agent: Agent, city: str) -> str:
"""Return the current weather for *city*."""
assert agent.name == "Weather Agent"
return f"The weather in {city} is 72F and sunny."

assert not memory_logger.pop()
Expand All @@ -148,6 +149,10 @@ def get_weather(city: str) -> str:
assert response and response.content

spans = memory_logger.pop()
tool_spans = [s for s in spans if s["span_attributes"]["type"].value == "tool"]
assert len(tool_spans) == 1
assert tool_spans[0]["input"] == {"city": "Paris"}
assert tool_spans[0]["metadata"] == {"name": "get_weather", "entrypoint": "get_weather"}
llm_spans = [s for s in spans if s["span_attributes"]["type"].value == "llm"]
assert llm_spans, "expected at least one llm span"

Expand Down
13 changes: 6 additions & 7 deletions py/src/braintrust/integrations/agno/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,12 @@ def _get_function_name(instance) -> str:


def _function_call_metadata(instance: Any) -> dict[str, Any]:
"""Best-effort metadata extraction for a FunctionCall. Contains instrumentation errors."""
"""Allowlist tool identity fields, containing instrumentation errors.

Never collect ``_build_entrypoint_args()`` for logging: injected runtime
objects (including Agent, Team, and RunContext) can contain credentials or
private state. Agno owns injecting those objects when executing the tool.
"""
metadata: dict[str, Any] = {}
try:
metadata["name"] = instance.function.name
Expand All @@ -1255,12 +1260,6 @@ def _function_call_metadata(instance: Any) -> dict[str, Any]:
metadata["entrypoint"] = instance.function.entrypoint.__name__
except Exception:
pass
try:
entrypoint_args = instance._build_entrypoint_args()
if entrypoint_args:
metadata.update(entrypoint_args)
except Exception:
pass
return metadata


Expand Down