Skip to content

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

TypeScript

test(mcp-host): pin tool-call arguments in the heuristic count (#731)

Alfredo Lopez38f9aa81106d
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 8ee570bfc..65074c658 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.364",
+ "version": "0.1.365",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.364",
+ "version": "0.1.365",
"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 81e89ac35..4c87a1cbb 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.364",
+ "version": "0.1.365",
"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/tokenizer/__tests__/heuristic.test.ts b/mcp-host/src/core/tokenizer/__tests__/heuristic.test.ts
index 28c58407d..b6251e00e 100644
--- a/mcp-host/src/core/tokenizer/__tests__/heuristic.test.ts
+++ b/mcp-host/src/core/tokenizer/__tests__/heuristic.test.ts
@@ -40,6 +40,23 @@ describe('heuristicCount', () => {
}
expect(heuristicCount([msg])).toBeGreaterThanOrEqual(Math.ceil(content.length / 4))
})
+
+ it('T-A2 counts assistant tool_calls arguments', () => {
+ // #731 — the other half of the undercount. An assistant message that issues
+ // a tool call carries its payload in `tool_calls[].arguments`, never in
+ // `content`, so a count that reads `content` alone bills the whole call at
+ // the 4-token framing overhead. `openaiTokenCounter.ts:58-62` already walks
+ // `tool_calls`; the heuristic did not.
+ const args = JSON.parse(minifiedMcpResult(7, 4_000)) as Record<string, unknown>
+ const msg: ChatMessage = {
+ role: 'assistant',
+ content: '',
+ tool_calls: [{ id: 'call_7', name: 'crm_bulk_update', arguments: args }],
+ }
+ // `content` is empty, so everything above the framing overhead comes from
+ // the arguments: ~4,000 chars → ~1,000 tokens.
+ expect(heuristicCount([msg])).toBeGreaterThanOrEqual(1_000)
+ })
})
describe('heuristicCountTools', () => {