Skip to content

Commit e4a0c1b

Browse files
committed
fix(foundation-models): declare contextWindowSize nil to reflect missing usage reporting
1 parent 9552dbc commit e4a0c1b

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

Sources/AgentRunKitFoundationModels/FoundationModelsClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/// An LLM client that runs on Apple's on-device foundation model.
88
@available(macOS 26, iOS 26, *)
99
public struct FoundationModelsClient<C: ToolContext>: LLMClient, Sendable {
10-
public let contextWindowSize: Int? = 4096
10+
public let contextWindowSize: Int? = nil
1111

1212
private let tools: [any AnyTool<C>]
1313
private let context: C

Tests/AgentRunKitFoundationModelsTests/FoundationModelsClientTests.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,26 @@
99
@Test func contextWindowSize() {
1010
guard #available(macOS 26, iOS 26, *) else { return }
1111
let client = FoundationModelsClient<EmptyContext>(context: EmptyContext())
12-
#expect(client.contextWindowSize == 4096)
12+
#expect(client.contextWindowSize == nil)
13+
}
14+
15+
@Test func contextBudgetConfigurationThrowsBecauseWindowSizeIsNil() async {
16+
guard #available(macOS 26, iOS 26, *) else { return }
17+
let client = FoundationModelsClient<EmptyContext>(context: EmptyContext())
18+
let agent = Agent<EmptyContext>(
19+
client: client,
20+
tools: [],
21+
configuration: AgentConfiguration(
22+
contextBudget: ContextBudgetConfig(enableVisibility: true)
23+
)
24+
)
25+
26+
await #expect(throws: AgentError.contextBudgetWindowSizeUnavailable) {
27+
_ = try await agent.run(userMessage: "go", context: EmptyContext())
28+
}
29+
await #expect(throws: AgentError.contextBudgetWindowSizeUnavailable) {
30+
for try await _ in agent.stream(userMessage: "go", context: EmptyContext()) {}
31+
}
1332
}
1433

1534
@Test func responseFormatThrows() async {

0 commit comments

Comments
 (0)