mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-06 01:40:59 +08:00
The guard sized the request from message content alone. It ignored assistant tool_calls arguments and the tool schemas sent with the call, so a request over the window could go out untrimmed. - Count each message with the counter history planning uses, leaving out the _context_snapshot key that _call_llm strips before sending. - Pass the call's tool_schemas into the guard. The forced-finish round sends none, so it passes none. - Keep a running total while tool results are snipped instead of re-estimating the whole request after every snip. - Log a warning when nothing is left to trim and the request still does not fit, rather than passing it silently. With the call's tool schemas, the 8k reproduction from #1961 now trims all three tool results, taking the request from 10435 to 6514 tokens against a 7372-token budget. Refs #1961