Skip to content

Commit 8dd704d

Browse files
committed
fix: resolve compile TS2532 and e2e glm-5-turbo max_tokens assertion
- Fix TS2532 'Object is possibly undefined' by extracting array element to a local variable before accessing .maxTokens - Update glm-5-turbo e2e expected max_tokens from 40000 to 40551 (Math.ceil(202752 * 0.2) = 40551, matching actual context window)
1 parent 084cb0a commit 8dd704d

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

apps/vscode-e2e/src/suite/providers/zai.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ function installZAiFetchInterceptor(
7676

7777
return () => {
7878
globalThis.fetch = original
79-
if (capture && capturedRequests.length > 0) {
80-
capture.maxTokens = capturedRequests[capturedRequests.length - 1].maxTokens
79+
const lastCaptured = capturedRequests[capturedRequests.length - 1]
80+
if (capture && lastCaptured) {
81+
capture.maxTokens = lastCaptured.maxTokens
8182
}
8283
}
8384
}
@@ -281,10 +282,11 @@ suite("Z.ai GLM provider", function () {
281282

282283
// Verify max_tokens uses the restored default clamp (20% of context window)
283284
// unless the user explicitly overrides it via modelMaxTokens.
285+
const expectedMaxTokens = 40_551 // Math.ceil(202_752 * 0.2) for glm-5-turbo
284286
assert.strictEqual(
285287
capturedMaxTokens,
286-
40_000,
287-
`max_tokens should default to the glm-5-turbo clamp (40_000) but was ${capturedMaxTokens}`,
288+
expectedMaxTokens,
289+
`max_tokens should default to the glm-5-turbo clamp (40_551) but was ${capturedMaxTokens}`,
288290
)
289291
})
290292
})

0 commit comments

Comments
 (0)