You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 3, 2026. It is now read-only.
Add new SystemPrompt type support to OpenAI Model provider.
Background
The systemPrompt type was recently updated from a simple string to SystemPrompt = string | SystemContentBlock[] to support advanced features like prompt caching with cache points. The Bedrock model provider has been updated to support this new type, and now the OpenAI model provider needs the same update.
Implementation Requirements
Technical Context
Type Definition: SystemPrompt = string | SystemContentBlock[] (defined in src/types/messages.ts)
SystemContentBlock: TextBlock | CachePointBlock
Reference Implementation: Bedrock model provider (src/models/bedrock.ts, lines 352-372)
Target File: src/models/openai.ts (specifically the _formatRequest method, lines 400-407)
Required Changes
1. Update _formatRequest Method in src/models/openai.ts
The current implementation (lines 400-407) only handles string systemPrompt:
Add warning when CachePointBlock elements are present
Skip adding system message if array is empty or contains no text
Cache Point Handling:
Emit console.warn when cache points are encountered
Warning message: "Cache points are not supported in OpenAI system prompts and will be ignored."
Rationale: OpenAI's Chat Completions API doesn't support prompt caching like Bedrock
2. Add Tests in src/models/__tests__/openai.test.ts
Follow the test patterns established in src/models/__tests__/bedrock.test.ts (lines 774-870):
Required Test Cases:
Array with text blocks only:
Multiple text blocks should be concatenated
Verify system message content is correctly formatted
Array with cache points:
Should warn about unsupported cache points
Should extract and use only text blocks
Verify warning message is logged
Empty array:
Should not add system message to request
Verify no system message in formatted request
Array with single text block:
Should work correctly as valid system prompt
Implementation Approach
Pattern to Follow:
// Pseudo-code based on Bedrock patternif(options?.systemPrompt!==undefined){if(typeofoptions.systemPrompt==='string'){// Existing string handlingif(options.systemPrompt.trim().length>0){request.messages.push({role: 'system',content: options.systemPrompt,})}}elseif(options.systemPrompt.length>0){// New array handlingconsttextBlocks: string[]=[]lethasCachePoints=falsefor(constblockofoptions.systemPrompt){if(block.type==='textBlock'){textBlocks.push(block.text)}elseif(block.type==='cachePointBlock'){hasCachePoints=true}}if(hasCachePoints){console.warn('Cache points are not supported by OpenAI and will be ignored. This feature is specific to AWS Bedrock models.')}if(textBlocks.length>0){request.messages.push({role: 'system',content: textBlocks.join('\n'),})}}}
Overview
Add new SystemPrompt type support to OpenAI Model provider.
Background
The
systemPrompttype was recently updated from a simplestringtoSystemPrompt = string | SystemContentBlock[]to support advanced features like prompt caching with cache points. The Bedrock model provider has been updated to support this new type, and now the OpenAI model provider needs the same update.Implementation Requirements
Technical Context
SystemPrompt = string | SystemContentBlock[](defined insrc/types/messages.ts)TextBlock | CachePointBlocksrc/models/bedrock.ts, lines 352-372)src/models/openai.ts(specifically the_formatRequestmethod, lines 400-407)Required Changes
1. Update
_formatRequestMethod insrc/models/openai.tsThe current implementation (lines 400-407) only handles string systemPrompt:
New Implementation Must:
Handle String SystemPrompt (existing behavior):
Handle Array SystemPrompt (new behavior):
options.systemPromptis an arrayTextBlockelementsCachePointBlockelements are presentCache Point Handling:
console.warnwhen cache points are encountered"Cache points are not supported in OpenAI system prompts and will be ignored."2. Add Tests in
src/models/__tests__/openai.test.tsFollow the test patterns established in
src/models/__tests__/bedrock.test.ts(lines 774-870):Required Test Cases:
Array with text blocks only:
Array with cache points:
Empty array:
Array with single text block:
Implementation Approach
Pattern to Follow:
Files to Modify
src/models/openai.ts: Update_formatRequestmethod (~20-30 lines changed)src/models/__tests__/openai.test.ts: Add 4 new test cases (~100-150 lines)Acceptance Criteria
Backward Compatibility
Estimated Scope
Related Context
src/types/messages.tslines 162-186