Add persistent performance telemetry and timing metrics to auto_agent - #94
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces timing metrics tracking across the pipeline agent execution steps, registering callbacks globally and via a plugin to measure agent, LLM, and tool durations. The review feedback highlights several improvement opportunities: refactoring highly duplicated timing calculation blocks in pipeline_agent.py into a helper function, ensuring callbacks return the original request/response objects instead of None to avoid framework crashes, moving the module docstring in callbacks.py to the top of the file to comply with PEP 8, and replacing inline __import__('time') calls with standard top-level imports.
ff39738 to
2a51897
Compare
2a51897 to
3600bab
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a telemetry and timing framework to track execution durations for agents, LLM calls, and tools across pipeline iterations, including a timing analysis script and mock end-to-end tests. The review feedback highlights several critical improvements: preventing state key collisions in concurrent environments by using unique context IDs, guarding against KeyError during analysis of interrupted runs, broadening exception handling during hook injection, preventing negative framework overhead calculations, and replacing a hardcoded user directory path in the mock tests with a relative path.
Add Timing Metrics
Summary
This PR upgrades the timing mechanics across the Auto-Agent framework to include timing information for users. Previously, execution timing was obscured by overlapping hierarchical wait times (e.g., framework overhead bounds were mistakenly inflated by IO bottlenecks). This PR introduces precise chronological event tracking via float timestamps, automatically merges these timestamps into "Exclusive Compute" bounds (Flamegraph-style self-time), and links it all through an automated reporting script that prints to the console and generates markdown metrics.
Changes
auto_agent/timing_callbacks.py)start_time,end_time) instead of just total durational times._llm_start_{agent}) to ensure bounds process safely during parallel asynchronous executions.agent_eventsdata payload to prevent downstream summation crashes.auto_search/analyze_timing.py)timing_metrics.jsonoutputs.auto_search/run_search.py)analyze_timingparser natively to the final termination step of successful beam and parallel searches, ensuring that users automatically receive a terminal printout and a formattedtiming_summary.mdin the target tracking directory exactly when their task safely concludes..gitignore,/examples)examples/dummy_kernel/for proper localization..gitignorerule-set against tracking the Python local package environment (.venv).Example Outputs
Click to expand: Example timing_metrics.json (Truncated payload view)
{ "overall_pipeline_time": 548.34, "iterations": { "0": { "iteration_total_time": 548.34, "llm_calls": [ { "agent": "RunTestsAgent", "start_time": 1729000010.5, "end_time": 1729000085.2 } ], "tools": [ { "agent": "MockTestExecutionAgent", "start_time": 1729000092.1, "end_time": 1729000094.0 } ], "agent_events": [ { "agent": "AutotuneRunner", "start_time": 1729000000.0, "end_time": 1729000200.0 } ] } } }Click to expand: Example timing_summary.md (Parser Output)