Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(mcp-host): require InLoopContextManager to count tool schemas (#731)

Alfredo Lopezcd13db900d1c
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 78c295a2d..abe164abb 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.408",
+ "version": "0.1.409",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.408",
+ "version": "0.1.409",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --git a/mcp-host/package.json b/mcp-host/package.json
index 8583d1b03..19e159f6c 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.408",
+ "version": "0.1.409",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --git a/mcp-host/src/core/extensions/__tests__/contextManager.test.ts b/mcp-host/src/core/extensions/__tests__/contextManager.test.ts
index 619ca7837..1ad83bba2 100644
--- a/mcp-host/src/core/extensions/__tests__/contextManager.test.ts
+++ b/mcp-host/src/core/extensions/__tests__/contextManager.test.ts
@@ -6,7 +6,8 @@ import { makeFakeConversation } from '../../conversation/__testing__/makeFakeCon
import { estimateTokens, splitTurns } from '../../conversation/compaction'
import type { LlmPort } from '../../interfaces'
import { validateToolLinkages } from '../../orchestration/toolUseLoop'
-import type { ChatMessage } from '../../types'
+import { heuristicCountTools } from '../../tokenizer/heuristic'
+import type { ChatMessage, ToolDefinition } from '../../types'
import {
InLoopContextManager,
PressureContextManager,
@@ -277,6 +278,28 @@ describe('InLoopContextManager', () => {
const userCount = result.filter(m => m.role === 'user').length
expect(userCount).toBe(3)
})
+
+ it('counts the tool schemas against its threshold, as PressureContextManager does', () => {
+ const msgs = generateMessages(10)
+ const tools: ToolDefinition[] = [
+ {
+ name: 'crm_search_contacts',
+ description: 'Search CRM contacts',
+ parameters: {
+ type: 'object',
+ properties: { q: { type: 'string', description: 'x'.repeat(4_000) } },
+ },
+ },
+ ]
+ // One token above the messages alone: the two outcomes below can only
+ // differ by the tools term.
+ const manager = new InLoopContextManager(estimateTokens(msgs) + 1, 3)
+ expect(heuristicCountTools(tools)).toBeGreaterThan(1)
+
+ expect(manager.manage(msgs, makeFakeConversation())).toBe(msgs)
+ const compacted = manager.manage(msgs, makeFakeConversation(), { tools })
+ expect(compacted.filter(m => m.role === 'user')).toHaveLength(3)
+ })
})
describe('splitTurns', () => {