Skip to content

docs: document semantic_cache_max_candidates recall tradeoff#2071

Merged
bug-ops merged 1 commit intomainfrom
feat-2031-semantic-cache-docs
Mar 20, 2026
Merged

docs: document semantic_cache_max_candidates recall tradeoff#2071
bug-ops merged 1 commit intomainfrom
feat-2031-semantic-cache-docs

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 20, 2026

Summary

Documents the semantic_cache_max_candidates parameter and its recall vs performance tradeoff in PR #2029. Users can now understand why setting max_candidates=10 limits the number of cached entries examined during similarity lookup.

Changes

  1. Config help comments (crates/zeph-config/src/providers.rs):

    • Added detailed doc comment explaining the recall-vs-performance tradeoff
    • Tuning guidance: 50+ for recall focus, 5 for speed focus, default 10 balanced
    • References SQL LIMIT clause and env override
    • Also expanded semantic_cache_threshold documentation
  2. Debug logs (crates/zeph-core/src/agent/tool_execution/mod.rs):

    • Log cache lookup start with max_candidates and threshold
    • Log cache hit/miss results with parameters
  3. Per-candidate debug logs (crates/zeph-memory/src/response_cache.rs):

    • Log each candidate's cosine similarity score
    • Log scan summary with examined count, best score, threshold, hit/miss verdict
  4. CHANGELOG updated

Validation

  • cargo +nightly fmt --check
  • cargo clippy --workspace -- -D warnings
  • cargo nextest run --workspace --lib --bins (5734 tests)
  • ✅ Code review approved

Fixes #2031

@github-actions github-actions bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes core zeph-core crate size/M Medium PR (51-200 lines) labels Mar 20, 2026
Add comprehensive documentation explaining the recall vs performance tradeoff
of the semantic_cache_max_candidates parameter (controls SQL LIMIT in
ResponseCache::get_semantic() lookup):

- Config help: expanded doc comments in providers.rs with tuning guidance
  (50+ for recall-focused, 5 for performance-focused, default 10 balanced)
- Debug logs: full lifecycle logs covering lookup start, per-candidate
  cosine similarity scores, scan summary, and hit/miss verdicts
- Explains SQL LIMIT clause and how it affects cache hit probability
- Documents env override: ZEPH_LLM_SEMANTIC_CACHE_MAX_CANDIDATES
- Also expanded semantic_cache_threshold doc comments for completeness

Fixes #2031
@bug-ops bug-ops force-pushed the feat-2031-semantic-cache-docs branch from 1ab2ee6 to f11245c Compare March 20, 2026 22:20
@bug-ops bug-ops enabled auto-merge (squash) March 20, 2026 22:20
@bug-ops bug-ops merged commit c65a0e1 into main Mar 20, 2026
25 checks passed
@bug-ops bug-ops deleted the feat-2031-semantic-cache-docs branch March 20, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: document semantic_cache_max_candidates recall tradeoff

1 participant