Skip to content

feat(scan): Complete and reorganize quality scan #2563

Merged
kevinmessiaen merged 9 commits into
mainfrom
feat/complete-quality-scan
Jun 30, 2026
Merged

feat(scan): Complete and reorganize quality scan #2563
kevinmessiaen merged 9 commits into
mainfrom
feat/complete-quality-scan

Conversation

@pierlj

@pierlj pierlj commented Jun 25, 2026

Copy link
Copy Markdown
Member

Description

  • Reorganize the quality scenario generators under a dedicated subpackage
  • Add 3 new generators: out of scope, multi topic, and split questions
  • Add component tags, to match features from RAGET

Type of Change

  • 📚 Examples / docs / tutorials / dependencies update
  • 🔧 Bug fix (non-breaking change which fixes an issue)
  • 🥂 Improvement (non-breaking change which improves an existing feature)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🔐 Security fix

Coding agents

Autonomous agents with no human in the loop must read AUTONOMOUS.md before opening a PR.

PR title: agent-opened PRs must end the title with 🤖🤖🤖🤖 (exactly four robot emojis). Do not omit — that suffix is how the expedited agent PR workflow picks up the PR.

Checklist

  • I've read the CODE_OF_CONDUCT.md document.
  • I've read the CONTRIBUTING.md guide.
  • I've written tests for all new methods and classes that I created.
  • I've written the docstring in NumPy format for all the methods and classes that I created or modified.
  • I've updated the uv.lock running uv lock (only applicable when pyproject.toml has been
    modified)

@pierlj
pierlj requested a review from kevinmessiaen June 25, 2026 15:26

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a new Contradiction check and refactors the KnowledgeBaseScenarioGenerator into several specialized quality scenario generators, including HallucinationScenarioGenerator, MultiTopicScenarioGenerator, OutOfScopeScenarioGenerator, SplitQuestionsScenarioGenerator, and SycophancyScenarioGenerator. It also updates the groundedness prompt to allow explicit refusals and adds a helper method to retrieve closest documents to arbitrary text. The review feedback suggests improving the _stringify method in the contradiction judge to format lists cleanly, executing document retrieval concurrently using asyncio.gather in the multi-topic generator, and validating against empty or whitespace-only queries in the knowledge base utility.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread libs/giskard-checks/src/giskard/checks/judges/contradiction.py Outdated
Comment on lines +74 to +82
turn_contexts = [
[
document.content
for document in await params.knowledge_base.closest_documents(
turn_seed_index, self.context_documents
)
]
for turn_seed_index in turn_seed_indices
]

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.

medium

The closest documents for each turn are currently retrieved sequentially using a list comprehension with await. Since these are independent async calls, they can be executed concurrently using asyncio.gather to improve performance, especially when there are multiple turns.

            import asyncio
            closest_docs_list = await asyncio.gather(*(
                params.knowledge_base.closest_documents(
                    turn_seed_index, self.context_documents
                )
                for turn_seed_index in turn_seed_indices
            ))
            turn_contexts = [
                [doc.content for doc in docs]
                for docs in closest_docs_list
            ]

Comment thread libs/giskard-scan/src/giskard/scan/utils/knowledge_base.py
@pierlj
pierlj force-pushed the feat/complete-quality-scan branch from 31495b2 to d41adad Compare June 25, 2026 16:10
@pierlj pierlj changed the title feat(scan) Complete and reorganize quality scan feat(scan): Complete and reorganize quality scan Jun 25, 2026
Comment thread libs/giskard-checks/tests/builtin/test_contradiction.py Outdated
Comment on lines +20 to +22
"DEFAULT_KNOWLEDGE_BASE_CONTEXT_DOCUMENTS",
"DEFAULT_KNOWLEDGE_BASE_MAX_TURNS",
"DEFAULT_KNOWLEDGE_BASE_SCENARIOS",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might be worth to allow a clean setup of all the DEFAULT_* used in scan.

Maybe using pydantic-settings to allow setting env variables to override GISKARD_SCAN_*?

We can keep it like this and work on this in a separate issue

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's a good point, I would keep it in a separate PR.

kevinmessiaen and others added 5 commits June 30, 2026 07:52
- Extract _document_contents() helper on the base generator, dedup the
  repeated [doc.content for doc in docs] comprehension across base and
  out_of_scope generators
- Thread the embedding matrix through _closest_indices() instead of
  re-fetching it from the cache, removing the hidden cache coupling

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ction

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants