Skip to content

Python: fix(providers): send a single stop string as a list in Gemini, Bedrock, Anthropic and Ollama - #8736

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
anishmehta24:fix/providers-plain-string-stop
Sep 28, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
anishmehta24:fix/providers-plain-string-stop

Conversation

@anishmehta24

Copy link
Copy Markdown
Contributor

Motivation & Context

ChatOptions.stop is typed str | Sequence[str], but four providers pass a single string straight into a field that only takes a list:

  • Gemini: stop_sequences fails GenerateContentConfig validation ("Input should be a valid list").
  • Bedrock: botocore rejects inferenceConfig.stopSequences ("valid types: list, tuple").
  • Anthropic: the request carries stop_sequences: "END"; the API expects an array.
  • Ollama: the request carries options.stop: "END"; Ollama expects a list.

OpenAI and Mistral accept a string, so they're unchanged.

Description & Review Guide

  • What are the major changes? Where each of the four clients maps stop to its provider field, a plain string is wrapped in a one-item list. Lists are passed as before.
  • What is the impact of these changes? options={"stop": "END"} works on these providers instead of failing or sending the wrong type.
  • What do you want reviewers to focus on? I kept it in one PR since it's the same two-line change in each client; happy to split per package if you prefer.

Related Issue

No existing issue.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible

One test per provider for a single stop string (all four fail on main). The gemini, bedrock, anthropic and ollama test suites pass, and the repo's pre-commit checks are clean.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Sep 24, 2026
Merged via the queue into microsoft:main with commit 9acaf82 Sep 28, 2026
50 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — 4c27bcac Deployed Sep 24, 2026 by anishmehta24 via team_check #5247
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants