Description
session.streamResponse(to:generating:) with ClaudeLanguageModel never yields partial snapshots. The for try await loop receives exactly one element containing the complete response, after the full generation time. Same behavior on the Simulator and on a physical device. With SystemLanguageModel, the same code streams partials as expected.
Environment
- ClaudeForFoundationModels 0.1.1
- Xcode 27 beta, iOS 27 beta (Simulator and device)
- Model: .sonnet4_6, auth: .apiKey
Minimal reproduction
import FoundationModels
import ClaudeForFoundationModels
@Generable
struct Ideas: Equatable {
@Guide(description: "Gift ideas", .count(5))
var ideas: [String]
}
let model = ClaudeLanguageModel(
name: .sonnet4_6,
auth: .apiKey("YOUR_API_KEY")
)
let session = LanguageModelSession(model: model)
var snapshots = 0
let stream = session.streamResponse(
to: "Suggest gift ideas for a sci-fi fan.",
generating: Ideas.self
)
for try await partial in stream {
snapshots += 1
print("snapshot \(snapshots):", partial.content)
}
print("total snapshots:", snapshots) // 1 — arrives only when generation completes
Expected
Multiple cumulative PartiallyGenerated snapshots as content streams in (as with SystemLanguageModel).
Actual
A single snapshot with the complete result, delivered at the end.
Notes
I'm not sure the issue related to the framework or to Foundation Models, but maybe you know the solution to fix it. Thanks!
Description
session.streamResponse(to:generating:)withClaudeLanguageModelnever yields partial snapshots. The for try await loop receives exactly one element containing the complete response, after the full generation time. Same behavior on the Simulator and on a physical device. WithSystemLanguageModel, the same code streams partials as expected.Environment
Minimal reproduction
Expected
Multiple cumulative PartiallyGenerated snapshots as content streams in (as with SystemLanguageModel).
Actual
A single snapshot with the complete result, delivered at the end.
Notes
I'm not sure the issue related to the framework or to Foundation Models, but maybe you know the solution to fix it. Thanks!