mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-05 11:49:46 +08:00
The fold loop counted only each exchange's archive text and always folded the oldest exchange, so one exchange over the plan was sent whole, and prior learner memory could push a fitting exchange over it. Fold the longest prefix of whole exchanges whose complete request fits: prior memory, the system instruction and the exchanges as _summarize() serializes them, plus a reserve for the length line. If even the oldest exchange doesn't fit, send no memory call; the watermark stays and the exchange stays in exact recall.