-
Notifications
You must be signed in to change notification settings - Fork 42
fix(tracer): agent on vefaas lost tracer callback #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 fixes an issue where agent tracers were not properly initialized in the VeFaaS environment by ensuring tracer callbacks are updated after extending the tracers list.
- Extracts tracer callback setup logic into a reusable
update_tracers_callback()method - Adds deduplication logic to prevent duplicate callback registration
- Calls the new method after extending tracers in the VeFaaS template to ensure proper initialization
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| veadk/cli/services/vefaas/template/src/app.py | Calls update_tracers_callback() after extending agent tracers |
| veadk/agent.py | Refactors tracer callback setup into a reusable method with deduplication |
| for tracer in self.tracers: | ||
| # Add tracer callbacks if not already added | ||
| if tracer.llm_metrics_hook not in self.before_model_callback: | ||
| self.before_model_callback.append(tracer.llm_metrics_hook) | ||
| if tracer.token_metrics_hook not in self.after_model_callback: | ||
| self.after_model_callback.append(tracer.token_metrics_hook) | ||
|
|
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using not in for list membership checking has O(n) complexity. Consider using a set to track added callbacks for O(1) lookups, especially if the number of tracers could be large.
| for tracer in self.tracers: | |
| # Add tracer callbacks if not already added | |
| if tracer.llm_metrics_hook not in self.before_model_callback: | |
| self.before_model_callback.append(tracer.llm_metrics_hook) | |
| if tracer.token_metrics_hook not in self.after_model_callback: | |
| self.after_model_callback.append(tracer.token_metrics_hook) | |
| before_set = set(self.before_model_callback) | |
| after_set = set(self.after_model_callback) | |
| for tracer in self.tracers: | |
| # Add tracer callbacks if not already added | |
| if tracer.llm_metrics_hook not in before_set: | |
| self.before_model_callback.append(tracer.llm_metrics_hook) | |
| before_set.add(tracer.llm_metrics_hook) | |
| if tracer.token_metrics_hook not in after_set: | |
| self.after_model_callback.append(tracer.token_metrics_hook) | |
| after_set.add(tracer.token_metrics_hook) |
| for tracer in self.tracers: | ||
| # Add tracer callbacks if not already added | ||
| if tracer.llm_metrics_hook not in self.before_model_callback: | ||
| self.before_model_callback.append(tracer.llm_metrics_hook) | ||
| if tracer.token_metrics_hook not in self.after_model_callback: | ||
| self.after_model_callback.append(tracer.token_metrics_hook) | ||
|
|
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using not in for list membership checking has O(n) complexity. Consider using a set to track added callbacks for O(1) lookups, especially if the number of tracers could be large.
| for tracer in self.tracers: | |
| # Add tracer callbacks if not already added | |
| if tracer.llm_metrics_hook not in self.before_model_callback: | |
| self.before_model_callback.append(tracer.llm_metrics_hook) | |
| if tracer.token_metrics_hook not in self.after_model_callback: | |
| self.after_model_callback.append(tracer.token_metrics_hook) | |
| before_set = set(self.before_model_callback) | |
| after_set = set(self.after_model_callback) | |
| for tracer in self.tracers: | |
| # Add tracer callbacks if not already added | |
| if tracer.llm_metrics_hook not in before_set: | |
| self.before_model_callback.append(tracer.llm_metrics_hook) | |
| before_set.add(tracer.llm_metrics_hook) | |
| if tracer.token_metrics_hook not in after_set: | |
| self.after_model_callback.append(tracer.token_metrics_hook) | |
| after_set.add(tracer.token_metrics_hook) |
cuericlee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
No description provided.