fleet-memory/hindsight-api/hindsight_api
Nicolò Boschi eeb938fc65
fix: truncate documents exceeding LiteLLM reranker context limit (#549)
* fix: register embedded profiles in CLI metadata on daemon start

When HindsightEmbedded(profile="myapp") starts a daemon, the profile
was never written to metadata.json or given a .env file, making it
invisible to `hindsight-embed profile list` and other CLI commands.

Add _register_profile() to DaemonEmbedManager which saves HINDSIGHT_API_*
config to ~/.hindsight/profiles/{name}.env and registers the port in
metadata.json. Called after a successful new daemon start and when the
daemon is already running, so orphaned profiles also get registered on
next use.

* fix: truncate documents exceeding LiteLLM reranker context limit

Add HINDSIGHT_API_RERANKER_LITELLM_MAX_TOKENS_PER_DOC env var for both
litellm and litellm-sdk reranker providers. When set, documents are
truncated to the configured token limit using tiktoken (cl100k_base)
before being sent to the reranker, preventing BadRequestError for
models with small context windows (e.g. 1024-token limit).

* refactor: use shared _tiktoken_encoder for doc truncation in LiteLLM reranker

* refactor: use _get_tiktoken_encoding() consistently, remove eager module-level encoder instance

* doc: add HINDSIGHT_API_RERANKER_LITELLM_MAX_TOKENS_PER_DOC to configuration reference
2026-03-13 10:18:18 +01:00
..
admin Fix run-db-migration for all-tenant upgrades (#530) 2026-03-10 10:10:03 +01:00
alembic fix: cancel in-flight async ops when bank is deleted (#545) 2026-03-12 09:39:31 +01:00
api fix: cancel in-flight async ops when bank is deleted (#545) 2026-03-12 09:39:31 +01:00
engine fix: truncate documents exceeding LiteLLM reranker context limit (#549) 2026-03-13 10:18:18 +01:00
extensions Add on_file_convert_complete extension hook after file-to-markdown conversion (#507) 2026-03-06 09:56:53 +01:00
webhooks fix: use correct schema name in webhook outbox callback to prevent silent transaction rollback (#499) 2026-03-05 17:07:48 +01:00
worker feat: webhook system with retain.completed event, UI, and docs (#487) 2026-03-04 14:17:01 +01:00
__init__.py Release v0.4.17 2026-03-10 17:18:35 +01:00
banner.py feat: support for pgvectorscale (DiskANN) (#378) 2026-02-16 14:19:56 +01:00
config.py fix: truncate documents exceeding LiteLLM reranker context limit (#549) 2026-03-13 10:18:18 +01:00
config_resolver.py Fix bank config API for multi-tenant schema isolation (#417) 2026-02-20 23:43:52 +01:00
daemon.py feat: improve openclaw and hindisght-embed params (#279) 2026-02-03 09:39:04 +01:00
main.py fix: truncate documents exceeding LiteLLM reranker context limit (#549) 2026-03-13 10:18:18 +01:00
mcp_local.py fix(mcp): unify hindsight-mcp-local and server mcp (#407) 2026-02-19 17:57:17 +01:00
mcp_tools.py Fix bank-level MCP tool filtering for FastMCP 3.x (#491) 2026-03-04 10:29:29 -05:00
metrics.py chore: remove dead code (#245) 2026-01-30 09:16:32 +01:00
migrations.py perf: replace window-function retrieval with UNION ALL + per-bank HNSW indexes (#541) 2026-03-11 12:09:50 +01:00
models.py Add bank-scoped validation to engine and HTTP handlers (#454) 2026-03-02 09:55:21 +01:00
pg0.py feat: support vertex as llm provider (#233) 2026-01-29 16:13:57 -05:00
server.py Fix: Load extensions in server.py for multi-worker deployments (#155) 2026-01-13 17:55:33 +01:00
tracing.py feat: add otel traceability (#330) 2026-02-10 12:20:48 +01:00
utils.py fix(helm): improve appVersion usage (#326) 2026-02-09 11:35:08 +01:00