Skip to content

fix(embeddings): forward timeout/batch_size/max_retries from config to the OpenAI provider - #361

Merged
HananKavitzAmat merged 3 commits into
chunkhound:mainfrom
GoodOlClint:fix/openai-provider-drops-embedding-config
Jul 9, 2026
Merged

HananKavitzAmat merged 3 commits into
chunkhound:mainfrom
GoodOlClint:fix/openai-provider-drops-embedding-config

Conversation

@GoodOlClint

Copy link
Copy Markdown
Contributor

Fixes #360.

What

The OpenAI factory path (EmbeddingProviderFactory._create_openai_provider) dropped timeout, batch_size, and max_retries from the provider config, so OpenAI-compatible providers always ran with the hardcoded 30s / 100 / 3 defaults regardless of configuration. The VoyageAI path in the same factory already forwards all three; this makes the OpenAI path symmetric.

  • create_openai_provider() grows batch_size / timeout / retry_attempts keyword args (defaults unchanged) and forwards them to OpenAIEmbeddingProvider, which already accepted them.
  • The factory passes config.get("timeout", 30), config.get("batch_size", 100), config.get("max_retries", 3) — same keys and defaults the VoyageAI path uses.

Why it matters

Local OpenAI-compatible endpoints (Ollama, LM Studio, llama.cpp, MLX servers) routinely exceed 30s per embedding batch with larger models; the configured timeout was silently ignored (see the last comment on #134 — a user hitting exactly this after that issue closed).

Test

tests/test_embedding_factory_forwards_config.py — verified discriminating: fails against the previous factory behavior (_timeout stuck at 30 with timeout: 120 configured), passes with the fix; also pins that defaults are preserved when the keys are absent.

🤖 Generated with Claude Code

…o the OpenAI provider

The OpenAI factory path dropped these three settings while the VoyageAI path
forwarded them, so OpenAI-compatible providers always ran with the hardcoded
30s timeout / batch_size 100 / 3 retries regardless of configuration.

Adds a regression test that fails against the previous factory behavior.

Co-Authored-By: Claude Fable 5 <[email protected]>
@HananKavitzAmat

Copy link
Copy Markdown
Collaborator

Summary: Clean, minimal fix for a genuine config-forwarding bug — the OpenAI factory path now matches the VoyageAI path it was asymmetric with.

Strengths:

  • The fix mirrors the VoyageAI path exactly (config.get("batch_size", 100), config.get("timeout", 30), config.get("max_retries", 3)), achieving the intended symmetry with no new patterns introduced.
  • All CI passes across 3 platforms × 2 Python versions (3.12, 3.14).
  • The test is discriminating — it would catch a regression to old behavior and validates defaults are preserved when keys are absent.

Issues:

Minor — chunkhound/embeddings.py:138-165: The create_openai_provider docstring gains three new keyword parameters (batch_size, timeout, retry_attempts) but the Args: block is not updated to document them. PEP 257 and the existing style on this function document every parameter.

Minor — chunkhound/core/config/embedding_factory.py:99-116: The debug log messages for the OpenAI path (both Azure and standard branches) don't include timeout, batch_size, or max_retries. The VoyageAI path also omits them from its debug log, so this is not a regression introduced by this PR — but worth flagging since operators running local endpoints (the exact use case this fixes) benefit from seeing these values in logs.

Observation — test style: The test accesses private attributes (_timeout, _batch_size, _retry_attempts). Per the project's testing philosophy this is only acceptable when it's "the narrowest way to protect a real external contract." Given there's no public accessor for timeout, this is justified — but note this makes the test brittle to future internal refactoring of OpenAIEmbeddingProvider. Acceptable here.

Reusability: No refactoring needed; the change is already as DRY as possible given the two factory methods.

Decision: APPROVE

The core fix is correct and the test is sound. The two minor issues (undocumented docstring params, missing debug log entries) can be addressed in a follow-up or as a quick amendment — they don't affect correctness.

@HananKavitzAmat

Copy link
Copy Markdown
Collaborator

@GoodOlClint The PR looks great.
Please fix the minor issues, otherwise it will confuse future PR request

…ebug logs

Address review feedback on chunkhound#361:
- Document batch_size/timeout/retry_attempts in create_openai_provider Args block
- Include timeout/batch_size/max_retries in the OpenAI factory debug logs

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@GoodOlClint

Copy link
Copy Markdown
Contributor Author

@HananKavitzAmat Thanks! Both minor issues addressed in 58bc92e:

  • create_openai_provider docstring now documents batch_size / timeout / retry_attempts.
  • OpenAI factory debug logs (Azure + standard branches) now include timeout, batch_size, and max_retries — the values operators on local endpoints care about.

The test observation is noted; left the private-attr access as-is since there's no public accessor for timeout.

@HananKavitzAmat

Copy link
Copy Markdown
Collaborator

@GoodOlClint Looks good bu you have some unresolved conflict

…rops-embedding-config

# Conflicts:
#	chunkhound/core/config/embedding_factory.py
@GoodOlClint

Copy link
Copy Markdown
Contributor Author

Merged latest main and resolved the conflict (0fbf54b). It was one overlapping edit in the OpenAI factory debug log — main had added output_dims/client_side_truncation while this branch added timeout/batch_size/max_retries; both sets are now in the log line. Tests green, PR is mergeable again.

@HananKavitzAmat
HananKavitzAmat added this pull request to the merge queue Jul 9, 2026
@HananKavitzAmat

Copy link
Copy Markdown
Collaborator

@GoodOlClint Thanks. Merged

Merged via the queue into chunkhound:main with commit 6f51604 Jul 9, 2026
12 checks passed
ofriw added a commit that referenced this pull request Jul 11, 2026
Resolved 4 conflict sites and 5 auto-merge gaps between db-portability
(code hygiene, DB portability, lint fixes across 400+ files) and main
(#361 config forwarding, #356 cosine similarity scoring).

Conflict 1: discovery.py - _read_startup_timeout -> _resolve_startup_timeout
Conflict 2: search_service.py - query param in search_regex_async
Conflict 3: unified_search.py - skip_rerank, exclude_ids params
Conflict 4: elbow_filter.py - get_unified_score similarity field handling

Auto-merge gaps fixed:
- query kwarg signature in SerialDatabaseProvider.search_regex_async
- score_fn support in chunk_dedup.py
- Depth exploration base_cosine search class integration
- gap_detection.py scoring path unification
- duckdb_provider.py type annotation boundary fix

Fixes included:
- query: str | None = None param added to SerialDatabaseProvider.search_regex_async
- Test assertions updated: _read_startup_timeout -> _resolve_startup_timeout
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.

OpenAI provider ignores configured timeout/batch_size/max_retries — factory drops them

2 participants