Repository navigation
fix(vercel-ai): don't drop gen_ai.system_instructions for message-object system prompts - #26090
Closed
biggdawg320 wants to merge 1 commit into
Closed
biggdawg320 wants to merge 1 commit into
biggdawg320 wants to merge 1 commit into
Conversation
…m prompts
The `ai` SDK's `system`/`instructions` option accepts a `string`, a
`SystemModelMessage`, or an array of them — the message form is how a
caller attaches `providerOptions` to the system prompt (e.g. Anthropic
prompt caching). Both the v7 native-channel subscriber and the v4-v6
orchestrion adapter only handled the string case, via `asString()`, so
`gen_ai.system_instructions` was silently dropped whenever the system
prompt was a message object or array.
Add a `systemInstructionEntries` helper in the shared channel core that
normalizes all three shapes into the `[{ type: 'text', content }]`
entries the attribute expects, and stop the orchestrion adapter from
narrowing `options.system` to a string before it reaches that core.
Co-Authored-By: Claude <noreply@anthropic.com>
biggdawg320
requested review from
andreiborza and
mydea
and removed request for
a team
November 4, 2026 09:04
Member
|
Hi, thank you for your interest in contributing to our SDKs. We are closing this PR because it does not link to an issue where a maintainer gave a go-ahead. See our guidelines for external contributors. If you want to continue with this change, find or open an issue and describe the problem and your proposed change. After a maintainer gives a go-ahead, we can reopen this PR or you can open a new one that links the issue. |
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.
gen_ai.system_instructionswas missing whenever theaiSDK'ssystem/instructionsoption was passed as aSystemModelMessageobject or array instead of a plain string — the documented way to attachproviderOptions(e.g. Anthropic prompt caching) to the system prompt. Both the v7 native-channel subscriber and the v4-v6 orchestrion adapter only recognized strings viaasString(), so the object/array form was silently discarded. This adds a small helper that normalizes string, single-message, and message-array forms into the[{ type: 'text', content }]shape the attribute expects, and stops the orchestrion adapter from narrowingoptions.systemto a string before it reaches that shared logic.Fixes #26079
Testing
packages/server-utils/test/integrations/vercel-ai/system-instructions.test.ts) that fails on the current code and passes with this change.cd packages/server-utils && pnpm exec vitest run test/integrations/vercel-aiThis change was drafted with AI assistance (Claude) and verified against the project's own test suite before submission.