The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(agent): inline the single-use _finish closure in _sample_summary_records
kshitijk4poore4f76b827754
diff --git a/agent/context_compressor.py b/agent/context_compressor.pyindex 34436254a96..707d571e396 100644--- a/agent/context_compressor.py+++ b/agent/context_compressor.py@@ -3644,10 +3644,6 @@ Summary generation was unavailable, so this is a best-effort deterministic fallbcursor = ereturn "".join(parts)- def _finish(text: str) -> Tuple[str, Dict[str, int]]:- shown = [i for s, e in selected for i in range(s, e)]- return text, _coverage(sum(len(display_records[i]) for i in shown), len(shown))-# Budget extension: the greedy fill leaves each slice short of `target` by up to one record# (5-43% of the cap unused for 8-20K records). Spend the headroom on whole neighbouring# records, round-robin one record per slice per round so every region keeps an even share@@ -3685,7 +3681,8 @@ Summary generation was unavailable, so this is a best-effort deterministic fallb# pre-bounded to `target`), there are <= n-1 markers each <= `marker_len` (widths computed# at their maxima), and n*target + (n-1)*marker_len <= _SUMMARY_INPUT_MAX_CHARS by# construction; the extension pass above only adds a record when the result stays <= cap.- return _finish(_render(selected))+ shown = [i for s, e in selected for i in range(s, e)]+ return _render(selected), _coverage(sum(len(display_records[i]) for i in shown), len(shown))def _fallback_to_main_for_compression(self, e: Exception, reason: str, failed_model: Optional[str] = None