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

Commit 6e4a9ea

Browse files
committed
refactor: address PR feedback - simplify docs and improve test assertions
- Remove cache point example from ContentBlock TSDoc - Remove array caching example from SystemPrompt TSDoc - Replace expect.objectContaining with exact object matching in system prompt tests All tests passing (50/50), quality checks passing.
1 parent f350b84 commit 6e4a9ea

2 files changed

Lines changed: 63 additions & 50 deletions

File tree

src/models/__tests__/bedrock.test.ts

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -770,11 +770,16 @@ describe('BedrockModel', () => {
770770

771771
collectEvents(provider.stream(messages, options))
772772

773-
expect(mockConverseStreamCommand).toHaveBeenLastCalledWith(
774-
expect.objectContaining({
775-
system: [{ text: 'You are a helpful assistant' }],
776-
})
777-
)
773+
expect(mockConverseStreamCommand).toHaveBeenLastCalledWith({
774+
modelId: 'global.anthropic.claude-sonnet-4-5-20250929-v1:0',
775+
messages: [
776+
{
777+
role: 'user',
778+
content: [{ text: 'Hello' }],
779+
},
780+
],
781+
system: [{ text: 'You are a helpful assistant' }],
782+
})
778783
})
779784

780785
it('formats string system prompt with cachePrompt config', async () => {
@@ -786,11 +791,16 @@ describe('BedrockModel', () => {
786791

787792
collectEvents(provider.stream(messages, options))
788793

789-
expect(mockConverseStreamCommand).toHaveBeenLastCalledWith(
790-
expect.objectContaining({
791-
system: [{ text: 'You are a helpful assistant' }, { cachePoint: { type: 'default' } }],
792-
})
793-
)
794+
expect(mockConverseStreamCommand).toHaveBeenLastCalledWith({
795+
modelId: 'global.anthropic.claude-sonnet-4-5-20250929-v1:0',
796+
messages: [
797+
{
798+
role: 'user',
799+
content: [{ text: 'Hello' }],
800+
},
801+
],
802+
system: [{ text: 'You are a helpful assistant' }, { cachePoint: { type: 'default' } }],
803+
})
794804
})
795805

796806
it('formats array system prompt with text blocks only', async () => {
@@ -805,11 +815,16 @@ describe('BedrockModel', () => {
805815

806816
collectEvents(provider.stream(messages, options))
807817

808-
expect(mockConverseStreamCommand).toHaveBeenLastCalledWith(
809-
expect.objectContaining({
810-
system: [{ text: 'You are a helpful assistant' }, { text: 'Additional context here' }],
811-
})
812-
)
818+
expect(mockConverseStreamCommand).toHaveBeenLastCalledWith({
819+
modelId: 'global.anthropic.claude-sonnet-4-5-20250929-v1:0',
820+
messages: [
821+
{
822+
role: 'user',
823+
content: [{ text: 'Hello' }],
824+
},
825+
],
826+
system: [{ text: 'You are a helpful assistant' }, { text: 'Additional context here' }],
827+
})
813828
})
814829

815830
it('formats array system prompt with cache points', async () => {
@@ -825,15 +840,20 @@ describe('BedrockModel', () => {
825840

826841
collectEvents(provider.stream(messages, options))
827842

828-
expect(mockConverseStreamCommand).toHaveBeenLastCalledWith(
829-
expect.objectContaining({
830-
system: [
831-
{ text: 'You are a helpful assistant' },
832-
{ text: 'Large context document' },
833-
{ cachePoint: { type: 'default' } },
834-
],
835-
})
836-
)
843+
expect(mockConverseStreamCommand).toHaveBeenLastCalledWith({
844+
modelId: 'global.anthropic.claude-sonnet-4-5-20250929-v1:0',
845+
messages: [
846+
{
847+
role: 'user',
848+
content: [{ text: 'Hello' }],
849+
},
850+
],
851+
system: [
852+
{ text: 'You are a helpful assistant' },
853+
{ text: 'Large context document' },
854+
{ cachePoint: { type: 'default' } },
855+
],
856+
})
837857
})
838858

839859
it('warns when both array system prompt and cachePrompt config are provided', async () => {
@@ -855,11 +875,16 @@ describe('BedrockModel', () => {
855875
)
856876

857877
// Verify array is used as-is (cachePrompt config ignored)
858-
expect(mockConverseStreamCommand).toHaveBeenLastCalledWith(
859-
expect.objectContaining({
860-
system: [{ text: 'You are a helpful assistant' }, { cachePoint: { type: 'default' } }],
861-
})
862-
)
878+
expect(mockConverseStreamCommand).toHaveBeenLastCalledWith({
879+
modelId: 'global.anthropic.claude-sonnet-4-5-20250929-v1:0',
880+
messages: [
881+
{
882+
role: 'user',
883+
content: [{ text: 'Hello' }],
884+
},
885+
],
886+
system: [{ text: 'You are a helpful assistant' }, { cachePoint: { type: 'default' } }],
887+
})
863888

864889
warnSpy.mockRestore()
865890
})
@@ -874,11 +899,15 @@ describe('BedrockModel', () => {
874899
collectEvents(provider.stream(messages, options))
875900

876901
// Empty array should not set system field
877-
expect(mockConverseStreamCommand).toHaveBeenLastCalledWith(
878-
expect.not.objectContaining({
879-
system: expect.anything(),
880-
})
881-
)
902+
expect(mockConverseStreamCommand).toHaveBeenLastCalledWith({
903+
modelId: 'global.anthropic.claude-sonnet-4-5-20250929-v1:0',
904+
messages: [
905+
{
906+
role: 'user',
907+
content: [{ text: 'Hello' }],
908+
},
909+
],
910+
})
882911
})
883912
})
884913
})

src/types/messages.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ export type Role = 'user' | 'assistant'
7575
* text: 'Analyzing the problem...'
7676
* }
7777
*
78-
* // Cache point block
79-
* const cachePointBlock: ContentBlock = {
80-
* type: 'cachePointBlock',
81-
* cacheType: 'default'
82-
* }
83-
*
8478
* // Type-safe handling
8579
* function handleBlock(block: ContentBlock) {
8680
* switch (block.type) {
@@ -96,9 +90,6 @@ export type Role = 'user' | 'assistant'
9690
* case 'reasoningBlock':
9791
* console.log(`Reasoning: ${block.text}`)
9892
* break
99-
* case 'cachePointBlock':
100-
* console.log('Cache point marker')
101-
* break
10293
* }
10394
* }
10495
* ```
@@ -240,13 +231,6 @@ export type StopReason =
240231
* ```typescript
241232
* // Simple string
242233
* const prompt: SystemPrompt = 'You are a helpful assistant'
243-
*
244-
* // Array with caching
245-
* const prompt: SystemPrompt = [
246-
* { type: 'textBlock', text: 'You are a helpful assistant' },
247-
* { type: 'textBlock', text: largeContextDocument },
248-
* { type: 'cachePointBlock', cacheType: 'default' }
249-
* ]
250234
* ```
251235
*/
252236
export type SystemPrompt = string | SystemContentBlock[]

0 commit comments

Comments
 (0)