@@ -305,6 +305,61 @@ function normalizeMessageProviderOptions(message: CoreMessage): CoreMessage {
305305 } as CoreMessage;
306306 }
307307
308+function stripOpenAIItemIdFromPart(part: unknown): {
309+ part: unknown;
310+ changed: boolean;
311+} {
312+ if (!isRecord(part)) return { part, changed: false };
313+
314+ let changed = false;
315+ const nextPart = { ...part };
316+
317+ const dropItemId = (field: "providerOptions" | "providerMetadata"): void => {
318+ const source = nextPart[field];
319+ if (!isRecord(source)) return;
320+ const openai = source.openai;
321+ if (!isRecord(openai) || !("itemId" in openai)) return;
322+
323+ const nextOpenAI = { ...openai };
324+ delete nextOpenAI.itemId;
325+ nextPart[field] = { ...source, openai: nextOpenAI };
326+ changed = true;
327+ };
328+
329+ dropItemId("providerOptions");
330+ dropItemId("providerMetadata");
331+
332+ return { part: changed ? nextPart : part, changed };
333+}
334+
335+export function stripOpenAIItemIdsFromHistory(
336+ messages: CoreMessage[],
337+ modelString: string,
338+): CoreMessage[] {
339+ if (!isOpenAIGPT(modelString)) return messages;
340+
341+ let mutated = false;
342+ const result = messages.map((message) => {
343+ if (!Array.isArray(message.content)) return message;
344+
345+ let contentMutated = false;
346+ const content = message.content.map((part) => {
347+ const cleaned = stripOpenAIItemIdFromPart(part);
348+ if (cleaned.changed) contentMutated = true;
349+ return cleaned.part;
350+ });
351+
352+ if (!contentMutated) return message;
353+ mutated = true;
354+ return {
355+ ...message,
356+ content: content as CoreMessage["content"],
357+ } as CoreMessage;
358+ });
359+
360+ return mutated ? result : messages;
361+}
362+
308363 /**
309364 * Reads the effective provider-options record for a content part, checking
310365 * both the modern `providerOptions` field and the legacy `providerMetadata`
@@ -469,9 +524,8 @@ export function stripGPTCommentaryFromHistory(
469524 // ─── Main turn function ───────────────────────────────────────────────────────
470525
471526 /**
472- * Returns true when the model string refers to an OpenAI GPT model, which uses
473- * the Responses API and honours the `instructions` provider option as the
474- * authoritative system prompt (rather than a system-role message in `input`).
527+ * Returns true when the model string refers to an OpenAI GPT model routed
528+ * through the OpenAI SDK stack (direct OpenAI or Zen OpenAI).
475529 */
476530 export function isOpenAIGPT(modelString: string): boolean {
477531 const { provider, modelId } = parseModelString(modelString);
@@ -526,11 +580,9 @@ export async function* runTurn(options: {
526580
527581 try {
528582 // OpenAI GPT models use the Responses API (@ai-sdk/openai v3 / ai v6 default),
529- // which honours `instructions` as the authoritative system prompt. Passing it
530- // as a system-role message in `input` works but is treated as a lower-priority
531- // user turn, causing the model to deprioritise the instructions.
532- const useInstructions =
533- systemPrompt !== undefined && isOpenAIGPT(modelString);
583+ // but we keep prompts only in `system` messages for consistency across
584+ // providers and to avoid prompting shape drift on GPT reasoning models.
585+ const useInstructions = false;
534586
535587 const toolCount = Object.keys(toolSet).length;
536588 const thinkingOpts = thinkingEffort
@@ -569,12 +621,20 @@ export async function* runTurn(options: {
569621 logApiEvent("gpt commentary stripped from history", { modelString });
570622 }
571623
624+ const openAIItemIdsStrippedMessages = stripOpenAIItemIdsFromHistory(
625+ gptSanitizedMessages,
626+ modelString,
627+ );
628+ if (openAIItemIdsStrippedMessages !== gptSanitizedMessages) {
629+ logApiEvent("openai item ids stripped from history", { modelString });
630+ }
631+
572632 logApiEvent(
573633 "turn context pre-prune",
574- getMessageDiagnostics(gptSanitizedMessages),
634+ getMessageDiagnostics(openAIItemIdsStrippedMessages),
575635 );
576636 const prunedMessages = applyContextPruning(
577- gptSanitizedMessages,
637+ openAIItemIdsStrippedMessages,
578638 pruningMode,
579639 );
580640 logApiEvent(
@@ -594,16 +654,25 @@ export async function* runTurn(options: {
594654 }
595655
596656 const mergedProviderOptions = {
597- ...(useInstructions
598- ? { openai: { instructions: systemPrompt, store: false } }
599- : {}),
600657 ...(thinkingOpts ?? {}),
601- ...(useInstructions && thinkingOpts?.openai
658+ ...(isOpenAIGPT(modelString)
602659 ? {
603660 openai: {
604- instructions: systemPrompt,
605661 store: false,
606- ...(thinkingOpts.openai as object),
662+ ...(isRecord(thinkingOpts?.openai)
663+ ? (thinkingOpts.openai as object)
664+ : {}),
665+ },
666+ }
667+ : {}),
668+ ...(useInstructions && systemPrompt
669+ ? {
670+ openai: {
671+ ...(isRecord(thinkingOpts?.openai)
672+ ? (thinkingOpts.openai as object)
673+ : {}),
674+ store: false,
675+ instructions: systemPrompt,
607676 },
608677 }
609678 : {}),