Fixes #250 - Dotnet SDK Validate Session Config Model#378
Open
john-mckillip wants to merge 4 commits intogithub:mainfrom
Open
Fixes #250 - Dotnet SDK Validate Session Config Model#378john-mckillip wants to merge 4 commits intogithub:mainfrom
john-mckillip wants to merge 4 commits intogithub:mainfrom
Conversation
Validate that SessionConfig.Model is a valid model name before creating a session. When an invalid model is specified, throw an ArgumentException with the invalid model name and list of available models. Fixes github#250
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds model validation to the .NET SDK's CreateSessionAsync method to ensure that only valid model IDs are used when creating sessions. The implementation throws an ArgumentException with a helpful error message listing available models when an invalid model is specified.
Changes:
- Added validation logic in
Client.csto verify the model ID exists in the list of available models before creating a session - Updated existing test to use a valid model name (
claude-sonnet-4.5) instead of a placeholder - Added new test to verify that invalid model names trigger an
ArgumentExceptionwith appropriate error details
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| dotnet/src/Client.cs | Implements model validation by checking the provided model against available models and throwing ArgumentException if invalid |
| dotnet/test/SessionTests.cs | Updates test with valid model name and adds new test case for invalid model validation |
…larifying the minimal performance overhead
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves model validation when creating Copilot sessions and enhances test coverage to ensure invalid models are handled correctly. The main changes focus on validating the provided model ID and updating tests to reflect this new behavior.
Model validation improvements:
Client.csto check if the specifiedModelinSessionConfigexists among the available models. If the model is invalid, anArgumentExceptionis thrown with a clear error message.Test updates:
SessionTests.csto use a valid model name (claude-sonnet-4.5) instead of a placeholder.CreateSessionAsyncthrows anArgumentExceptionwhen called with an invalid model name, and that the error message contains relevant details.