YueGuobin 7fcdb57615 feat(context-manager): improve context window management with tool token accounting
Enhanced the context window management system to properly account for tool definition tokens when trimming messages. The key changes include:

- Updated `trim_messages_for_context` function to accept `tool_tokens` parameter
- Modified token budget allocation logic to subtract tool tokens before message trimming
- Added detailed documentation explaining the token budget distribution between messages and tool definitions
- Implemented prioritized trimming strategy that preserves system messages and recent conversation history
- Added boundary case handling for scenarios where system messages or tools exceed available budget

The improvements ensure more accurate context window management by accounting for the ~1000-2000 tokens typically consumed by tool definitions that LangChain automatically includes in LLM requests.
2026-03-05 01:50:48 +08:00
..
2026-01-28 22:24:10 +08:00
2026-02-16 19:32:47 +08:00
2025-05-14 19:11:44 +02:00
2024-04-22 18:51:29 +07:00
2026-01-28 22:30:36 +08:00
2022-01-19 22:28:36 +10:30
2026-02-28 11:35:46 +08:00