From 8e2e2d5bf24f1059afd0ebec4a6cbef673d31242 Mon Sep 17 00:00:00 2001 From: Kagura Date: Tue, 24 Mar 2026 16:12:54 +0800 Subject: [PATCH] fix(reflect): disable source facts in search_observations to prevent context overflow (#669) search_observations in the reflect agent hardcoded include_source_facts=True with max_source_facts_tokens=-1 (unlimited). For banks with many observations backed by thousands of facts, a single tool call could produce 300K+ tokens, exceeding the default 100K context budget and causing forced synthesis with an empty 'Retrieved Data' section. The reflect agent synthesizes from observations, not raw backing facts. Disable source facts to keep payloads proportional to observation count (~6K vs ~310K in the reporter's case). The consolidation path already has configurable source fact limits (PR #509, v0.4.17). The reflect path was not updated. Fixes #668 Co-authored-by: Kagura Chen --- hindsight-api-slim/hindsight_api/engine/reflect/tools.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hindsight-api-slim/hindsight_api/engine/reflect/tools.py b/hindsight-api-slim/hindsight_api/engine/reflect/tools.py index 6ef73a18..e0b092fe 100644 --- a/hindsight-api-slim/hindsight_api/engine/reflect/tools.py +++ b/hindsight-api-slim/hindsight_api/engine/reflect/tools.py @@ -136,7 +136,7 @@ async def tool_search_observations( pending_consolidation: int = 0, ) -> dict[str, Any]: """ - Search consolidated observations using recall with include_source_facts. + Search consolidated observations using recall. Observations are auto-generated from memories. Returns freshness info so the agent knows if it should also verify with recall(). @@ -165,8 +165,7 @@ async def tool_search_observations( tags=tags, tags_match=tags_match, tag_groups=tag_groups, - include_source_facts=True, - max_source_facts_tokens=-1, # No token limit — include all source facts + include_source_facts=False, _connection_budget=1, _quiet=True, )