@@ -43,7 +43,7 @@ func setUpTestWithTransport(rr *httprr.RecordReplay) (*bedrockruntime.Client, er
4343 return client , nil
4444}
4545
46- func TestAmazonOutputConverseAPI (t * testing.T ) {
46+ func TestAmazonOutputConverseAPI (t * testing.T ) { //nolint:funlen
4747 ctx := t .Context ()
4848
4949 httprr .SkipIfNoCredentialsAndRecordingMissing (t , "AWS_ACCESS_KEY_ID" )
@@ -1519,14 +1519,13 @@ func TestAmazonTextResponseWithThinkingConverseAPI(t *testing.T) {
15191519 t .Fatal (err )
15201520 }
15211521
1522- messages := []llms.MessageContent {
1523- {
1524- Role : llms .ChatMessageTypeHuman ,
1525- Parts : []llms.ContentPart {
1526- llms .TextPart ("Solve: If x + 5 = 12, what is x?" ),
1527- },
1522+ messages := make ([]llms.MessageContent , 0 , 3 )
1523+ messages = append (messages , llms.MessageContent {
1524+ Role : llms .ChatMessageTypeHuman ,
1525+ Parts : []llms.ContentPart {
1526+ llms .TextPart ("Solve: If x + 5 = 12, what is x?" ),
15281527 },
1529- }
1528+ })
15301529
15311530 // Request with thinking
15321531 resp , err := llm .GenerateContent (ctx , messages ,
@@ -1603,14 +1602,13 @@ func TestAmazonTextResponseWithThinkingLegacyAPI(t *testing.T) {
16031602 t .Fatal (err )
16041603 }
16051604
1606- messages := []llms.MessageContent {
1607- {
1608- Role : llms .ChatMessageTypeHuman ,
1609- Parts : []llms.ContentPart {
1610- llms .TextPart ("Solve: If x + 5 = 12, what is x?" ),
1611- },
1605+ messages := make ([]llms.MessageContent , 0 , 3 )
1606+ messages = append (messages , llms.MessageContent {
1607+ Role : llms .ChatMessageTypeHuman ,
1608+ Parts : []llms.ContentPart {
1609+ llms .TextPart ("Solve: If x + 5 = 12, what is x?" ),
16121610 },
1613- }
1611+ })
16141612
16151613 // Request with thinking
16161614 resp , err := llm .GenerateContent (ctx , messages ,
@@ -1666,7 +1664,7 @@ func TestAmazonTextResponseWithThinkingLegacyAPI(t *testing.T) {
16661664}
16671665
16681666// TestAmazonSingleToolCallWithThinkingConverseAPI tests single tool call with thinking
1669- func TestAmazonSingleToolCallWithThinkingConverseAPI (t * testing.T ) {
1667+ func TestAmazonSingleToolCallWithThinkingConverseAPI (t * testing.T ) { //nolint:funlen
16701668 ctx := t .Context ()
16711669
16721670 httprr .SkipIfNoCredentialsAndRecordingMissing (t , "AWS_ACCESS_KEY_ID" )
@@ -1702,12 +1700,11 @@ func TestAmazonSingleToolCallWithThinkingConverseAPI(t *testing.T) {
17021700 },
17031701 }}
17041702
1705- messages := []llms.MessageContent {
1706- {
1707- Role : llms .ChatMessageTypeHuman ,
1708- Parts : []llms.ContentPart {llms .TextPart ("What's the weather in Boston?" )},
1709- },
1710- }
1703+ messages := make ([]llms.MessageContent , 0 , 3 )
1704+ messages = append (messages , llms.MessageContent {
1705+ Role : llms .ChatMessageTypeHuman ,
1706+ Parts : []llms.ContentPart {llms .TextPart ("What's the weather in Boston?" )},
1707+ })
17111708
17121709 resp , err := llm .GenerateContent (ctx , messages ,
17131710 llms .WithModel (bedrock .ModelAnthropicClaudeSonnet45 ),
@@ -1769,7 +1766,7 @@ func TestAmazonSingleToolCallWithThinkingConverseAPI(t *testing.T) {
17691766}
17701767
17711768// TestAmazonSequentialToolCallsWithThinkingConverseAPI tests sequential tool calls with thinking
1772- func TestAmazonSequentialToolCallsWithThinkingConverseAPI (t * testing.T ) {
1769+ func TestAmazonSequentialToolCallsWithThinkingConverseAPI (t * testing.T ) { //nolint:funlen
17731770 ctx := t .Context ()
17741771
17751772 httprr .SkipIfNoCredentialsAndRecordingMissing (t , "AWS_ACCESS_KEY_ID" )
@@ -1807,14 +1804,13 @@ func TestAmazonSequentialToolCallsWithThinkingConverseAPI(t *testing.T) {
18071804 },
18081805 }
18091806
1810- messages := []llms.MessageContent {
1811- {
1812- Role : llms .ChatMessageTypeHuman ,
1813- Parts : []llms.ContentPart {
1814- llms .TextPart ("Calculate (5 + 3) and then multiply by 2" ),
1815- },
1807+ messages := make ([]llms.MessageContent , 0 , 3 )
1808+ messages = append (messages , llms.MessageContent {
1809+ Role : llms .ChatMessageTypeHuman ,
1810+ Parts : []llms.ContentPart {
1811+ llms .TextPart ("Calculate (5 + 3) and then multiply by 2" ),
18161812 },
1817- }
1813+ })
18181814
18191815 // First call
18201816 resp1 , err := llm .GenerateContent (ctx , messages ,
@@ -1960,7 +1956,7 @@ func TestAmazonTextResponseWithThinkingStreamingConverseAPI(t *testing.T) {
19601956// Turn 1: CacheCreation > 0 (conversation history cached)
19611957// Turn 2: CacheRead > 0 (previous turn read from cache), new content added to cache
19621958// Turn 3+: Cache continues to be used and extended
1963- func TestAmazonMultiTurnCachingWithToolsLegacyAPI (t * testing.T ) {
1959+ func TestAmazonMultiTurnCachingWithToolsLegacyAPI (t * testing.T ) { //nolint:funlen
19641960 ctx := t .Context ()
19651961
19661962 httprr .SkipIfNoCredentialsAndRecordingMissing (t , "AWS_ACCESS_KEY_ID" )
@@ -2190,7 +2186,7 @@ func TestAmazonMultiTurnCachingWithToolsLegacyAPI(t *testing.T) {
21902186// Expected behavior:
21912187// Turn 3: CacheCreation > 0 (conversation history with cachePoint)
21922188// Turn 4: CacheRead > 0 (previous context read from cache)
2193- func TestAmazonMultiTurnCachingWithToolsConverseAPI (t * testing.T ) {
2189+ func TestAmazonMultiTurnCachingWithToolsConverseAPI (t * testing.T ) { //nolint:funlen
21942190 ctx := t .Context ()
21952191
21962192 httprr .SkipIfNoCredentialsAndRecordingMissing (t , "AWS_ACCESS_KEY_ID" )
@@ -2252,16 +2248,17 @@ func TestAmazonMultiTurnCachingWithToolsConverseAPI(t *testing.T) {
22522248 systemPrompt := "BedrockConverseCache-v1: " + strings .Repeat ("You are a helpful assistant with access to weather and flight booking capabilities. " , 15 )
22532249
22542250 // Turn 1: Initial request with system prompt
2255- messages := []llms.MessageContent {
2256- {
2251+ messages := make ([]llms.MessageContent , 0 , 8 )
2252+ messages = append (messages ,
2253+ llms.MessageContent {
22572254 Role : llms .ChatMessageTypeSystem ,
22582255 Parts : []llms.ContentPart {llms .TextPart (systemPrompt )},
22592256 },
2260- {
2257+ llms. MessageContent {
22612258 Role : llms .ChatMessageTypeHuman ,
22622259 Parts : []llms.ContentPart {llms .TextPart ("What's the weather in Boston?" )},
22632260 },
2264- }
2261+ )
22652262
22662263 resp1 , err := llm .GenerateContent (ctx , messages ,
22672264 llms .WithModel (bedrock .ModelAnthropicClaudeSonnet45 ),
@@ -2418,7 +2415,7 @@ func TestAmazonMultiTurnCachingWithToolsConverseAPI(t *testing.T) {
24182415// - Cache points are automatically added to conversation history
24192416// - No manual bedrock.WithCacheControl() wrapper needed
24202417// - Cache metrics show cache utilization
2421- func TestAmazonAutomaticCachingLegacyAPI (t * testing.T ) {
2418+ func TestAmazonAutomaticCachingLegacyAPI (t * testing.T ) { //nolint:funlen
24222419 ctx := t .Context ()
24232420
24242421 httprr .SkipIfNoCredentialsAndRecordingMissing (t , "AWS_ACCESS_KEY_ID" )
@@ -2468,16 +2465,17 @@ func TestAmazonAutomaticCachingLegacyAPI(t *testing.T) {
24682465 systemPrompt := "BedrockAutoCacheTest-v1: " + strings .Repeat ("You are a helpful assistant with access to weather capabilities. " , 15 )
24692466
24702467 // Turn 1: Initial request with system prompt
2471- messages := []llms.MessageContent {
2472- {
2468+ messages := make ([]llms.MessageContent , 0 , 6 )
2469+ messages = append (messages ,
2470+ llms.MessageContent {
24732471 Role : llms .ChatMessageTypeSystem ,
24742472 Parts : []llms.ContentPart {llms .TextPart (systemPrompt )},
24752473 },
2476- {
2474+ llms. MessageContent {
24772475 Role : llms .ChatMessageTypeHuman ,
24782476 Parts : []llms.ContentPart {llms .TextPart ("What's the weather in Boston?" )},
24792477 },
2480- }
2478+ )
24812479
24822480 resp1 , err := llm .GenerateContent (ctx , messages ,
24832481 llms .WithModel (bedrock .ModelAnthropicClaudeSonnet45 ),
@@ -2589,7 +2587,7 @@ func TestAmazonAutomaticCachingLegacyAPI(t *testing.T) {
25892587
25902588// TestAmazonAutomaticCachingConverseAPI tests automatic prompt caching with Converse API.
25912589// This validates that WithAutomaticCaching() works correctly with Converse API.
2592- func TestAmazonAutomaticCachingConverseAPI (t * testing.T ) {
2590+ func TestAmazonAutomaticCachingConverseAPI (t * testing.T ) { //nolint:funlen
25932591 ctx := t .Context ()
25942592
25952593 httprr .SkipIfNoCredentialsAndRecordingMissing (t , "AWS_ACCESS_KEY_ID" )
@@ -2640,16 +2638,17 @@ func TestAmazonAutomaticCachingConverseAPI(t *testing.T) {
26402638 systemPrompt := "BedrockConverseAutoCacheTest-v1: " + strings .Repeat ("You are a helpful assistant with access to weather capabilities. " , 15 )
26412639
26422640 // Turn 1: Initial request with system prompt
2643- messages := []llms.MessageContent {
2644- {
2641+ messages := make ([]llms.MessageContent , 0 , 6 )
2642+ messages = append (messages ,
2643+ llms.MessageContent {
26452644 Role : llms .ChatMessageTypeSystem ,
26462645 Parts : []llms.ContentPart {llms .TextPart (systemPrompt )},
26472646 },
2648- {
2647+ llms. MessageContent {
26492648 Role : llms .ChatMessageTypeHuman ,
26502649 Parts : []llms.ContentPart {llms .TextPart ("What's the weather in Boston?" )},
26512650 },
2652- }
2651+ )
26532652
26542653 resp1 , err := llm .GenerateContent (ctx , messages ,
26552654 llms .WithModel (bedrock .ModelAnthropicClaudeSonnet45 ),
0 commit comments