Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

Task 90: Add new SystemPrompt type support to OpenAI Model provider Implementation#92

Merged
Unshure merged 2 commits into
mainfrom
agent-tasks/90
Oct 29, 2025
Merged

Task 90: Add new SystemPrompt type support to OpenAI Model provider Implementation#92
Unshure merged 2 commits into
mainfrom
agent-tasks/90

Conversation

@Unshure

@Unshure Unshure commented Oct 29, 2025

Copy link
Copy Markdown
Member

Resolves: #90

Overview

This PR adds SystemPrompt array type support to the OpenAI model provider, bringing it to feature parity with the Bedrock model provider. The implementation allows systemPrompt to be either a string or an array of SystemContentBlock elements.

Changes

  • Updated _formatRequest method to handle both string and array SystemPrompt types
  • Added 4 comprehensive test cases following the Bedrock test pattern
  • Console warning emitted when cache points are present
  • Backward compatibility maintained

Test Results

  • All 166 tests pass (4 new tests added)
  • Coverage: 94.34%
  • TypeScript, ESLint, Prettier all pass

Add support for handling SystemPrompt as both string and array of SystemContentBlock elements in the OpenAI model provider. This brings OpenAI provider feature parity with Bedrock provider.

Changes:
- Update _formatRequest method to handle SystemPrompt array format
- Extract text from TextBlock elements and concatenate with newlines
- Add console warning when CachePointBlock elements are encountered (unsupported by OpenAI)
- Handle empty arrays correctly (no system message added)
- Maintain backward compatibility with string systemPrompt

Tests:
- Add 4 new test cases covering array scenarios
- All 166 tests pass
- Coverage maintained above 80%

Resolves: #90
Comment thread src/models/openai.ts Outdated
Comment thread src/models/openai.ts Outdated
Comment thread src/models/__tests__/openai.test.ts Outdated
@Unshure

Unshure commented Oct 29, 2025

Copy link
Copy Markdown
Member Author

/strands

@github-actions github-actions Bot added the strands-running <strands-managed> Whether or not an agent is currently running label Oct 29, 2025
- Add explicit Array.isArray() check for array type guard
- Change textBlocks.join() to use empty string instead of newline
- Refactor test mock client creation to shared factory function
- Add proper TypeScript type annotations for captured request containers

All 166 tests passing, all quality checks pass.
@github-actions

Copy link
Copy Markdown
Contributor

✅ All Review Feedback Addressed

I've successfully addressed all three review comments:

Changes Made

  1. Array Type Guard (Line 410)

    • Added explicit Array.isArray() check for proper type discrimination
    • Changed from options.systemPrompt.length > 0 to Array.isArray(options.systemPrompt) && options.systemPrompt.length > 0
  2. Text Concatenation (Line 430)

    • Changed from textBlocks.join('\n') to textBlocks.join('')
    • Text blocks are now concatenated without separators
  3. Test Refactoring

    • Created shared createMockClientWithCapture() factory function
    • Refactored all 4 tests to reuse the factory
    • Added proper TypeScript type annotations for captured request containers

Test Results

  • ✅ All 166 tests passing
  • ✅ Coverage: 94.34% (above 80% requirement)
  • ✅ Build successful
  • ✅ Lint passed
  • ✅ Type-check passed
  • ✅ Format-check passed

Commit: 7326481

Ready for re-review! 🚀

@github-actions github-actions Bot removed the strands-running <strands-managed> Whether or not an agent is currently running label Oct 29, 2025
@Unshure Unshure closed this Oct 29, 2025
@Unshure Unshure reopened this Oct 29, 2025
Comment thread src/models/openai.ts
@Unshure Unshure merged commit 9f983a1 into main Oct 29, 2025
11 checks passed
@Unshure Unshure deleted the agent-tasks/90 branch October 29, 2025 18:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add new SystemPrompt type support to OpenAI Model provider

3 participants