Repository navigation
Conversation
A custom engine could report four fixed numbers about a run: duration, turns, and input and output tokens. Anything else, such as decode speed at given context lengths or time to first token, had to go into an artifact file that skill-up archived without reading. SessionResult now accepts an optional measurements object on both the local and http transports: named scalars and series, each with a unit, plus the engine's account of how they were produced. The new internal/measurement package validates it strictly. A defect in the object as a whole (an unsupported schema version, a duplicated JSON key, an unknown field, missing provenance, a size limit) rejects all of it. A defect in one entry rejects only that entry and keeps its siblings. Every rejection leaves a diagnostic, nothing is truncated, and a value that could not be measured stays MISSING with its reason instead of becoming 0. Engine-supplied text is masked like stderr and final_message. The validated measurements are written to result.json and report.json as engine_measurements and engine_measurement_diagnostics: on the case for a single-turn case, and on the turn that reported them for a multi-turn one. buildAggregateResult copies the last turn's SessionResult, so it now clears them; otherwise the last turn's measurements would be presented as the whole case's. Measurements are informational. They never change a verdict, a pass rate, the benchmark or a named-metric state, and an invalid object never fails the case. Results without measurements are unchanged, and grading.json, benchmark.json, the JUnit, HTML and Markdown reports, OTel attributes and the JSONL event stream do not carry them. The HTML report converted each turn result to its embedded form with a struct conversion, which the new turn fields would break, so it now copies the fields it embeds. The custom engine design doc gains the Measurements contract, with the decode-speed sweep from alibaba#296 as the worked example. The writing-evals guides and the CHANGELOG describe the field. Refs alibaba#422
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aebd578054
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| previous := math.Inf(-1) | ||
| for index, item := range rawPoints { | ||
| point, at, defect := p.parsePoint(item) | ||
| if defect == nil && at <= previous { |
There was a problem hiding this comment.
Preserve distinct decimal positions when validating series
When an engine sends a valid series with adjacent JSON decimals that are distinct but map to the same float64 (for example 9007199254740992 followed by 9007199254740993), parsePoint preserves each literal but this comparison sees equal rounded positions and rejects the entire series as non-increasing. Since the contract accepts finite JSON numbers and retains their spelling, compare positions without losing decimal precision or explicitly reject non-representable coordinates.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The comparison does read positions as float64 while the stored point keeps the literal. I kept the float64 comparison and stated it, rather than comparing decimals exactly: most readers of the stored JSON see at as a double, so two such points could not be told apart downstream either. 1669242 documents the rule in the design doc and the code, and adds a test for an integer pair, a decimal pair and the neighboring float64 that is accepted.
A series is rejected when a point's position does not increase. The comparison reads each position as a float64, while the stored point keeps the engine's literal. Two literals that are distinct as decimals but convert to the same float64, such as 9007199254740992 and 9007199254740993, therefore reject the series, and nothing said so. Keep that behavior and state it. Most readers of the stored JSON see positions as doubles, so two such points could not be told apart downstream either. The design doc, the Point and parsePoints comments and the diagnostic hint now give the rule. A test pins it for an integer pair and a decimal pair, together with the neighboring float64 that is accepted. Refs alibaba#422
Summary
A custom engine can report four fixed numbers about a run:
duration_ms,turns,input_tokensandoutput_tokens. Any other runtime measurement, such as decode speed at given context lengths or time to first token, had to go into an artifact file that skill-up archived without reading.This PR is slice 1 of #422.
SessionResultaccepts an optionalmeasurementsobject on both thelocalandhttptransports: namedscalarsandseries, each with a unit, plus the engine's own provenance. skill-up validates it strictly, masks it, and writes it toresult.jsonandreport.json. It does nothing else with it: measurements never change a verdict, a pass rate, the benchmark or a named-metric state, and an invalid object never fails the case.Related issues
Refs #422 (slice 1: contract and persistence). Background in #296.
Changes
internal/measurement(new, no internal dependencies): the stored form and the strict parser. A whole-object defect (unsupportedschema_version, a duplicated JSON key, an unknown field, missing or invalidprovenance, a size limit) rejects the object. An entry defect (invalididorunit, a duplicatedid, a non-finite value, a bad point, a series over its point limit) rejects only that scalar or series. Every rejection leaves a diagnostic with a scope, a code and a path. Nothing is truncated, and a missing value staysMISSINGwith its reason.internal/agent:parseSessionResultkeepsmeasurementsas a raw field and validates it on its own, so a defect there cannot fail the decode of the fields grading depends on. Engine-supplied text goes throughmaskAPIKey, likestderrandfinal_message.internal/evaluator:buildAggregateResultcopies the last turn'sSessionResult. It now clears the measurements, which would otherwise be presented as the whole case's.internal/report,internal/runner:CaseResultandCaseTurnResultgainengine_measurementsandengine_measurement_diagnostics, bothomitempty. A single-turn case carries them on the case; a multi-turn case carries them on the turn that reported them.internal/report/html.go: the HTML report converted each turn result to its embedded form with a struct conversion, which the new turn fields would break. It now copies the fields it embeds. The HTML output is unchanged.docs/design/custom-engine.mdwith the Eval scenario: long-context decode TPS decay — half-speed point as a compaction-threshold anchor #296 decode-speed sweep as the worked example, a short section in bothwriting-evalsguides, and a CHANGELOG entry.Following the review on #422:
scalarsandseries.requested_context_tokens, and the observed input-token count is a second series on that axis, so a timed-out step isMISSINGin both.Test plan
make testpassesmake verifypasses (fmt + vet + lint)make e2epasses (94 passed; 41 skipped as LLM-dependent in quick mode)result.jsoncarries the valid entries and oneinvalid_unitdiagnostic, and the missing point has novalue.mainwith this branch on the same result without measurements: thereport.json, JUnit, HTML and Markdown output is byte-identical.How the acceptance criteria of #422 map to tests:
localandhttpboth persist a scalar and a seriesTestPipeline_CustomEngine_Measurements_LocalTransport,TestPipeline_CustomEngine_Measurements_HTTPTransportresult.jsonandreport.jsonunchangedTestWriteResults_MeasurementsChangeNothingElse,TestPipeline_CustomEngine_NoMeasurementsLeavesTheOutputsUntouchedTestWriteResults_MeasurementsChangeNothingElse,TestCustomAgent_MeasurementsNeverChangeTheRunOutcome,TestPipeline_CustomEngine_Measurements_InvalidNeverChangesTheVerdictMISSINGkeeps its reason; nothing becomes0TestParseKeepsMissingValuesMissing,TestWriteResults_MissingMeasurementIsWrittenWithoutAValueTestParseRejectsTheWholeObject,TestParseRejectsOnlyTheDefectiveScalar,TestParseRejectsOnlyTheDefectiveSeries,TestParseRejectsEveryEntryCarryingADuplicatedIDTestParseAcceptsEveryLimitAtItsBoundary,TestParseRejectsOnePastEachWholeObjectLimit,TestParseRejectsOnePastEachEntryLimitTestParseMasksEngineText,TestCustomAgent_MasksMeasurementText,TestDiagnosticsNeverEchoRejectedTextTestExecuteMultiTurn_MeasurementsStayOnTheTurnThatReportedThem,TestPipeline_CustomEngine_Measurements_StayOnTheirTurndocs/design/custom-engine.md; the same document is the fixture ofTestParseWorkedExampleNotes for reviewers
Three things the proposal did not settle:
NaN/Infinity. They make the wholeSessionResultinvalid JSON, so the case is a result error, and Python'sjson.dumpswrites them by default. "Invalid measurements never change the verdict" cannot hold for that input. The docs tell engines to serialize withallow_nan=Falseand report such a value asMISSING. A number that is valid JSON but out of float64 range, such as1e999, rejects only its own entry.null. It is read as an omitted field, formeasurementsitself and for the optional fields inside it.Smaller choices, all written down in the design doc:
agent_judgeengine has itsmeasurementsvalidated but not stored.Two naming choices I'd like your view on:
engine_measurementsandengine_measurement_diagnostics;duplicate_json_key,size_limit, ...) instead of their own (duplicate_key,payload_too_large, ...).