Skip to content

fix(search): reuse Gemini and Kimi caches for equivalent queries - #126798

Merged
steipete merged 1 commit into
mainfrom
codex/autoqa-provider-search-cache-20260820
Aug 20, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/autoqa-provider-search-cache-20260820

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Gemini and Kimi web searches repeated billable provider requests for the same query when callers supplied different result counts, even though both providers ignore that parameter. Gemini searches using relative freshness or open-ended dates also missed their documented cache whenever the clock advanced.

Why This Change Was Made

Keep count validation but remove ignored count settings from each provider-owned cache identity, matching the existing Grok provider. Carry Gemini's normalized freshness and explicit date bounds into the cache key while preserving the real, current timestamps sent to Google Search grounding. Model, endpoint, operator-header partitioning, cache TTL, and public plugin SDK contracts stay unchanged.

User Impact

Equivalent Gemini and Kimi searches now reuse the configured search cache, reducing duplicate paid requests and latency. Distinct Gemini freshness windows, date ranges, models, endpoints, and operator headers remain isolated, and invalid result counts continue to fail visibly.

Evidence

  • Regression-first proof: before the fix, Gemini and Kimi each made three provider requests for one identical query with count 1, count 10, and no count; both now make exactly one.
  • Regression-first proof: Gemini relative freshness and open-ended date searches both missed cache after the clock advanced two seconds; equivalent normalized filters now reuse cache while genuinely distinct filters still trigger a fresh request.
  • Exact head: 4e8a75ea3988a7fc2175ba113d171bb3f6964ed1.
  • PNPM_CONFIG_MODULES_DIR=/Users/steipete/Projects/openclaw/node_modules OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_FS_MODULE_CACHE=0 NODE_DISABLE_COMPILE_CACHE=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-providers.config.ts --configLoader runner extensions/google/web-search-provider.test.ts extensions/moonshot/src/kimi-web-search-provider.test.ts extensions/moonshot/index.test.ts — 3 files, 81 tests passed, including the already-landed Kimi unfinished-answer/retry regression.
  • node --import tsx scripts/check-assertion-safety-ratchet.mts — passed.
  • node --import tsx scripts/check-max-lines-ratchet.mts — passed.
  • node_modules/.bin/oxfmt --check extensions/google/src/gemini-web-search-provider.runtime.ts extensions/google/web-search-provider.test.ts extensions/moonshot/src/kimi-web-search-provider.runtime.ts extensions/moonshot/src/kimi-web-search-provider.test.ts — passed.
  • Fresh authenticated isolated Codex branch autoreview: clean, no actionable findings; TruffleHog scan clean.
  • Production code: +21/-30 (net -9); regression tests: +95/-0.
  • Live provider calls were not run; deterministic regressions exercise the actual provider entrypoints with mocked upstream HTTP responses and real request/cache behavior.

@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 20, 2026 18:51
@steipete
steipete merged commit c0775c7 into main Aug 20, 2026
167 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the codex/autoqa-provider-search-cache-20260820 branch August 20, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant