Skip to content

fix(evals): name the model of a spec hash rather than stringifying it - #430

Merged
TonsOfFun merged 1 commit into
mainfrom
fix/model-spec-hash
Sep 11, 2026
Merged

fix(evals): name the model of a spec hash rather than stringifying it#430
TonsOfFun merged 1 commit into
mainfrom
fix/model-spec-hash

Conversation

@TonsOfFun

Copy link
Copy Markdown
Contributor

A scenario evaluation started from the dashboard failed every scenario with HTTP 400 before reaching the model.

Root cause

ModelSpec.parse_all calls to_s on each value:

values.map { |value| value.to_s.strip }

A Hash stringifies to its inspected form, which then travels as the model ID. OpenRouter answers:

{"label" => "openrouter/openai/gpt-4o-mini", "model" => "openai/gpt-4o-mini",
 "provider" => "openrouter"} is not a valid model ID

This is reachable from the dashboard by design, not by misuse: ScenarioEvaluationRunner#selection_summary persists a run's models as specs.map(&:to_h), and re-running that selection hands the hashes straight back to parse_all. A caller passing a plain string (test_execute) was unaffected, which is why single runs worked while every batch run failed.

Fix

parse_all names the model of a hash — label first, then model — and leaves strings alone.

Verification

Against a host application whose agent calls MCP tools, the same three-scenario run before and after:

before after
errors 3 × HTTP 400 0
tool calls none list_filters, search_providers
scores 0.0 0.68 – 0.875
duration ~1s (failed early) 2.8 – 4.3s

The remaining failures are genuine quality results rather than infrastructure.

Three regression tests cover the label-bearing hash, a symbol-keyed hash, and a hash carrying only model.

parse_all called to_s on each value, so a Hash arrived at the provider as its
inspected form and every scenario failed with '{"label" => ...} is not a
valid model ID'. The dashboard persists a run's models as specs.map(&:to_h)
and hands that back on a re-run, so any dashboard-initiated run hit this.
@TonsOfFun
TonsOfFun marked this pull request as ready for review September 11, 2026 01:17
@TonsOfFun
TonsOfFun requested a balanced review from Copilot September 11, 2026 02:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused implementation resolves the reported round-trip failure and is adequately covered by regression tests.

Pull request overview

Fixes dashboard evaluation reruns by correctly parsing persisted model-spec hashes.

Changes:

  • Extracts label, falling back to model, from hash-like values.
  • Adds regression coverage for string-keyed, symbol-keyed, and label-less hashes.
File summaries
File Description
lib/active_agent/evals/model_spec.rb Coerces persisted model specs before parsing.
test/evals/model_spec_test.rb Tests supported hash representations.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@TonsOfFun
TonsOfFun merged commit 18010e2 into main Sep 11, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants