feat(experiment): add opt-in model routing for evaluators - #325
Open
pdebjyot wants to merge 1 commit into
Open
Conversation
Adds ModelRouter and RoutingRule, plus an optional model_router parameter on Experiment, so evaluation cost/accuracy can be matched to evaluator complexity: fast models for structural/rubric checks, strong models for nuanced judgment. Semantics: - Opt-in: no model_router means behavior is unchanged. - Explicit wins: an evaluator constructed with model=... is never re-routed. - First matching RoutingRule wins; rules match on evaluator type (class or name) and an optional per-case condition (e.g., trace length) enabling complexity-based routing. - Routing returns a shallow copy of the evaluator with the routed model so shared instances are never mutated across concurrent workers; evaluators without a model attribute (deterministic) pass through untouched. - A raising condition logs a warning and skips the rule instead of failing the evaluation. model_router is intentionally excluded from Experiment.to_dict()/from_dict() since routing conditions are arbitrary callables.
pdebjyot
requested a deployment
to
manual-approval
July 23, 2026 16:06 — with
GitHub Actions
Waiting
pdebjyot
requested a deployment
to
manual-approval
July 23, 2026 16:06 — with
GitHub Actions
Waiting
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.
Closes #323
Related: #88
Description
Adds
ModelRouterandRoutingRule(new modulestrands_evals/model_router.py), plus an optionalmodel_router=parameter onExperiment, so evaluation cost/accuracy can be matched to evaluator complexity: fast models for structural/rubric checks, strong models for nuanced judgment — including case-dependent escalation (e.g., long traces get a stronger judge).Semantics:
model_router→ behavior unchanged.model=...is never re-routed.conditionpredicate. No match falls through to an optionaldefault_model.modelattribute (deterministic) pass through untouched.conditionlogs a warning and skips the rule instead of failing the evaluation.model_routeris intentionally excluded fromExperiment.to_dict()/from_dict()since routing conditions are arbitrary callables.Example
Testing
Experimentintegration tests asserting the judge agent is constructed with the routed model (and unchanged without a router).ruff checkandruff formatclean.Checklist