Skip to content

fix(vercel-ai): don't drop gen_ai.system_instructions for message-object system prompts - #26090

Closed
biggdawg320 wants to merge 1 commit into
getsentry:developfrom
biggdawg320:jobscout/26079-vercel-ai-gen-ai-system-instructions-is
Closed

biggdawg320 wants to merge 1 commit into
getsentry:developfrom
biggdawg320:jobscout/26079-vercel-ai-gen-ai-system-instructions-is

Conversation

@biggdawg320

Copy link
Copy Markdown

gen_ai.system_instructions was missing whenever the ai SDK's system/instructions option was passed as a SystemModelMessage object or array instead of a plain string — the documented way to attach providerOptions (e.g. Anthropic prompt caching) to the system prompt. Both the v7 native-channel subscriber and the v4-v6 orchestrion adapter only recognized strings via asString(), 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 narrowing options.system to a string before it reaches that shared logic.

Fixes #26079

Testing

  • Added a test (packages/server-utils/test/integrations/vercel-ai/system-instructions.test.ts) that fails on the current code and passes with this change.
  • The surrounding tests pass: cd packages/server-utils && pnpm exec vitest run test/integrations/vercel-ai

This change was drafted with AI assistance (Claude) and verified against the project's own test suite before submission.

…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
biggdawg320 requested a review from a team as a code owner November 4, 2026 09:04
@biggdawg320
biggdawg320 requested review from andreiborza and mydea and removed request for a team November 4, 2026 09:04
@github-actions github-actions Bot added the external PR from an external contributor label Nov 4, 2026
@andreiborza

Copy link
Copy Markdown
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.

@andreiborza andreiborza closed this Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external PR from an external contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vercel AI: gen_ai.system_instructions is missing when the system prompt is a message object

2 participants