-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[NA][SDK] Optimizer update LLM call/trace helpers #4215
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
base: main
Are you sure you want to change the base?
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 refactors and centralizes trace tagging functionality for LLM calls in the optimizer SDK. The main purpose is to standardize how optimization traces are tagged across different optimizer implementations and add support for conditionally disabling tracing based on environment variables.
Key changes:
- Centralized trace tagging logic in
BaseOptimizerwith a new_tag_trace()helper method - Added optimizer short name mapping for consistent tag prefixes across all optimizer types
- Implemented conditional tracing based on
OPIK_TRACK_DISABLEandOPIK_API_KEYenvironment variables
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| optimizable_agent.py | Added trace_phase attribute and automatic trace tagging during LLM completions |
| base_optimizer.py | Added _tag_trace() centralized method and optimizer short name mapping |
| meta_prompt_optimizer/ops/evaluation_ops.py | Removed manual trace tagging code, replaced with centralized helper |
| hierarchical_reflective_optimizer.py | Removed manual trace tagging code, replaced with centralized helper |
| gepa_optimizer.py | Removed manual trace tagging code, replaced with centralized helper |
| few_shot_bayesian_optimizer.py | Removed manual trace tagging code, replaced with centralized helper |
| evolutionary_optimizer/ops/evaluation_ops.py | Removed manual trace tagging code, replaced with centralized helper |
| _llm_calls.py | Added stack-based trace tagging, optimizer short name detection, and conditional tracing logic |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Details
Add some improvements and refactoring for LLM calls mostly to centralize trace tagging and manipulation. Added support (partially) to block tracing if enabled.
Change checklist
Issues
Testing
Locally
Documentation
n.a