fleet-memory/hindsight-docs/docs/developer
Nicolò Boschi 7dad9da02d
feat: allow chunks-only in recall (max_tokens=0) (#364)
* feat: allow chunks only in recall

* feat: fetch chunks independently of max_tokens filtering

Changes:
- Chunks now fetched BEFORE max_tokens filtering (Step 5.5)
- Implements batching: (max_chunk_tokens / retain_chunk_size) * 2
- Loop-based fetching until budget exhausted or no more chunks
- Handles varying chunk sizes across documents
- When max_tokens=0: returns 0 facts but still returns chunks
- When max_tokens>0: backward compatible (chunks match filtered facts)

Tests:
- Added test_recall_chunks_independence.py with 5 comprehensive tests
- Tests chunk independence, batching, ordering, and backward compat

Docs:
- Updated recall.mdx to explain new chunk behavior
- Updated memory_engine.py docstrings

Fixes chunk-related test failures by reordering chunks to match
filtered facts when max_tokens > 0 (backward compatibility).

* fix: fetch chunks after token filtering when max_tokens>0

Changes:
- When max_tokens=0: fetch chunks BEFORE token filtering (new behavior)
- When max_tokens>0: fetch chunks AFTER token filtering (backward compat)
- This ensures chunk ordering matches filtered facts for max_tokens>0
- Fixes test failures in test_chunks_and_entities_follow_fact_order,
  test_chunk_fact_mapping, test_chunk_ordering_preservation, etc.

The previous approach tried to reorder prefetched chunks, but that
caused issues when the chunk budget was exhausted before all facts
were processed. The new approach fetches chunks based on the correct
fact set for each scenario.

* fix: use ConfigResolver for bank-specific retain_chunk_size

Fixes error: Field 'retain_chunk_size' is bank-configurable and cannot
be accessed from global config.

Changed from:
- config.retain_chunk_size (global config, not allowed)

To:
- bank_config.retain_chunk_size (resolved from ConfigResolver)

This ensures the correct chunk size is used for each bank, respecting
any bank-specific overrides.

* fix: correct Budget import in test_recall_chunks_independence

Changed from:
- from hindsight_api.engine.interface import Budget (incorrect)

To:
- from hindsight_api.engine.memory_engine import Budget (correct)

This fixes the ImportError that was preventing the tests from running.

* fix: prevent infinite loop in chunk fetching and improve test content

- Add max(1, ...) to estimated_batch_size to prevent division resulting in 0
- Update test content to use more substantial examples that generate facts
- Add request_context parameter to all retain_async and recall_async test calls

* refactor: simplify chunk fetching to always use pre-filtering approach

Remove backward compatibility code that fetched chunks after token
filtering. Now chunks are always fetched from top-scored results
before max_tokens filtering, regardless of max_tokens value.

This simplifies the code by:
- Removing duplicate chunk fetching logic
- Eliminating conditional behavior based on max_tokens
- Making chunk fetching behavior consistent and predictable

Chunks are still fetched in batches and respect max_chunk_tokens limit.
2026-02-13 16:56:35 +01:00
..
api feat: allow chunks-only in recall (max_tokens=0) (#364) 2026-02-13 16:56:35 +01:00
admin-cli.md chore: internal renames (#204) 2026-01-27 09:53:28 +01:00
configuration.md feat: support litellm-sdk as reranker and embeddings (#357) 2026-02-12 23:53:12 +01:00
development.md rename to hindsight (#2) 2025-11-25 19:28:26 +01:00
extensions.md doc: prepare doc for 0.4.10 (#325) 2026-02-09 11:42:37 +01:00
index.md fix: misc fixes for observations and mental models (#209) 2026-01-27 15:37:57 +01:00
installation.md Replace waitlist links with direct Hindsight Cloud signup URL (#349) 2026-02-11 20:51:32 +01:00
mcp-server.md Fix incorrect MCP tool parameters in docs (#358) 2026-02-12 08:52:05 -07:00
models.md doc: update claude-code usage terms (#315) 2026-02-06 16:53:12 +01:00
monitoring.md feat: add otel traceability (#330) 2026-02-10 12:20:48 +01:00
multilingual.md chore: internal renames (#204) 2026-01-27 09:53:28 +01:00
observations.mdx fix: misc fixes for observations and mental models (#209) 2026-01-27 15:37:57 +01:00
performance.md fix: misc fixes for observations and mental models (#209) 2026-01-27 15:37:57 +01:00
rag-vs-hindsight.md doc: mental models (#199) 2026-01-26 14:27:08 +01:00
reflect.mdx fix: misc fixes for observations and mental models (#209) 2026-01-27 15:37:57 +01:00
retain.md chore: internal renames (#204) 2026-01-27 09:53:28 +01:00
retrieval.md chore: internal renames (#204) 2026-01-27 09:53:28 +01:00
services.md doc: mental models (#199) 2026-01-26 14:27:08 +01:00
storage.md bump pg0 0.11.x and improve documentation (#33) 2025-12-16 13:33:01 +01:00