Skip to content

🐛 Fix(evaluation): require a selected evaluator and remove Jiuwen scoring fallback - #4337

Open
cj2026-bit wants to merge 2 commits into
developfrom
cj/fix-eval-remove-jiuwen-fallback
Open

cj2026-bit wants to merge 2 commits into
developfrom
cj/fix-eval-remove-jiuwen-fallback

Conversation

@cj2026-bit

@cj2026-bit cj2026-bit commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

  • Trial runs and both formal evaluation modes required an evaluator in the UI, but the backend initialized JiuwenSDKAdapter unconditionally in management/services/evaluation/execution.py and runs.py.
  • _evaluate_query silently fell back to adapter.evaluate_semantic_consistency(...) whenever the preloaded evaluator map was empty, so a run with no usable evaluator produced {"semantic_consistency": ...} scores outside the selected-evaluator contract instead of failing.
  • This affects all three entry points: the evaluator "Try it out" trial run, formal evaluation with an evaluation set, and formal evaluation without a set (AI-generated queries). They all converge on _evaluate_query.

Fix

  • Remove the Jiuwen adapter imports, construction, and propagation from management/services/evaluation/execution.py and management/services/evaluation/runs.py. No new adapter is introduced.
  • _evaluate_query now rejects an empty evaluator map before the agent is called (AGENT_EVALUATION_EVALUATOR_REQUIRED), and always scores through _score_with_evaluators.
  • Trial run: after loading evaluator_ids, an empty set of PUBLISHED evaluators raises AppException before agent execution. The config API now forwards the runtime's structured error response (code/message/HTTP status) instead of collapsing it to a generic 500, so callers receive 160209 with a clear message.
  • Trial-run UI: the drawer's trial handler now checks response.ok. A non-2xx response shows the backend message/detail as an error toast and does not populate the success result modal; network failures show the localized fallback agentEvaluation.trialFailed (zh/en).
  • Formal run: execute_agent_evaluation_run preloads PUBLISHED evaluators from the frozen run config and raises before iterating cases when none are usable. The existing outer handler marks the run FAILED and stores the reason in error_message. This covers both with-set and no-set runs because both dispatch to the same execution entry.
  • Add AGENT_EVALUATION_EVALUATOR_REQUIRED = "160209" (HTTP 400) to contracts with its default message. Existing API payloads, evaluator scoring, and persistence contracts are unchanged; selected LLM/code evaluators still produce the same {evaluator_name: score} / reason payloads.
  • The independent prompt-optimization Jiuwen call chain in prompt_service and its adapter are intentionally untouched; only evaluation usage is removed.

Verification

  • Targeted backend tests (each file run in its own process, matching test/run_all_test.py isolation):
    • test/backend/services/test_agent_evaluation_service.py: 153 passed, 4 skipped
    • test/backend/services/test_evaluation_pure_logic.py: 27 passed
    • test/backend/app/test_agent_evaluation_app.py: 51 passed
    • test/backend/app/test_agent_evaluation_runtime_app.py: 11 passed
    • test/backend/app/test_evaluation_delete_app.py: 19 passed
  • py_compile and the pre-commit ruff rule set were run on the changed files. The diff adds no new ruff findings; runs.py/the evaluation test file already carry pre-existing F401/I001 debt on the base commit (split-module re-exports), which is why the backend commit was made with --no-verify. Counts before/after are unchanged for those files.
  • Frontend: npm run type-check passes and Prettier reports no formatting changes on the three UI/locale files.
  • CI on head 93c8f54d7: 16/16 checks pass, including test (pytest + coverage generation and Codecov upload) and codecov/patch; type-check, CodeQL and all image builds also pass.
  • Real deployment: worktrees/deploy checked out at this branch head, config/runtime started from WSL against the local historical PostgreSQL data, frontend served from the same commit. Backend behavior was verified at 905fabcac; the trial error display was re-verified at 93c8f54d7.
    • Trial run with evaluator 答案准确性: agent answer returned and score keyed by the selected evaluator ({"答案准确性": 0.0}; expected answer is empty in trial mode), no semantic_consistency.
    • Trial run with no evaluator_ids: HTTP 400, {"code":"160209","message":"At least one published evaluator is required for a trial run."}. Same result with a nonexistent evaluator id.
    • Trial-run page with an invalid selected evaluator: the result modal stays closed and the page shows the error toast At least one published evaluator is required for a trial run.
    • Formal evaluation with set 简单数值计算 (run 37): COMPLETED, 12/12 cases passed, overall 0.97, per-evaluator stats keyed by 答案准确性.
    • Formal evaluation without a set, 2 generated queries (run 38): COMPLETED, 2/2 cases scored by 答案准确性, overall 0.00 (generated weather queries have no expected answer).
    • Formal evaluation without an evaluator, with set (run 39): FAILED before any case ran (0/12) with error_message = "No usable evaluator is configured for this run. Select at least one published evaluator and retry."
    • Formal evaluation without an evaluator, no set (run 40): FAILED (0/2) with the same reason.
  • Environment note: latest develop required pending migrations on the local historical database; v2.9.0_008, v2.9.0_009 (both files), and v2.9.0_010 were applied through the repository migration runner. A pre-migration pg_dump was kept at C:\Users\cj\IdeaProjects\nexent\artifacts\eval-remove-jiuwen-20261112\nexent-before-migrate.dump.

Screenshots (local evidence, to be attached)

01-evaluation-list 02-with-set-detail 03-failed-no-evaluator 04-no-set-detail 05-trial-run-result 06-failed-run-api-evidence 07-trial-invalid-evaluator-ui-error

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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.

1 participant