fix: use auto-stub fallback for L1/L2 when LLM summary not available
L1/L2 objects without LLM summaries kept full content as fallback, increasing context instead of reducing it. Now uses auto-stub (truncated preview) when no summary exists, ensuring degraded objects always produce smaller content.
This commit is contained in:
parent
8d8bd03d41
commit
4a9182d4aa
1 changed files with 15 additions and 12 deletions
|
|
@ -1383,24 +1383,27 @@ def _apply_fidelity(payload: dict, session: "Session") -> None:
|
|||
session._summary_cache.get((obj_id, int(FidelityLevel.L2)))
|
||||
or obj.summary_compact
|
||||
)
|
||||
if summary:
|
||||
if block.get("type") == "tool_result":
|
||||
block["content"] = summary
|
||||
else:
|
||||
block["text"] = summary
|
||||
# else: keep full content as fallback
|
||||
if not summary:
|
||||
# No LLM summary yet — use auto-stub as fallback
|
||||
summary = obj.stub or _auto_stub(text)
|
||||
if block.get("type") == "tool_result":
|
||||
block["content"] = summary
|
||||
else:
|
||||
block["text"] = summary
|
||||
elif obj.current_fidelity == FidelityLevel.L1:
|
||||
# L1: use detailed summary if available (from LLM or pre-set)
|
||||
summary = (
|
||||
session._summary_cache.get((obj_id, int(FidelityLevel.L1)))
|
||||
or obj.summary_detailed
|
||||
)
|
||||
if summary:
|
||||
if block.get("type") == "tool_result":
|
||||
block["content"] = summary
|
||||
else:
|
||||
block["text"] = summary
|
||||
# else: keep full content as fallback
|
||||
if not summary:
|
||||
# No LLM summary yet — use auto-stub as fallback
|
||||
# so we still get compression instead of keeping full content
|
||||
summary = obj.stub or _auto_stub(text)
|
||||
if block.get("type") == "tool_result":
|
||||
block["content"] = summary
|
||||
else:
|
||||
block["text"] = summary
|
||||
else:
|
||||
# New object — register it
|
||||
obj_type = "tool_result" if block.get("type") == "tool_result" else "file_context"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue