Skip to content

fix(embedding): honour REPOWISE_EMBEDDING_TIMEOUT in every embedder - #1475

Merged
RaghavChamadiya merged 4 commits into
repowise-dev:mainfrom
serjflint:fix/local-endpoint-embedding
Aug 14, 2026
Merged

RaghavChamadiya merged 4 commits into
repowise-dev:mainfrom
serjflint:fix/local-endpoint-embedding

Conversation

@serjflint

Copy link
Copy Markdown
Contributor

Fixes #1474.

REPOWISE_EMBEDDING_TIMEOUT is documented as applying to whichever embedder is active, but only the
Ollama embedder read it; openai, gemini and openrouter hardcoded 10s. Against a local
OpenAI-compatible endpoint one request embeds a whole batch — measured ~10s at 2,500 characters per item
and ~15s beyond 4,000 — so batches expired and were reported once as N/N items failed to embed while the
run still exited 0. The repair that message recommends, repowise reindex, embeds through the same path
and failed identically. Numbers, method and repro are in the issue.

Defaults are unchanged (Ollama 30s, the rest 10s). The same embedder serves the query path and the SDK
retries twice, so raising the shared default would turn a stalled hosted endpoint into a ~90s MCP tool
call. Unifying the four defaults is a separate call.

A malformed value falls back instead of raising. build_embedder wraps construction in
except Exception and returns KeylessEmbedder, so raising on a typo like 30s would silently leave the
run with 8-dimensional vectors and no retrieval — breaking a setup that worked before the variable was read
at all. It is reported on stderr rather than through log.warning, because configure_cli_logging filters
structlog to ERROR unless -v, which would have discarded the message on every command that embeds. What
should happen for bad embedder config is the open question in #826; this follows whatever is decided
there.

Commits

Independent — either can be dropped without touching the other.

  1. concept-tree: warn when outline naming is cut at the token ceiling. A truncated reply parses to
    {} and decodes to the same deterministic fallback an empty one produces, so the two are
    indistinguishable and titles silently become path-derived. Reasoning tokens count against the same
    ceiling, so a thinking model can exhaust it having emitted no answer.
  2. embedding: honour the variable in every embedder, via one shared resolver
    (explicit arg > <PROVIDER>_EMBEDDING_TIMEOUT > REPOWISE_EMBEDDING_TIMEOUT > provider default).
  3. embedding: route Ollama through it too. Ollama and _embedder_kwargs each parsed the variable
    with a bare float(), so the keyless downgrade above was still reachable on the embedder most likely to
    need a raised timeout, and inf/negatives reached httpx unchecked.

Tests

tests/unit/test_persistence/test_embedding_timeout_resolution.py holds the cross-embedder contract:
precedence, that a malformed provider-specific value falls through to a valid shared one rather than
consuming its precedence, that no embedder is destroyed by a typo, and that the fallback reaches stderr.
12 of the new tests fail on main — including could not convert string to float: '30s' and inf
reaching the client on the Ollama path.

uv run pytest tests/unit/test_persistence tests/unit/generation tests/unit/test_providers — 1667 passed.
CONFIG.md gains the provider-prefixed rows and the defaults it never stated.

I have not run ruff format repo-wide: it reformats 522 files on current main, which would bury the
diff.

Sergei Iakhnitskii added 3 commits August 13, 2026 10:18
A reply truncated at max_tokens parses to {} and decodes to the same
deterministic fallback a model that returned nothing produces, so the two
are indistinguishable: no exception, no warning, only named_by_model=0 on
the planned line. The provider already surfaces the signal, and
validate_generated_response treats it as fatal for a page.

Log it and carry on. Reasoning tokens are charged to the same ceiling, so
a thinking model can exhaust it while emitting no answer at all.
Only the Ollama embedder read the timeout variable CONFIG.md documents as
applying to whichever embedder is active; openai, gemini and openrouter
hardcoded 10s. Against an OpenAI-compatible endpoint on local hardware one
chunk is EMBED_BATCH_MAX_ITEMS items of up to EMBED_TEXT_MAX_CHARS, which
takes seconds of GPU work, and an expired batch is not retried — it is
reported once as 'N/N items failed to embed' while the run still exits 0.

Resolve through one shared helper: explicit arg > <PROVIDER>_EMBEDDING_TIMEOUT
> REPOWISE_EMBEDDING_TIMEOUT > the provider default. Defaults are unchanged,
since the same embedder bounds the retried query path.

A malformed env value warns and falls back rather than raising: build_embedder
converts a construction error into a keyless 8-wide embedder, so raising would
let a typo silently destroy retrieval for a setup that worked before the
variable was read at all. inf and nan are rejected with the rest.
…out loud

Two gaps in the previous commit, both on the path this change exists for.

