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)))
|
session._summary_cache.get((obj_id, int(FidelityLevel.L2)))
|
||||||
or obj.summary_compact
|
or obj.summary_compact
|
||||||
)
|
)
|
||||||
if summary:
|
if not summary:
|
||||||
if block.get("type") == "tool_result":
|
# No LLM summary yet — use auto-stub as fallback
|
||||||
block["content"] = summary
|
summary = obj.stub or _auto_stub(text)
|
||||||
else:
|
if block.get("type") == "tool_result":
|
||||||
block["text"] = summary
|
block["content"] = summary
|
||||||
# else: keep full content as fallback
|
else:
|
||||||
|
block["text"] = summary
|
||||||
elif obj.current_fidelity == FidelityLevel.L1:
|
elif obj.current_fidelity == FidelityLevel.L1:
|
||||||
# L1: use detailed summary if available (from LLM or pre-set)
|
# L1: use detailed summary if available (from LLM or pre-set)
|
||||||
summary = (
|
summary = (
|
||||||
session._summary_cache.get((obj_id, int(FidelityLevel.L1)))
|
session._summary_cache.get((obj_id, int(FidelityLevel.L1)))
|
||||||
or obj.summary_detailed
|
or obj.summary_detailed
|
||||||
)
|
)
|
||||||
if summary:
|
if not summary:
|
||||||
if block.get("type") == "tool_result":
|
# No LLM summary yet — use auto-stub as fallback
|
||||||
block["content"] = summary
|
# so we still get compression instead of keeping full content
|
||||||
else:
|
summary = obj.stub or _auto_stub(text)
|
||||||
block["text"] = summary
|
if block.get("type") == "tool_result":
|
||||||
# else: keep full content as fallback
|
block["content"] = summary
|
||||||
|
else:
|
||||||
|
block["text"] = summary
|
||||||
else:
|
else:
|
||||||
# New object — register it
|
# New object — register it
|
||||||
obj_type = "tool_result" if block.get("type") == "tool_result" else "file_context"
|
obj_type = "tool_result" if block.get("type") == "tool_result" else "file_context"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue