microcompactHistory accepts fractional values for the QWEN_MC_KEEP_RECENT override because it parses the env var with Number(...) and only checks finiteness.
That value is later used as a count. JavaScript array slicing coerces a fractional keepRecent differently from the metadata calculation:
slice(-1.5) behaves like keeping 1 item
Math.min(count, 1.5) can report 1.5 in mediaKept
meta.keepRecent also exposes the fractional value
So QWEN_MC_KEEP_RECENT=1.5 can produce inconsistent diagnostic metadata even though retention counts should be integers.
Expected behavior: QWEN_MC_KEEP_RECENT and settings.toolResultsNumToKeep should resolve to positive safe integers. Fractional, unsafe, and non-finite values should fall back to the next source/default before keepRecent is used for slicing and metadata.
I can send a small fix with tests.
microcompactHistoryaccepts fractional values for theQWEN_MC_KEEP_RECENToverride because it parses the env var withNumber(...)and only checks finiteness.That value is later used as a count. JavaScript array slicing coerces a fractional
keepRecentdifferently from the metadata calculation:slice(-1.5)behaves like keeping 1 itemMath.min(count, 1.5)can report1.5inmediaKeptmeta.keepRecentalso exposes the fractional valueSo
QWEN_MC_KEEP_RECENT=1.5can produce inconsistent diagnostic metadata even though retention counts should be integers.Expected behavior:
QWEN_MC_KEEP_RECENTandsettings.toolResultsNumToKeepshould resolve to positive safe integers. Fractional, unsafe, and non-finite values should fall back to the next source/default beforekeepRecentis used for slicing and metadata.I can send a small fix with tests.