Skip to content

The agent that grows with you

refactor(agent): integer head/tail split in _bound_oversized_record

kshitijk4poor8e12cd92d7c3
diff --git a/agent/context_compressor.py b/agent/context_compressor.py
index ff9d4b98f8c..34436254a96 100644
--- a/agent/context_compressor.py
+++ b/agent/context_compressor.py
@@ -3541,10 +3541,10 @@ Summary generation was unavailable, so this is a best-effort deterministic fallb
if limit <= marker_reserve:
return record[:limit]
remaining = limit - marker_reserve
- head_len = int(remaining * 0.5)
+ head_len = remaining // 2
tail_len = remaining - head_len
head = record[:head_len].rstrip("\n")
- tail = record[-tail_len:].lstrip("\n") if tail_len else ""
+ tail = record[-tail_len:].lstrip("\n")
elided = len(record) - len(head) - len(tail)
return head + marker_template.format(elided=elided) + tail