#20315: fix(memory): add gemini-embedding-001 to GEMINI_MAX_INPUT_TOKENS
size: XS
trusted-contributor
Cluster:
Memory Database Enhancements
## Problem
`GEMINI_MAX_INPUT_TOKENS` only mapped `text-embedding-004`, leaving `gemini-embedding-001` with `maxInputTokens: undefined`. This causes embedding calls to skip token-count limiting, potentially exceeding the model's 2048-token context window.
## Fix
Add `'gemini-embedding-001': 2048` to the token map in `src/memory/embeddings-gemini.ts`.
## Test
Added a unit test covering the undefined case to prevent regression.
Co-authored-by: Clawborn <tianrun.yang103@gmail.com>
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds the `gemini-embedding-001` model (the default Gemini embedding model) to `GEMINI_MAX_INPUT_TOKENS` with a limit of 8192 tokens. Previously, only `text-embedding-004` was mapped, so the default model's `maxInputTokens` was set to `undefined` at provider creation time in `createGeminiEmbeddingProvider`.
- Adds `"gemini-embedding-001": 8192` to the token map in `embeddings-gemini.ts`
- Exports `GEMINI_MAX_INPUT_TOKENS` and `DEFAULT_GEMINI_EMBEDDING_MODEL` for test access
- Adds a new test file verifying both models are mapped and the default model always has a defined token limit
- **Note**: The downstream `resolveEmbeddingMaxInputTokens` in `embedding-model-limits.ts` already had a conservative Gemini fallback of 2048 tokens, so this wasn't causing runtime failures — but the explicit 8192 value is more accurate and avoids unnecessarily conservative chunking for `gemini-embedding-001`
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it adds a missing token limit entry and a regression test with no risk to existing behavior.
- The change is minimal and well-scoped: one new entry in a token-limit map and one new test file. The existing fallback in embedding-model-limits.ts means there was no actual runtime failure before this fix, but the explicit value (8192) is more accurate than the conservative fallback (2048). No existing functionality is altered.
- No files require special attention.
<sub>Last reviewed commit: 3290ba7</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#17701: fix(memory-lancedb): add gemini-embedding-001 and baseUrl support
by Phineas1500 · 2026-02-16
80.4%
#8675: fix: Gemini batch embeddings state path, enum values, and download URL
by seasalim · 2026-02-04
74.8%
#15301: Feat/gemini overflow and tags
by divisonofficer · 2026-02-13
74.8%
#8660: fix: respect agents.defaults.models.*.params.maxTokens in image tool
by dbottme · 2026-02-04
74.2%
#15585: fix: add retry/backoff for Gemini embedding API calls
by WalterSumbon · 2026-02-13
73.8%
#16786: fix: support google-antigravity OAuth for Gemini embeddings
by outsourc-e · 2026-02-15
73.5%
#7913: fix: fixed gemini-cli usage not working for preview models
by RomanHotsiy · 2026-02-03
72.6%
#11464: feat(models): add forward-compat fallback for gemini-3-pro-image
by ben-milanko · 2026-02-07
72.6%
#8309: fix: add emb_ prefix to batch embedding custom_id for OpenAI compli...
by vishaltandale00 · 2026-02-03
72.3%
#21998: fix(models): prioritize exact model-id match over fuzzy scoring (#2...
by lailoo · 2026-02-20
72.1%