The ollama embedder and the CLI's _embedder_kwargs each parsed the variable
themselves with a bare float(), so a typo raised inside build_embedder's
except Exception and downgraded the run to a keyless 8-wide store — the
failure this change set out to prevent, still reachable on the embedder most
likely to need a raised timeout. inf and negatives reached httpx unchecked
there too. Both now resolve through the one helper; the CLI stops pre-parsing.

The fallback also claimed to warn while warning nobody: configure_cli_logging
pins structlog to ERROR unless -v, so every command that embeds discarded the
line. Report on stderr as build_embedder already does for the same class of
misconfiguration.

A malformed provider-specific value no longer consumes its precedence over a
valid shared one.
@repowise-bot

repowise-bot Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Health of changed files: 7.5 → 7.6 (+0.1)
⚠️ Change risk: moderate, riskier than 50% of this repo's commits.

📋 At a glance
1 file changed health · 5 hotspots touched · 1 new finding introduced · 3 files with recent fix history · 1 dead-code finding.

Files & modules (2)
  • packages (6 files)
    • .../embedding/base.py
    • .../concept_tree/planner.py
    • .../embedding/openrouter.py
    • .../embedding/openai.py
    • .../providers/embedders.py
    • .../embedding/gemini.py
  • tests (1 file)
    • .../generation/test_concept_outline.py

✅ Health gate: passed

📌 Before you merge

  • Run .../generation/test_concept_naming_wiring.py, .../persistence/test_embed_batch_pg.py, tests/integration/test_mcp.py, .../cli/test_doctor_embed_recipe.py (+7 more): they import the changed files
🔎 More signals (3)

🗺️ Change map

flowchart LR
  subgraph PR ["Changed in this PR (7 with dependents)"]
    f_packages_core_src_repowise_core_generation_concept_tree_planner_py[".../concept_tree/planner.py 🔥"]:::changed
    f_packages_core_src_repowise_core_providers_embedding_base_py[".../embedding/base.py 🔥"]:::changed
    f_packages_core_src_repowise_core_providers_embedding_openai_py[".../embedding/openai.py 🔥"]:::changed
    f_packages_core_src_repowise_core_providers_embedding_openrouter_py[".../embedding/openrouter.py 🔥"]:::changed
    f_packages_cli_src_repowise_cli_providers_embedders_py[".../providers/embedders.py"]:::changed
    f_packages_core_src_repowise_core_providers_embedding_gemini_py[".../embedding/gemini.py"]:::changed
    f_packages_core_src_repowise_core_providers_embedding_ollama_py[".../embedding/ollama.py"]:::changed
  end
  f_packages_core_src_repowise_core_generation_page_generator_orchestrate_py[".../page_generator/orchestrate.py"]
  f_packages_core_src_repowise_core_generation_concept_tree_planner_py --> f_packages_core_src_repowise_core_generation_page_generator_orchestrate_py
  f_packages_cli_src_repowise_cli_commands_doctor_cmd_repo_checks_py[".../doctor_cmd/repo_checks.py"]
  f_packages_core_src_repowise_core_providers_embedding_base_py --> f_packages_cli_src_repowise_cli_commands_doctor_cmd_repo_checks_py
  f_packages_cli_src_repowise_cli_commands_reindex_cmd_py[".../commands/reindex_cmd.py"]
  f_packages_core_src_repowise_core_providers_embedding_base_py --> f_packages_cli_src_repowise_cli_commands_reindex_cmd_py
  f_packages_cli_src_repowise_cli_providers_vector_store_py[".../providers/vector_store.py"]
  f_packages_core_src_repowise_core_providers_embedding_base_py --> f_packages_cli_src_repowise_cli_providers_vector_store_py
  f_packages_cli_src_repowise_cli_upgrade_py[".../cli/upgrade.py"]
  f_packages_core_src_repowise_core_providers_embedding_base_py --> f_packages_cli_src_repowise_cli_upgrade_py
  f_packages_core_src_repowise_core_providers_embedding_registry_py[".../embedding/registry.py"]
  f_packages_core_src_repowise_core_providers_embedding_openai_py --> f_packages_core_src_repowise_core_providers_embedding_registry_py
  f_packages_core_src_repowise_core_providers_llm_deepseek_py[".../llm/deepseek.py"]
  f_packages_core_src_repowise_core_providers_embedding_openai_py --> f_packages_core_src_repowise_core_providers_llm_deepseek_py
  f_packages_core_src_repowise_core_providers_llm_kimi_py[".../llm/kimi.py"]
  f_packages_core_src_repowise_core_providers_embedding_openai_py --> f_packages_core_src_repowise_core_providers_llm_kimi_py
  f_packages_core_src_repowise_core_providers_llm_ollama_py[".../llm/ollama.py"]
  f_packages_core_src_repowise_core_providers_embedding_openai_py --> f_packages_core_src_repowise_core_providers_llm_ollama_py
  f_packages_core_src_repowise_core_providers_embedding_openrouter_py --> f_packages_core_src_repowise_core_providers_embedding_registry_py
  f_packages_cli_src_repowise_cli_providers_embedders_py --> f_packages_cli_src_repowise_cli_commands_reindex_cmd_py
  f_packages_core_src_repowise_core_providers_embedding_gemini_py --> f_packages_core_src_repowise_core_providers_embedding_registry_py
  f_packages_core_src_repowise_core_providers_embedding_ollama_py --> f_packages_core_src_repowise_core_providers_embedding_registry_py
  more(["+19 more dependents"])
  PR --> more
  t_tests_unit_generation_test_concept_naming_wiring_py(["✅ .../generation/test_concept_naming_wiring.py"]):::guard
  t_tests_unit_generation_test_concept_naming_wiring_py -.-> f_packages_core_src_repowise_core_generation_concept_tree_planner_py
  t_tests_integration_persistence_test_embed_batch_pg_py(["✅ .../persistence/test_embed_batch_pg.py"]):::guard
  t_tests_integration_persistence_test_embed_batch_pg_py -.-> f_packages_core_src_repowise_core_providers_embedding_base_py
  t_tests_unit_server_mcp_test_embedder_resolution_py(["✅ .../mcp/test_embedder_resolution.py"]):::guard
  t_tests_unit_server_mcp_test_embedder_resolution_py -.-> f_packages_core_src_repowise_core_providers_embedding_openai_py
  classDef changed fill:#dbeafe,stroke:#1d4ed8,color:#1e3a5f
  classDef warn fill:#fef3c7,stroke:#b45309,color:#78350f
  classDef guard fill:#dcfce7,stroke:#15803d,color:#14532d
