fix(matchers): warn on implicit self grading fallback by Asthenia0412 · Pull Request #10640 · promptfoo/promptfoo · GitHub
Skip to content

fix(matchers): warn on implicit self grading fallback - #10640

Open
Asthenia0412 wants to merge 1 commit into
promptfoo:mainfrom
Asthenia0412:codex/grader-self-warning
Open

fix(matchers): warn on implicit self grading fallback#10640
Asthenia0412 wants to merge 1 commit into
promptfoo:mainfrom
Asthenia0412:codex/grader-self-warning

Conversation

@Asthenia0412

Copy link
Copy Markdown

Summary

  • Warn when model-graded assertions implicitly use defaultTest.provider as the grader because no explicit grader was configured.
  • Keep the existing fallback order intact for backwards compatibility.
  • Document that defaultTest.provider can become the implicit grader and may make the target grade itself.

Why

defaultTest.provider is primarily the test target override, but today it is also used as a grader fallback. That can make the target model generate and grade the same output with only a debug log, so users may miss a self-grading setup in CI or normal eval output.

Fixes #10581

Validation

  • npx vitest run test/matchers/getGradingProvider.test.ts initially failed on the new warning assertion before the implementation change.
  • npx vitest run test/matchers/getGradingProvider.test.ts test/matchers/utils.test.ts
  • npx @biomejs/biome check src/matchers/providers.ts test/matchers/getGradingProvider.test.ts
  • npx prettier --check site/docs/configuration/expected-outputs/model-graded/index.md
  • git diff --check

Notes

  • npm run tsc still fails locally on the existing optional @openai/codex-security import/type errors in src/providers/openai/codex-security.ts; this branch does not touch that provider.

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

@promptfoo-scanner promptfoo-scanner Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 All Clear

Reviewed changes to provider fallback selection and related tests/documentation. The PR adds source-aware fallback logic and a warning when defaultTest.provider implicitly acts as the grader. No new LLM prompts, tool capabilities, or execution sinks were introduced. No LLM security vulnerabilities were identified in this diff.

Minimum severity threshold: 🟡 Medium | To re-scan after changes, comment @promptfoo-scanner
Learn more


Was this helpful?  👍 Yes  |  👎 No 

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d6598abb51

ℹ️ 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".

Comment thread src/matchers/providers.ts
Comment on lines +233 to +236
logger.warn(
'[Grading] defaultTest.provider is being used as the grader because no explicit grader is configured',
logContext,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Warn only after the provider passes modality validation

When an embedding assertion such as similar runs with a normal chat provider in defaultTest.provider, this warning fires before getAndCheckProvider determines that the provider lacks callEmbeddingApi and returns the built-in embedding provider instead. The CLI therefore claims that defaultTest.provider is being used as the grader even though it is never called for that assertion; defer the warning until after type validation so it describes the provider actually selected.

Useful? React with 👍 / 👎.

Comment thread src/matchers/providers.ts
Comment on lines +233 to +236
logger.warn(
'[Grading] defaultTest.provider is being used as the grader because no explicit grader is configured',
logContext,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Emit the implicit-grader warning only once per eval

When an eval has multiple outputs or model-graded assertions and relies on defaultTest.provider, every assertion invocation reaches this branch and emits the same warning. A typical matrix can therefore produce hundreds of identical warning blocks, obscuring progress and actionable errors in normal CLI and CI output; deduplicate it per eval/provider rather than logging once per grading call.

Useful? React with 👍 / 👎.

Comment thread src/matchers/providers.ts
Comment on lines +229 to +235
const logContext = {
providerId: finalProvider.id(),
});
};
if (fallback.source === 'defaultTest.provider') {
logger.warn(
'[Grading] defaultTest.provider is being used as the grader because no explicit grader is configured',
logContext,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Sanitize provider IDs before warning

When defaultTest.provider is a raw HTTP endpoint containing basic-auth credentials or a token-bearing query parameter, HttpProvider.id() returns that complete URL and this new warning writes it to normal CLI and CI logs under the non-sensitive providerId context key. Generic context sanitization does not apply URL sanitization to that key, so credentials that were previously confined to debug output become exposed; pass the ID through sanitizeProviderIdForLog before logging it.

Useful? React with 👍 / 👎.

Comment on lines +278 to +281

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Split the site edit into a docs(site) commit

The reviewed commit uses the fix(matchers): scope while modifying the documentation site; split this documentation change into a commit using the required docs(site): scope.

AGENTS.md reference: site/AGENTS.md:L9-L9

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant