Skip to content

Make EMBEDDING_MAX_CHARS provider-aware to avoid over-truncating large symbols#65

Merged
GoodbyePlanet merged 1 commit into
mainfrom
fix/embedding-max-chars-provider-aware-64
Jul 2, 2026
Merged

Make EMBEDDING_MAX_CHARS provider-aware to avoid over-truncating large symbols#65
GoodbyePlanet merged 1 commit into
mainfrom
fix/embedding-max-chars-provider-aware-64

Conversation

@GoodbyePlanet

Copy link
Copy Markdown
Owner

Summary

  • Replace the flat 6,000-char EMBEDDING_MAX_CHARS default with a per-provider default derived from each provider's default model's max input token limit (verified against official docs), so large-context providers (Voyage 32K, OpenAI/Jina 8K) aren't truncated down to the smallest-context provider's (Ollama 2K) budget.
  • EMBEDDING_MAX_CHARS env var still works as an explicit override for any provider.
  • Docs (docs/configuration.md, docs/ingestion.md, docs/dense-vectors.md, README.md, .env.example) updated with the new per-provider table.
EMBEDDINGS_PROVIDER Default model Max input tokens Derived EMBEDDING_MAX_CHARS default
jina jinaai/jina-embeddings-v2-base-code 8,192 22,000
jina-api jina-embeddings-v2-base-code 8,192 22,000
voyage voyage-code-3 32,000 86,000
openai text-embedding-3-large 8,192 22,000
ollama nomic-embed-text 2,048 5,500

Fixes #64.

Test plan

  • uv run pytest -q — 216 passed
  • New tests/test_config.py covers all five per-provider defaults and the explicit-override case
  • Existing tests/test_pipeline.py (which passes max_chars explicitly) unaffected

🤖 Generated with Claude Code

…t window

Replace the flat 6000-char default with a per-provider table keyed on
EMBEDDINGS_PROVIDER's default model context window (~3 chars/token, ~10%
safety margin): 22000 for the 8K-token providers (jina/jina-api/openai),
86000 for voyage-code-3's 32K window, 5500 for ollama's 2K window. A
model_validator fills the value only when EMBEDDING_MAX_CHARS is unset, so
the env var still overrides explicitly. Fixes under-utilization that
truncated large symbols down to the smallest provider's budget.

Tests: adds tests/test_config.py covering all five per-provider defaults
and the explicit-override case; full suite passes (216).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@GoodbyePlanet GoodbyePlanet merged commit b5e1530 into main Jul 2, 2026
2 checks passed
@GoodbyePlanet GoodbyePlanet deleted the fix/embedding-max-chars-provider-aware-64 branch July 2, 2026 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make EMBEDDING_MAX_CHARS provider-aware to avoid over-truncating large symbols

1 participant