fleet-memory/hindsight-api/tests
Nicolò Boschi aefb3fcf4d
fix: improve async batch retain with large payloads (#366)
* fix: improve async batch retain with large payloads

* fix: improve async batch retain with large payloads

* api

* api

* api

* api

* api

* Clean up perf benchmark: keep only Python files

- Remove README.md and PERFORMANCE_FINDINGS.md
- Remove results/ JSON files (gitignored)
- Remove test_data/ directory
- Keep only __init__.py and retain_perf.py

* docs: explain automatic batch optimization for async retain

- Add section explaining Hindsight automatically handles batch sizing
- Users don't need to manually tune batch sizes with async mode
- Hindsight splits large batches (>10k tokens) into optimized sub-batches
- Include example showing best practices

* docs: remove emojis and code example from performance page

* fix: correct OperationDetails type to match API response

- Change optional fields to use | null instead of ?
- Fixes TypeScript compilation error in control plane build

* fix: use discriminated union for OperationDetails type

- Support both success and error states properly
- Fixes TypeScript error when setting error state

* fix: use unique document_ids in batch retain examples

- Each item in a batch must have unique document_id
- Update both Python and JavaScript examples
- Fixes test-doc-examples CI failure

* chore: trigger CI

* fix: test mocking and duplicate document_ids in examples

- Mock _get_pool() in test_async_retain_tags.py to avoid _initialized error
- Set _initialized = True on mocked MemoryEngine instances
- Fix duplicate document_ids in retain.py and retain.mjs examples

* fix: properly mock async pool/connection and fix more duplicate document_ids

- Use AsyncMock for pool.acquire() to fix 'can't be used in await' error
- Fix duplicate document_ids in retain-async examples (retain.py and retain.mjs)
- Remove batch-level document_id parameter that caused duplicates

* ci: collect all doc example failures and show summary

- Run all Python/Node.js/CLI examples regardless of individual failures
- Collect failure list and display summary at the end
- Show pass/fail count and list of failed files
- Exit with failure only after running all examples

* refactor: extract doc example testing to standalone script

- Create scripts/test-doc-examples.sh to run all examples
- Collects logs of failed examples separately
- Shows full error logs only for failures at the end
- Clean summary with pass/fail counts
- Proper exit codes
- Replaces inline bash in CI workflow

* fix: doc examples - duplicate document_ids and error handling

- retain.py: move document_id to item level to avoid duplicates
- documents.mjs: add error handling for getDocument to show clear error message

* fix: update tests for duplicate document_id validation

- test_async_retain_tags: verify operation structure instead of exact UUID
- test_delete_bank: use unique document_ids (team-doc-1, team-doc-2)
2026-02-16 12:51:42 +01:00
..
fixtures rename to hindsight (#2) 2025-11-25 19:28:26 +01:00
__init__.py rename to hindsight (#2) 2025-11-25 19:28:26 +01:00
conftest.py fix: improve claude code and codex for /reflect (#285) 2026-02-04 13:34:45 +01:00
test_admin_backup_restore.py feat: run db migrations offline (optionally) (#114) 2026-01-07 15:49:51 +01:00
test_agents_api.py feat: introduce mental models (#132) 2026-01-16 11:16:41 +01:00
test_async_batch_retain.py fix: improve async batch retain with large payloads (#366) 2026-02-16 12:51:42 +01:00
test_async_retain_tags.py fix: improve async batch retain with large payloads (#366) 2026-02-16 12:51:42 +01:00
test_base_path.py feat: add reverse proxy support (#346) 2026-02-12 10:09:53 +01:00
test_batch_chunking.py feat: extensions (#54) 2025-12-22 11:05:23 +01:00
test_causal_relations.py feat: implement hierarchical configuration (system, tenant, bank) (#329) 2026-02-12 13:14:57 +01:00
test_causal_relationships.py feat: implement hierarchical configuration (system, tenant, bank) (#329) 2026-02-12 13:14:57 +01:00
test_chunking.py improve retain performances, caching and tests 2025-12-08 18:21:56 +01:00
test_combined_scoring.py feat: extensions (#54) 2025-12-22 11:05:23 +01:00
test_config_validation.py fix: hindsight-embed profiles are not loaded correctly (#316) 2026-02-06 17:13:54 +01:00
test_consolidation.py feat: implement hierarchical configuration (system, tenant, bank) (#329) 2026-02-12 13:14:57 +01:00
test_custom_embedding_dimension.py fix: improve mental model consolidation (#197) 2026-01-26 09:54:25 +01:00
test_document_tracking.py feat: extensions (#54) 2025-12-22 11:05:23 +01:00
test_extensions.py Add actual LLM token usage fields to RetainResult (#342) 2026-02-11 10:41:41 +01:00
test_fact_extraction_analysis.py feat: implement hierarchical configuration (system, tenant, bank) (#329) 2026-02-12 13:14:57 +01:00
test_fact_extraction_output_ratio.py feat: implement hierarchical configuration (system, tenant, bank) (#329) 2026-02-12 13:14:57 +01:00
test_fact_extraction_quality.py feat: implement hierarchical configuration (system, tenant, bank) (#329) 2026-02-12 13:14:57 +01:00
test_fact_ordering.py feat: introduce mental models (#132) 2026-01-16 11:16:41 +01:00
test_hierarchical_config.py feat: implement hierarchical configuration (system, tenant, bank) (#329) 2026-02-12 13:14:57 +01:00
test_http_api_integration.py fix: improve async batch retain with large payloads (#366) 2026-02-16 12:51:42 +01:00
test_link_expansion_retrieval.py feat: implement hierarchical configuration (system, tenant, bank) (#329) 2026-02-12 13:14:57 +01:00
test_link_utils.py prepare for release 2025-12-03 11:52:25 +01:00
test_litellm_sdk_cross_encoder.py feat: support litellm-sdk as reranker and embeddings (#357) 2026-02-12 23:53:12 +01:00
test_litellm_sdk_embeddings.py feat: support litellm-sdk as reranker and embeddings (#357) 2026-02-12 23:53:12 +01:00
test_llm_provider.py fix(ci): resolve flaky test failures in api tests (#311) 2026-02-06 13:56:59 +01:00
test_llm_token_metrics.py feat: support for codex and claude-code as llm (#276) 2026-02-02 12:54:44 +01:00
test_llm_tools.py chore: internal renames (#204) 2026-01-27 09:53:28 +01:00
test_load_large_batch.py feat: support for other text and vector search pg extensions (#355) 2026-02-12 14:13:04 +01:00
test_main_module.py feat: implement hierarchical configuration (system, tenant, bank) (#329) 2026-02-12 13:14:57 +01:00
test_mcp_endpoint_routing.py Harden MCP server: fix routing, validation, and usage metering (#341) 2026-02-11 10:41:20 +01:00
test_mcp_extension.py Harden MCP server: fix routing, validation, and usage metering (#341) 2026-02-11 10:41:20 +01:00
test_mcp_local.py feat(mcp): add timestamp to retain (#190) 2026-01-23 16:00:43 +01:00
test_mcp_routing.py Harden MCP server: fix routing, validation, and usage metering (#341) 2026-02-11 10:41:20 +01:00
test_mcp_tools.py Harden MCP server: fix routing, validation, and usage metering (#341) 2026-02-11 10:41:20 +01:00
test_mental_model_hooks.py Add extension hooks for mental model operations (#260) 2026-01-31 09:30:53 -05:00
test_mental_models.py doc: prepare doc for 0.4.10 (#325) 2026-02-09 11:42:37 +01:00
test_metrics.py chore: remove dead code (#245) 2026-01-30 09:16:32 +01:00
test_mpfp_retrieval.py fix: improve mpfp retrieval (#146) 2026-01-12 18:58:05 +01:00
test_multilingual.py chore: remove dead code (#245) 2026-01-30 09:16:32 +01:00
test_observations.py feat: implement hierarchical configuration (system, tenant, bank) (#329) 2026-02-12 13:14:57 +01:00
test_per_operation_llm_config.py feat: add more config options for llm retries (#234) 2026-01-29 17:50:43 +01:00
test_provider_default_models.py feat: support for codex and claude-code as llm (#276) 2026-02-02 12:54:44 +01:00
test_query_analyzer.py fix: ci and ui build (#9) 2025-12-03 15:47:53 +01:00
test_recall_chunks_independence.py feat: allow chunks-only in recall (max_tokens=0) (#364) 2026-02-13 16:56:35 +01:00
test_reflect_agent.py fix: graph endpoint not showing links for observations (#214) 2026-01-28 14:51:25 +01:00
test_reflect_empty_based_on.py fix: resolve based_on schema/serialization issues in reflect API (#348) 2026-02-12 11:26:12 +01:00
test_reflect_tracing.py feat: add otel traceability (#330) 2026-02-10 12:20:48 +01:00
test_reflections.py feat: improve mental models ux on control plane (#297) 2026-02-04 15:49:03 +01:00
test_retain.py feat: implement hierarchical configuration (system, tenant, bank) (#329) 2026-02-12 13:14:57 +01:00
test_schema_isolation.py fix: improve mental model consolidation (#197) 2026-01-26 09:54:25 +01:00
test_search_trace.py feat: extensions (#54) 2025-12-22 11:05:23 +01:00
test_server_module.py fix: improve mental model consolidation (#197) 2026-01-26 09:54:25 +01:00
test_sql_schema_safety.py chore: internal renames (#204) 2026-01-27 09:53:28 +01:00
test_supabase_tenant.py Add Supabase tenant extension as built-in (#267) 2026-02-09 10:16:47 +01:00
test_tags_visibility.py chore: cleanup benchmarks runner with old flags (#212) 2026-01-28 13:22:48 +01:00
test_tei_cross_encoder.py fix: add defensive error handling to PyTorch device detection (#221) 2026-01-28 18:14:54 +01:00
test_temporal_ranges.py feat(mcp): add timestamp to retain (#190) 2026-01-23 16:00:43 +01:00
test_think.py chore: remove dead code (#245) 2026-01-30 09:16:32 +01:00
test_tracing.py feat: add otel traceability (#330) 2026-02-10 12:20:48 +01:00
test_tracing_integration.py feat: add otel traceability (#330) 2026-02-10 12:20:48 +01:00
test_tracing_spans_verification.py feat: add otel traceability (#330) 2026-02-10 12:20:48 +01:00
test_vertexai_provider.py Switch Vertex AI provider to native genai SDK (#242) 2026-01-30 08:35:59 +01:00
test_worker.py fix: worker doesn't pick up correct default schema (#259) 2026-01-31 09:15:59 +01:00