fleet-memory/hindsight-api/hindsight_api/engine/consolidation
Nicolò Boschi 861295dd7c
refactor: replace set_gemini_safety_settings() with LLMProvider.with_config() (#474)
* refactor: replace set_gemini_safety_settings() with LLMProvider.with_config()

Removes the fragile ContextVar-setter pattern where callers had to remember
to call set_gemini_safety_settings() at every operation entry point.

Instead, LLMProvider.with_config(resolved_config) returns a
ConfiguredLLMProvider wrapper that:
- injects per-bank settings (Gemini safety settings) on every call via
  token-based ContextVar set/reset — properly scoped, no leakage
- proxies all attribute access to the underlying provider via __getattr__
- requires zero changes to LLMInterface or any provider implementations

Call sites (retain, reflect, consolidation) now pass
llm_config.with_config(resolved_config) to sub-components instead of
setting a global context var and hoping nothing else runs in between.
This pattern also composes naturally with a future per-bank provider
factory: callers always receive something with a .call() method.

* fix: pass messages/tools as kwargs in ConfiguredLLMProvider to preserve class-level patch compatibility
2026-03-03 15:00:32 +01:00
..
__init__.py feat: revisit mental models, directives and reflections (#179) 2026-01-22 17:13:16 +01:00
consolidator.py refactor: replace set_gemini_safety_settings() with LLMProvider.with_config() (#474) 2026-03-03 15:00:32 +01:00
prompts.py feat: batch observations consolidation (#430) 2026-02-24 15:19:39 +01:00