Repository navigation
fix(vertexai): concatenate anthropic system prompt text parts without commas - #7218
Closed
anjalimishra-0007 wants to merge 1 commit into
Closed
anjalimishra-0007 wants to merge 1 commit into
anjalimishra-0007 wants to merge 1 commit into
Conversation
… commas
In Model Garden Anthropic converters (both v2 and legacy), system message parts were joined using Array.prototype.join() with no argument, which inserts commas between text parts. This causes system prompts with multiple parts (e.g. system instructions combined with schema formatting instructions) to contain stray commas.
Change .join() to .join('') to match Mistral and Genkit Message.text conventions.
Fixes genkit-ai#7167
Signed-off-by: Anjali Mishra <246823347+anjalimishra-0007@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request fixes an issue where multiple system message text parts were joined with commas by changing .join() to .join('') in both the legacy and v2 Anthropic model garden plugins. Corresponding unit tests have been added to verify that system messages are concatenated without commas. I have no additional feedback to provide.
Contributor
3 of 4 tasks
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.
Fixes #7167.
Description
In Model Garden Anthropic converters (
js/plugins/vertexai/src/modelgarden/v2/anthropic.tsandlegacy/anthropic.ts), system message parts were joined usingmsg.content.map((c) => c.text).join(). BecauseArray.prototype.join()defaults to a comma separator when called without arguments, system messages containing multiple parts (such as prompt system instructions combined with schema formatting instructions frominjectInstructions) ended up containing stray commas in the final system prompt sent to Anthropic Claude models.This changes
.join()to.join(''), matching the behavior of Mistral converters (v2/mistral.ts), Ollama (#7124), and GenkitMessage.text.Scenarios Tested
js/plugins/vertexai/tests/modelgarden/v2/anthropic_test.tsjs/plugins/vertexai/tests/modelgarden/legacy/anthropic_test.tsverifying that multi-part system messages are concatenated cleanly without commas.