Skip to content

Conversation

@daavoo
Copy link
Contributor

@daavoo daavoo commented May 5, 2025

TODO:

  • Extract evaluation logic from tracing/processors

daavoo added 3 commits May 2, 2025 17:55
Move `any_agent/tracing.py` to `any_agent/tracing/tracer.py`.
@daavoo daavoo requested a review from Copilot May 5, 2025 10:57
@daavoo daavoo self-assigned this May 5, 2025
@daavoo daavoo requested a review from njbrake May 5, 2025 10:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the tracing and evaluation logic to consolidate telemetry, agent result, and agent trace functionality. Key changes include removing the legacy telemetry modules, updating agent framework methods to return AgentTrace instead of AgentResult, and refactoring tracing and instrumentation initialization across the codebase.

Reviewed Changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/any_agent/tracing/exporter.py Introduces the new AnyAgentExporter for building and exporting traces.
src/any_agent/tracing/init.py Updates the public API of the tracing module.
src/any_agent/tracing.py Removes the legacy tracing module now replaced by the new implementation.
src/any_agent/telemetry/* Removes telemetry cost and processor files as they are consolidated.
src/any_agent/frameworks/*.py Updates run_async methods and imports across frameworks to use AgentTrace.
src/any_agent/frameworks/any_agent.py Refactors the AnyAgent base class to use the new _setup_tracing and exporter model.
src/any_agent/evaluation/* Adjusts evaluator and evaluation modules to use the new tracing processor.
src/any_agent/config.py Improves the validation error message for output_dir when saving traces.
src/any_agent/init.py Updates public imports to expose AgentTrace and remove legacy types.
README.md Updates usage examples to reflect the new tracing interface.
Comments suppressed due to low confidence (1)

src/any_agent/frameworks/tinyagent.py:191

  • After removing the call to self._create_tracer, please verify that self._exporter is reliably initialized via _setup_tracing before it is used in run_async.
async def run_async(self, prompt: str, **kwargs: Any) -> AgentTrace:

from opentelemetry.sdk.trace import ReadableSpan


class AnyAgentExporter(SpanExporter):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@njbrake You could implement here the:

include things like the agent framework that was used, which would be a much more reliable method to load the trace when it comes to evaluation

However, let's make sure that the resulting JSON is compatible with OTEL, whatever that means

@daavoo daavoo marked this pull request as draft May 5, 2025 11:09
@daavoo daavoo changed the title 194 refactor to consolidate evaluation telemetry agentresult and anyagenttrace Refactor around returning and using AgentTrace May 5, 2025
@daavoo daavoo marked this pull request as ready for review May 5, 2025 11:42
@daavoo daavoo marked this pull request as draft May 5, 2025 11:42
@daavoo daavoo marked this pull request as ready for review May 5, 2025 14:11
@daavoo daavoo merged commit d4eda14 into main May 5, 2025
3 checks passed
@daavoo daavoo deleted the 194-refactor-to-consolidate-evaluation-telemetry-agentresult-and-anyagenttrace branch May 5, 2025 14:16
Comment on lines -45 to -48
self._last_tracer: Tracer | None = (
None # holds the trace from the most recent run
)
self._tracing_config = tracing
Copy link
Contributor

@njbrake njbrake May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daavoo Whoops I missed this during the initial review. Making this change means that now all the agent.run() commands from an agent are going to get merged into a single trace. That's going to be an issue for people that are running the agent in a server or want to have multiple runs happening in a single instantation of the agent.

 result = agent.run("What's the best agent framework")
 result2 = agent.run("What's the best agent framework")

result2 is going to be result and result2 appended on top of it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor to consolidate evaluation, telemetry , AgentResult and AnyAgentTrace.

3 participants