Improve trace loading logic#123
Merged
krisztianfekete merged 3 commits intomainfrom Apr 17, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands the evaluation pipeline to support running evaluations on pre-loaded Trace objects and accepting OTLP traces via JSON request bodies, reducing reliance on file I/O and multipart uploads.
Changes:
- Introduces
EvalParams(evaluation-only config) and refactors the runner to evaluate from in-memory traces viarun_evaluation_from_traces(). - Adds
OtlpJsonLoader.load_from_dict()and extends OTLP attribute extraction to handle flat/nested dict attribute formats (with dot-notation flattening). - Adds new API endpoints
POST /evaluate/jsonandPOST /evaluate/json/streamto evaluate OTLP traces provided as JSON.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/agentevals/runner.py | Refactors evaluation to support pre-loaded traces; keeps file-based API delegating to the new core path. |
| src/agentevals/loader/otlp.py | Adds dict-based OTLP loading and more flexible attribute extraction (including nested dict flattening). |
| src/agentevals/config.py | Splits evaluation parameters into EvalParams and makes EvalRunConfig inherit from it; enables camelCase aliases. |
| src/agentevals/api/routes.py | Adds JSON-body evaluation endpoints (sync + SSE) that bypass multipart uploads. |
| src/agentevals/api/models.py | Adds EvaluateJsonRequest request model wiring JSON traces + config + optional eval set. |
Comments suppressed due to low confidence (1)
src/agentevals/config.py:130
- The JSON endpoints now rely on
EvalParamsvalidation, butthresholdandmetricsno longer get the input checks that/evaluateapplies (non-empty metrics list, threshold in [0,1]). Consider moving those validations intoEvalParams(field constraints/validators) so file-based and JSON-based evaluation behave consistently and return 4xx validation errors instead of failing later during evaluation.
metrics: list[str] = Field(
default_factory=lambda: ["tool_trajectory_avg_score"],
description="List of built-in metric names to evaluate.",
)
custom_evaluators: list[CustomEvaluatorDef] = Field(
default_factory=list,
description="Custom evaluator definitions.",
)
judge_model: str | None = Field(
default=None,
description="LLM model for judge-based metrics.",
)
threshold: float | None = Field(
default=None,
description="Score threshold for pass/fail.",
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b4d3f32 to
93e3e52
Compare
peterj
reviewed
Apr 17, 2026
peterj
reviewed
Apr 17, 2026
peterj
reviewed
Apr 17, 2026
peterj
reviewed
Apr 17, 2026
peterj
reviewed
Apr 17, 2026
peterj
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the ability to evaluate traces without file uploads.
EvalParamsbase class inconfig.pythat pulls out the evaluation-only settings (metrics, judge model, threshold, etc.) from EvalRunConfig. The existing config inherits from it so nothing breaks. Accepts bothcamelCaseandsnake_casefor API consumers.run_evaluation_from_traces()that takes pre-loadedTraceobjects and anEvalParamsdirectly, skipping all file I/O.run_evaluation()now delegates to it under the hood.OtlpJsonLoader.load_from_dict()for parsing OTLP JSON from a dict instead of a file path. Also made_extract_attributes()smarter: it now handles flat dicts and nested dicts (auto-flattened to dot-notation) alongside the standard OTLP attribute arrays./evaluate/jsonandPOST/evaluate/json/streamthat accept traces as a JSON body instead of multipart form uploads. Same SSE event format as the existing streaming endpoint.