Skip to content

.Net: Fix GeminiPromptExecutionSettings.Clone dropping Labels and CachedContent - #14194

Open
dfedoryshchev wants to merge 1 commit into
microsoft:mainfrom
dfedoryshchev:fix/gemini-clone-labels-cachedcontent
Open

.Net: Fix GeminiPromptExecutionSettings.Clone dropping Labels and CachedContent#14194
dfedoryshchev wants to merge 1 commit into
microsoft:mainfrom
dfedoryshchev:fix/gemini-clone-labels-cachedcontent

Conversation

@dfedoryshchev

Copy link
Copy Markdown

Motivation and Context

GeminiPromptExecutionSettings.Clone() rebuilds the settings through an object initializer, but two settable, serialized properties are missing from it, so cloning silently drops them:

  • Labels ([JsonPropertyName("labels")])
  • CachedContent ([JsonPropertyName("cached_content")])

Every other serialized property is copied in Clone(); these two are not, so a clone loses the request labels and the explicit-cache reference.

Description

  • Copy Labels (as a new dictionary, matching how ExtensionData/StopSequences are cloned) and CachedContent in Clone().
  • Extend PromptExecutionSettingsCloneWorksAsExpected to set and assert both properties.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the SK Contribution Guidelines
  • The existing tests pass
  • New tests added

Copilot AI review requested due to automatic review settings July 24, 2026 22:50
@dfedoryshchev
dfedoryshchev requested a review from a team as a code owner July 24, 2026 22:50

Copilot AI 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.

Pull request overview

This PR fixes a correctness issue in the .NET Google Gemini connector where GeminiPromptExecutionSettings.Clone() previously dropped two serialized, user-settable properties (Labels and CachedContent), causing cloned settings to lose request metadata and explicit caching references.

Changes:

  • Update GeminiPromptExecutionSettings.Clone() to clone Labels (as a new dictionary) and copy CachedContent.
  • Extend PromptExecutionSettingsCloneWorksAsExpected unit test to set and assert both labels and cached_content survive cloning.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
dotnet/src/Connectors/Connectors.Google/GeminiPromptExecutionSettings.cs Ensures Clone() preserves Labels and CachedContent (previously omitted).
dotnet/src/Connectors/Connectors.Google.UnitTests/GeminiPromptExecutionSettingsTests.cs Adds assertions verifying the new clone behavior for Labels and CachedContent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions 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.

Automated Code Review

Reviewers: 5 | Confidence: 95% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by dfedoryshchev's agents

@dfedoryshchev

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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