Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): count tool schemas in InLoopContextManager's threshold (#731)
Alfredo Lopezb61f2d73aa8c
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex abe164abb..fc2138ea3 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.409",+ "version": "0.1.410","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.409",+ "version": "0.1.410","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex 19e159f6c..75ad4fad9 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.409",+ "version": "0.1.410","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/contextManager.ts b/mcp-host/src/core/extensions/contextManager.tsindex fdbf1d941..191f85202 100644--- a/mcp-host/src/core/extensions/contextManager.ts+++ b/mcp-host/src/core/extensions/contextManager.ts@@ -742,13 +742,15 @@ export class InLoopContextManager implements ContextManager {manage(messages: ChatMessage[],conversation: Conversation,- _options?: ContextManageOptions+ options?: ContextManageOptions): ChatMessage[] {// IronClaw invariant #1 — same defensive guard as PressureContextManager.if (conversation.pending_approval !== undefined) {return messages}- const estimated = estimateTokens(messages)+ // The tool schemas travel with every request, so they count against the+ // threshold exactly as in PressureContextManager.computePressure.+ const estimated = estimateTokens(messages) + heuristicCountTools(options?.tools ?? [])if (estimated < this.thresholdTokens) {return messages // Passthrough