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 <daniyuu19@sjtu.edu.cn>
This commit is contained in:
Kagura 2026-03-24 16:12:54 +08:00 committed by GitHub
parent 4a55068db7
commit 8e2e2d5bf2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,
)