@benkhz/context-manager 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@benkhz/context-manager",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Provider-agnostic LLM context manager with tool execution, auto-compaction, reactive state, and an event bus.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -328,7 +328,11 @@ export class AIContextManager {
328
328
 
329
329
  /** Approximate context size in characters, measured on the active LLM-facing window */
330
330
  _charCount() {
331
- return this._activeMessages.reduce((n, m) => n + (m.content?.length ?? 0), 0)
331
+ return this._activeMessages.reduce((n, m) => {
332
+ const contentLen = m.content?.length ?? 0
333
+ const toolCallsLen = m.toolCalls ? JSON.stringify(m.toolCalls).length : 0
334
+ return n + contentLen + toolCallsLen
335
+ }, 0)
332
336
  }
333
337
 
334
338
  /** Hard truncation — drop oldest active messages down to compactKeepLast (no summary kept) */