Repository navigation
feat(sleep): record judge-side latency, requests, and model identity in replay and reports - #369
Open
RohithPariki wants to merge 1 commit into
Open
RohithPariki wants to merge 1 commit into
RohithPariki wants to merge 1 commit into
Conversation
…in replay and reports
- Add judge_latency_ms, judge_tokens, and judge_model to ReplayResult
- Add judge_requests, judge_latency_ms, judge_tokens, and judge_model to SleepReport and ConsolidationResult
- Expose judge_model_name property on Backend and DualBackend
- Measure judge-side timing and token deltas in replay_one, distinguishing local rule judges ('rule') from external LLM evaluations
- Aggregate judge metrics across consolidation passes and held-out test evaluation in run_sleep_cycle
- Surface judge metrics in report.json, report.md, and evidence logs
- Add comprehensive unit test suite in tests/test_sleep_judge_observability.py
Fixes microsoft#283
This branch has not been deployed
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.
Problem
In SkillOpt-Sleep, offline task replay (
replay_one) previously measured latency and token consumption strictly aroundbackend.attempt(). When tasks use semantic evaluators (rubric scoring or LLM-as-a-judge),backend.judge()is invoked afterwards to assess response quality. The computational latency, token spend, and model attribution of these judge evaluations were unmeasured and omitted from consolidation summaries and nightly reports (report.jsonandreport.md). Consequently, nightly runs had no visibility into evaluation costs vs task generation attempts, and dual-backend setups could not distinguish optimizer/judge model identity from target execution.In #283, maintainer Yifan Yang (@Yif-Yang) noted:
Solution
skillopt_sleep/types.py):judge_latency_ms: float = 0.0,judge_tokens: int = 0, andjudge_model: str = ""toReplayResult.judge_requests: int = 0,judge_latency_ms: float = 0.0,judge_tokens: int = 0, andjudge_model: str = ""toSleepReport.skillopt_sleep/backend.py):judge_model_nameproperty toBackend(resolvingmodelorname) andDualBackend(delegating tooptimizer.judge_model_name).skillopt_sleep/replay.py):time.time()and backend token accounting (token_delta/ delta oftokens_used()).judge_model="rule"with 0 tokens.backend.judge_model_nameand recorded latency and token deltas.skillopt_sleep/consolidate.py,skillopt_sleep/cycle.py):SleepReport.report.md(- judge: <requests> request(s), <latency>ms, <tokens> tokens (model: <model>)) and structuredreport.json.evidence.log("cycle", "end", ...).## [Unreleased] / ### Added.Testing
tests/test_sleep_judge_observability.py:test_replay_one_rule_judge_records_rule_model_and_zero_tokens: Verifies rule checks record zero tokens and"rule"model.test_replay_one_rubric_judge_measures_latency_and_tokens: Verifies rubric evaluation tracks latency, tokens, and model attribution.test_dual_backend_judge_model_attribution: VerifiesDualBackendroutesjudge_model_nameto the optimizer.test_consolidate_aggregates_judge_metrics: Verifies consolidation passes accumulate judge metrics intoConsolidationResult.test_render_report_md_includes_judge_observability: Verifies markdown report formatting for judge metrics.test_run_sleep_cycle_records_judge_metrics: Verifies end-to-endrun_sleep_cyclepopulates report judge metrics.pytest tests/test_sleep_judge_observability.py(6/6 passed in 0.48s).pytest tests/test_sleep_dream_metric.py tests/test_sleep_adopt_skill_subset.py(102 passed, 4 skipped).python -m ruff checkpassed cleanly.Risk
Low. All additions are additive and preserve backwards compatibility with existing backends and report schemas. Existing non-instrumented mock backends report 0 tokens and negligible latency without breaking existing assertions.
Fixes #283