Skip to content

v1.1.1 — HyDE query crash fix

Choose a tag to compare

@idapixl idapixl released this 16 May 11:03
· 124 commits to master since this release
e40bd66

Fixed

HyDE query crash on empty LLM outputquery(hyde: true) could crash with Cannot read properties of undefined (reading 'length') when a reasoning-mode LLM (qwen3, phi4-reasoning, etc.) consumed the entire maxTokens budget on the <think>...</think> block, leaving an empty final response. stripThinking() then yielded "", and OllamaEmbedProvider.embed("") returned undefined (Ollama returns embeddings: [] for empty input, and [][0] is undefined). The undefined embedding propagated as the query vector and crashed on .length access in spread activation.

Three layers of fix

  • hydeExpand (src/engines/memory.ts) — prepends /no_think to suppress reasoning-mode output (mirroring the pattern generateJSON already used), and falls back to embedding the raw query if the LLM still produces empty output.
  • OllamaEmbedProvider.embed (src/providers/ollama.ts) — throws on empty input and validates the response has a non-empty embedding (fail-fast instead of returning undefined).
  • spreadActivation (src/engines/memory.ts) — defensive null guard on memory.embedding.length, matching the optional-chaining pattern already used elsewhere in the function (Memory.embedding is typed number[] | null).

Added

  • HyDE fallback regression test (src/engines/hyde-fallback.test.ts) — 3 tests covering empty LLM output, whitespace-only output, and substantive output paths.
  • Spread-activation null-embedding regression test (src/engines/spread-activation.test.ts) — covers the previously-unguarded memory.embedding.length access.
  • scripts/verify-hyde-fix.mjs — standalone Node script that exercises the HyDE → findNearest → spreadActivation chain against a live SQLite store, useful for debugging future query path crashes.

Also in this release

  • feat(config-loader): support llm/embed/store options and cognitive_tools in NamedCortexEntry, enabling multi-agent setups where one named agent owns one cortex namespace with its own tool subset directly from agent.yaml.

Full diff: v1.1.0...v1.1.1