Skip to content

feat: [OSS-20] Add support to annotations in scenario/trace#2268

Merged
mattbit merged 5 commits intomainfrom
feature/oss-20-support-annotations-in-scenariotrace
Feb 26, 2026
Merged

feat: [OSS-20] Add support to annotations in scenario/trace#2268
mattbit merged 5 commits intomainfrom
feature/oss-20-support-annotations-in-scenariotrace

Conversation

@henchaves
Copy link
Member

@henchaves henchaves commented Feb 24, 2026

Description

  • Added annotations: dict[str, Any] to Scenario and Trace
  • Added with_annotations method to scenario builder API

Related Issue

#2267

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

@linear
Copy link

linear bot commented Feb 24, 2026

@gemini-code-assist
Copy link

Summary of Changes

Hello @henchaves, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new feature that allows users to attach arbitrary key-value annotations to Scenario and Trace objects. This provides a mechanism for sharing contextual metadata throughout the lifecycle of a scenario execution, making it accessible within trace objects and subsequent checks. The change enhances the flexibility and expressiveness of scenarios by enabling the inclusion of shared, read-only information.

Highlights

  • Scenario Annotation Support: Added an annotations field to the Scenario class, allowing for the storage of scenario-level metadata.
  • Trace Annotation Integration: Introduced an annotations field and a with_annotations method to the Trace class, enabling shared, immutable context to be carried with the trace.
  • ScenarioBuilder Enhancements: Enhanced ScenarioBuilder to include an annotations field, a with_annotations method, and updated its build method to pass annotations to the Scenario constructor.
  • Annotation Propagation: Modified the scenario execution runner to ensure that Scenario annotations are correctly propagated and applied to the Trace object during execution.
  • New Unit Tests: Included new unit tests to verify the correct propagation and accessibility of annotations within traces and their usage in checks.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • libs/giskard-checks/src/giskard/checks/core/scenario.py
    • Imported Any from typing.
    • Added annotations: dict[str, Any] field to the Scenario class with a default empty dictionary.
  • libs/giskard-checks/src/giskard/checks/core/trace.py
    • Added annotations: dict[str, Any] field to the Trace class with a default empty dictionary.
    • Implemented with_annotations method to return a new Trace instance with updated annotations.
  • libs/giskard-checks/src/giskard/checks/scenarios/builder.py
    • Imported Any from typing.
    • Added annotations: dict[str, Any] field to ScenarioBuilder with a default empty dictionary.
    • Added with_annotations method to ScenarioBuilder to set scenario-level annotations.
    • Modified the build method to pass annotations to the Scenario constructor.
    • Updated the scenario factory function to accept an annotations argument and pass it to ScenarioBuilder.
  • libs/giskard-checks/src/giskard/checks/scenarios/runner.py
    • Modified the run function to call trace.with_annotations(scenario.annotations) to propagate annotations.
  • libs/giskard-checks/tests/core/test_scenario.py
    • Imported Scenario and from_fn.
    • Added test_scenario_annotations_propagated_to_trace to verify annotation propagation.
    • Added test_scenario_builder_with_annotations_and_equals_check to test annotation usage within checks.
Activity
  • No human activity (comments, reviews, etc.) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@henchaves henchaves self-assigned this Feb 24, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces support for annotations in Scenario and Trace objects, allowing for shared, read-only context during scenario execution. This is a good addition for providing extra metadata. The changes are well-implemented, including updates to the ScenarioBuilder and ScenarioRunner to handle these new annotations. The new test cases adequately cover the functionality of annotations propagation and usage within checks.

Copy link
Member

@mattbit mattbit left a comment

Choose a reason for hiding this comment

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

Would do a little clean up of the with_annotation setter. I would rather keep these things explicit on the trace object since it's a frozen object.

@henchaves henchaves requested a review from mattbit February 26, 2026 08:19
@mattbit mattbit enabled auto-merge (squash) February 26, 2026 12:12
@mattbit mattbit merged commit a1f90fc into main Feb 26, 2026
17 checks passed
@mattbit mattbit deleted the feature/oss-20-support-annotations-in-scenariotrace branch February 26, 2026 12:13
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