fix(test): tolerate cache probes with usage-only output · openclaw/openclaw@4199258
steipete
·
2026-05-15
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -157,37 +157,37 @@ describe("live cache regression runner", () => {
|
157 | 157 | ).toBe(256); |
158 | 158 | }); |
159 | 159 | |
160 | | -it("accepts empty OpenAI cache probe text only when usage is observable", () => { |
| 160 | +it("accepts empty cache probe text only when usage is observable", () => { |
161 | 161 | expect( |
162 | | -__testing.shouldAcceptEmptyOpenAICacheProbe({ |
| 162 | +__testing.shouldAcceptEmptyCacheProbe({ |
163 | 163 | providerTag: "openai", |
164 | 164 | text: "", |
165 | 165 | usage: { input: 5_000 }, |
166 | 166 | }), |
167 | 167 | ).toBe(true); |
168 | 168 | expect( |
169 | | -__testing.shouldAcceptEmptyOpenAICacheProbe({ |
| 169 | +__testing.shouldAcceptEmptyCacheProbe({ |
170 | 170 | providerTag: "openai", |
171 | 171 | text: "", |
172 | 172 | usage: { cacheRead: 4_608 }, |
173 | 173 | }), |
174 | 174 | ).toBe(true); |
175 | 175 | expect( |
176 | | -__testing.shouldAcceptEmptyOpenAICacheProbe({ |
| 176 | +__testing.shouldAcceptEmptyCacheProbe({ |
177 | 177 | providerTag: "openai", |
178 | 178 | text: "wrong", |
179 | 179 | usage: { input: 5_000 }, |
180 | 180 | }), |
181 | 181 | ).toBe(false); |
182 | 182 | expect( |
183 | | -__testing.shouldAcceptEmptyOpenAICacheProbe({ |
| 183 | +__testing.shouldAcceptEmptyCacheProbe({ |
184 | 184 | providerTag: "anthropic", |
185 | 185 | text: "", |
186 | 186 | usage: { input: 5_000 }, |
187 | 187 | }), |
188 | | -).toBe(false); |
| 188 | +).toBe(true); |
189 | 189 | expect( |
190 | | -__testing.shouldAcceptEmptyOpenAICacheProbe({ |
| 190 | +__testing.shouldAcceptEmptyCacheProbe({ |
191 | 191 | providerTag: "openai", |
192 | 192 | text: "", |
193 | 193 | usage: {}, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -166,12 +166,12 @@ function resolveCacheProbeMaxTokens(params: {
|
166 | 166 | return Math.max(requested, CACHE_PROBE_MIN_MAX_TOKENS); |
167 | 167 | } |
168 | 168 | |
169 | | -function shouldAcceptEmptyOpenAICacheProbe(params: { |
| 169 | +function shouldAcceptEmptyCacheProbe(params: { |
170 | 170 | providerTag: "anthropic" | "openai"; |
171 | 171 | text: string; |
172 | 172 | usage: CacheUsage; |
173 | 173 | }): boolean { |
174 | | -if (params.providerTag !== "openai" || params.text.trim().length > 0) { |
| 174 | +if (params.text.trim().length > 0) { |
175 | 175 | return false; |
176 | 176 | } |
177 | 177 | return ( |
@@ -283,7 +283,7 @@ async function completeCacheProbe(params: {
|
283 | 283 | const text = extractAssistantText(response); |
284 | 284 | const usage = normalizeCacheUsage(response.usage); |
285 | 285 | if ( |
286 | | -shouldAcceptEmptyOpenAICacheProbe({ |
| 286 | +shouldAcceptEmptyCacheProbe({ |
287 | 287 | providerTag: params.providerTag, |
288 | 288 | text, |
289 | 289 | usage, |
@@ -679,7 +679,7 @@ export const __testing = {
|
679 | 679 | evaluateAgainstBaseline, |
680 | 680 | isAnthropicAccountDrift, |
681 | 681 | resolveCacheProbeMaxTokens, |
682 | | -shouldAcceptEmptyOpenAICacheProbe, |
| 682 | +shouldAcceptEmptyCacheProbe, |
683 | 683 | shouldRetryCacheProbeText, |
684 | 684 | shouldRetryBaselineFindings, |
685 | 685 | }; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。