Loading

Solid arrows: code that imports the changed files (28 direct dependents, from the last indexed snapshot). Dashed: history/tests.

🔥 Hotspots touched (5)

  • .../generation/test_concept_outline.py: 3 commits/90d, 0 dependents · primary owner: Raghav Chamadiya (100%)
  • .../concept_tree/planner.py: 2 commits/90d, 3 dependents · primary owner: Raghav Chamadiya (100%)
  • .../embedding/openrouter.py: 2 commits/90d, 3 dependents · primary owner: lenya lozhkin (74%)
2 more
  • .../embedding/base.py: 2 commits/90d, 47 dependents · primary owner: Raghav Chamadiya (100%)
  • .../embedding/openai.py: 3 commits/90d, 17 dependents · primary owner: Raghav Chamadiya (56%)

💀 Dead code (1 finding)

  • 💀 .../concept_tree/planner.py plan_deterministic (confidence 1.00)

👀 Suggested reviewers @RaghavChamadiya


📊 See the full report for this PR
Your repo map with this PR's blast radius lit up, every caller of the contracts it changes, and health before and after. No sign-in. · ⭐ Star Repowise · 📥 Install bot · Silence on a single PR with [skip repowise] in the title · Per-repo toggle on repowise.dev/settings?tab=bot · Updated 2026-08-13 18:35 UTC

@RaghavChamadiya

Copy link
Copy Markdown
Member

Good report and a good fix. The timing table in #1474, the note that the recommended repair runs through the same failing path, and the reasoning for why a bad value must not raise (it would hit build_embedder's except Exception and leave the run with an 8-wide keyless index) are all right, and the last one is a trap people fall into here regularly.

Consolidating onto one resolver and deleting the duplicate parse in _embedder_kwargs is the right shape. Keeping the defaults where they are, with the reason recorded in the comment about the retried query path, is also the right call.

One thing to fix. The stderr message names the wrong number in the case your own logic is cleverest about:

OPENAI_EMBEDDING_TIMEOUT='45s' is not a positive number of seconds; using 10.0s.
actual timeout used: 180.0

_report_invalid_timeout is called inside the loop and always passed default, but on a fall-through the value actually used is the shared variable's. test_a_malformed_provider_variable_falls_through_to_the_shared_one pins the behaviour, so it is only the message that is wrong, and it is wrong on the one path where a user is already confused. Resolving first and reporting once at the end, with the value that won, would fix it.

On the concept-tree commit: normally I would ask for that as its own PR, since we squash and the commit title would hide a generation change inside an embedding fix. It is small and genuinely independent though, so do not bother splitting it. I will write the squash message to name both.

Not running ruff format repo-wide was correct, our CI contract is ruff check only.

Fix the message and I will merge.

@serjflint

Copy link
Copy Markdown
Contributor Author

@RaghavChamadiya thank you for the review. I pushed the fix.

@RaghavChamadiya RaghavChamadiya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@RaghavChamadiya
RaghavChamadiya merged commit e0a1e6b into repowise-dev:main Aug 14, 2026
9 checks passed
@serjflint

Copy link
Copy Markdown
Contributor Author

Thank you

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.

REPOWISE_EMBEDDING_TIMEOUT is honoured only by the Ollama embedder

2 participants