@@ -6,6 +6,11 @@ private let apiKey = ProcessInfo.processInfo.environment["ANTHROPIC_API_KEY"] ??
66private let hasAPIKey = !apiKey. isEmpty
77private let model = ProcessInfo . processInfo. environment [ " SMOKE_ANTHROPIC_MODEL " ] ?? " claude-sonnet-4-6 "
88
9+ private let cachingSystemPrompt = String (
10+ repeating: " You are a helpful Swift programming assistant. Follow best practices. " ,
11+ count: 150
12+ )
13+
914@Suite ( . enabled( if: hasAPIKey, " Requires ANTHROPIC_API_KEY environment variable " ) )
1015struct AnthropicSmokeTests {
1116 let client = AnthropicClient ( apiKey: apiKey, model: model, maxTokens: 1024 )
@@ -46,6 +51,45 @@ struct AnthropicSmokeTests {
4651 try await assertSmokeStreamingTokenUsage ( client: client)
4752 }
4853
54+ @Test func chatStreamWithTools( ) async throws {
55+ try await assertSmokeChatStreamWithTools ( client: client)
56+ }
57+
58+ @Test func cachingEnabled( ) async throws {
59+ let cachingClient = AnthropicClient (
60+ apiKey: apiKey,
61+ model: model,
62+ maxTokens: 1024 ,
63+ cachingEnabled: true
64+ )
65+
66+ let messages : [ ChatMessage ] = [
67+ . system( cachingSystemPrompt) ,
68+ . user( " What is Swift? " ) ,
69+ ]
70+
71+ let response1 = try await cachingClient. generate ( messages: messages, tools: [ smokeWeatherTool] )
72+ let usage1 = response1. tokenUsage
73+ #expect( usage1 != nil )
74+ #expect( ( usage1? . cacheWrite ?? 0 ) > 0 )
75+
76+ let response2 = try await cachingClient. generate ( messages: messages, tools: [ smokeWeatherTool] )
77+ let usage2 = response2. tokenUsage
78+ #expect( usage2 != nil )
79+ #expect( ( usage2? . cacheRead ?? 0 ) > 0 )
80+ }
81+
82+ @Test func nonInterleavedReasoning( ) async throws {
83+ let nonInterleavedClient = AnthropicClient (
84+ apiKey: apiKey,
85+ model: model,
86+ maxTokens: 16384 ,
87+ reasoningConfig: . budget( 4096 ) ,
88+ interleavedThinking: false
89+ )
90+ try await assertSmokeReasoningGenerate ( client: nonInterleavedClient)
91+ }
92+
4993 @Test func reasoningStream( ) async throws {
5094 let thinkingClient = AnthropicClient (
5195 apiKey: apiKey,
0 commit comments