Skip to content

Commit f703e90

Browse files
committed
fix: remove tool_count_number, it is not required
1 parent 0448298 commit f703e90

File tree

6 files changed

+2
-180
lines changed

6 files changed

+2
-180
lines changed

src/const.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ export const MCP_SERVER_CACHE_MAX_SIZE = 500;
7878
export const MCP_SERVER_CACHE_TTL_SECS = 30 * 60; // 30 minutes
7979
export const USER_CACHE_MAX_SIZE = 200;
8080
export const USER_CACHE_TTL_SECS = 60 * 60; // 1 hour
81-
export const SESSION_TOOL_CALL_COUNTER_CACHE_MAX_SIZE = 200;
82-
export const SESSION_TOOL_CALL_COUNTER_CACHE_TTL_SECS = 60 * 60; // 1 hour
8381

8482
export const ACTOR_PRICING_MODEL = {
8583
/** Rental Actors */

src/index-internals.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { processParamsGetTools } from './mcp/utils.js';
88
import { addTool } from './tools/helpers.js';
99
import { defaultTools, getActorsAsTools, toolCategories, toolCategoriesEnabledByDefault } from './tools/index.js';
1010
import { actorNameToToolName } from './tools/utils.js';
11-
import type { ToolCallCounterStore, ToolCategory } from './types.js';
11+
import type { ToolCategory } from './types.js';
1212
import { getExpectedToolNamesByCategories, getToolPublicFieldOnly } from './utils/tools.js';
1313
import { TTLLRUCache } from './utils/ttl-lru.js';
1414

@@ -24,7 +24,6 @@ export {
2424
toolCategories,
2525
toolCategoriesEnabledByDefault,
2626
type ToolCategory,
27-
type ToolCallCounterStore,
2827
processParamsGetTools,
2928
getActorsAsTools,
3029
getToolPublicFieldOnly,

src/mcp/server.ts

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import {
3232
HelperTools,
3333
SERVER_NAME,
3434
SERVER_VERSION,
35-
SESSION_TOOL_CALL_COUNTER_CACHE_MAX_SIZE,
36-
SESSION_TOOL_CALL_COUNTER_CACHE_TTL_SECS,
3735
SKYFIRE_PAY_ID_PROPERTY_DESCRIPTION,
3836
SKYFIRE_README_CONTENT,
3937
SKYFIRE_TOOL_INSTRUCTIONS,
@@ -48,7 +46,6 @@ import type {
4846
ActorsMcpServerOptions,
4947
ActorTool,
5048
HelperTool,
51-
ToolCallCounterStore,
5249
ToolCallTelemetryProperties,
5350
ToolEntry,
5451
} from '../types.js';
@@ -58,7 +55,6 @@ import { logHttpError } from '../utils/logging.js';
5855
import { buildMCPResponse } from '../utils/mcp.js';
5956
import { createProgressTracker } from '../utils/progress.js';
6057
import { cloneToolEntry, getToolPublicFieldOnly } from '../utils/tools.js';
61-
import { TTLLRUCache } from '../utils/ttl-lru.js';
6258
import { getUserIdFromTokenCached } from '../utils/userid-cache.js';
6359
import { getPackageVersion } from '../utils/version.js';
6460
import { connectMCPClient } from './client.js';
@@ -81,13 +77,6 @@ export class ActorsMcpServer {
8177
// Telemetry configuration (resolved from options and env vars in setupTelemetry)
8278
private telemetryEnabled: boolean | null = null;
8379
private telemetryEnv: TelemetryEnv = DEFAULT_TELEMETRY_ENV;
84-
private toolCallCountStore: ToolCallCounterStore | undefined;
85-
86-
// In-memory storage for tool call counters (used when toolCallCountStore is not provided)
87-
private sessionToolCallCounters = new TTLLRUCache<number>(
88-
SESSION_TOOL_CALL_COUNTER_CACHE_MAX_SIZE,
89-
SESSION_TOOL_CALL_COUNTER_CACHE_TTL_SECS,
90-
);
9180

9281
constructor(options: ActorsMcpServerOptions = {}) {
9382
this.options = options;
@@ -124,15 +113,6 @@ export class ActorsMcpServer {
124113
this.setupResourceHandlers();
125114
}
126115

127-
/**
128-
* Gets and increments the tool call counter for a session.
129-
* @param sessionId - The session ID
130-
* @returns Promise resolving to the new counter value (after increment)
131-
*/
132-
private async getAndIncrementToolCallCounter(sessionId: string): Promise<number> {
133-
return await this.toolCallCountStore?.getAndIncrement(sessionId) ?? 0;
134-
}
135-
136116
/**
137117
* Telemetry configuration with precedence: explicit options > env vars > defaults
138118
*/
@@ -145,34 +125,12 @@ export class ActorsMcpServer {
145125
this.telemetryEnabled = envEnabled ?? DEFAULT_TELEMETRY_ENABLED;
146126
}
147127

148-
// Setup tool call counter store only if telemetry is enabled
128+
// Configure telemetryEnv: explicit option > env var > default ('PROD')
149129
if (this.telemetryEnabled) {
150-
// Configure telemetryEnv: explicit option > env var > default ('PROD')
151130
this.telemetryEnv = getTelemetryEnv(this.options.telemetry?.env ?? process.env.TELEMETRY_ENV);
152-
153-
if (this.options.telemetry?.toolCallCountStore) {
154-
this.toolCallCountStore = this.options.telemetry.toolCallCountStore;
155-
} else {
156-
this.toolCallCountStore = {
157-
getAndIncrement: async (sessionId: string): Promise<number> => {
158-
const current = this.sessionToolCallCounters.get(sessionId) ?? 0;
159-
const newValue = current + 1;
160-
this.sessionToolCallCounters.set(sessionId, newValue);
161-
return newValue;
162-
},
163-
};
164-
}
165131
}
166132
}
167133

168-
/**
169-
* Gets the tool call counter store (for testing purposes)
170-
* @internal
171-
*/
172-
public getToolCallCountStore(): ToolCallCounterStore | undefined {
173-
return this.toolCallCountStore;
174-
}
175-
176134
/**
177135
* Returns an array of tool names.
178136
* @returns {string[]} - An array of tool names.
@@ -808,16 +766,6 @@ Please verify the tool name and ensure the tool is properly registered.`;
808766

809767
const toolFullName = tool.type === 'actor' ? tool.actorFullName : tool.name;
810768

811-
// Get or increment tool call counter for this session
812-
let toolCallNumber = 0;
813-
if (mcpSessionId) {
814-
try {
815-
toolCallNumber = await this.getAndIncrementToolCallCounter(mcpSessionId);
816-
} catch (error) {
817-
log.warning('Failed to get tool call counter', { mcpSessionId, error: String(error) });
818-
}
819-
}
820-
821769
// Get userId from cache or fetch from API
822770
let userId: string | null = null;
823771
if (apifyToken) {
@@ -839,7 +787,6 @@ Please verify the tool name and ensure the tool is properly registered.`;
839787
tool_name: toolFullName,
840788
tool_status: 'succeeded', // Will be updated in finally
841789
tool_exec_time_ms: 0, // Will be calculated in finally
842-
tool_call_number: toolCallNumber,
843790
};
844791

845792
return { telemetryData, userId };

src/types.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -309,20 +309,6 @@ export interface ToolCallTelemetryProperties {
309309
tool_name: string;
310310
tool_status: 'succeeded' | 'failed' | 'aborted';
311311
tool_exec_time_ms: number;
312-
tool_call_number: number;
313-
}
314-
315-
/**
316-
* Interface for storing and retrieving tool call counters per session.
317-
* Used for tracking tool call sequence in user journeys.
318-
*/
319-
export interface ToolCallCounterStore {
320-
/**
321-
* Gets and increments the tool call counter for a session atomically.
322-
* @param sessionId - The session ID
323-
* @returns Promise resolving to the new counter value (after increment)
324-
*/
325-
getAndIncrement(sessionId: string): Promise<number>;
326312
}
327313

328314
/**
@@ -351,12 +337,6 @@ export interface ActorsMcpServerOptions {
351337
* - 'PROD': Use production Segment write key (default)
352338
*/
353339
env?: TelemetryEnv;
354-
/**
355-
* Optional store for tool call counters.
356-
* If not provided, uses in-memory storage (suitable for stdio).
357-
* For distributed deployments (HTTP/SSE), provide a Redis-backed implementation.
358-
*/
359-
toolCallCountStore?: ToolCallCounterStore;
360340
};
361341
/**
362342
* Transport type for telemetry tracking.

tests/unit/mcp.server.tool-call-counter.test.ts

Lines changed: 0 additions & 99 deletions
This file was deleted.

tests/unit/telemetry.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ describe('telemetry', () => {
2929
tool_name: 'test-tool',
3030
tool_status: 'succeeded' as const,
3131
tool_exec_time_ms: 100,
32-
tool_call_number: 1,
3332
};
3433

3534
trackToolCall(userId, 'DEV', properties);
@@ -49,7 +48,6 @@ describe('telemetry', () => {
4948
tool_name: 'test-tool',
5049
tool_status: 'succeeded',
5150
tool_exec_time_ms: 100,
52-
tool_call_number: 1,
5351
},
5452
});
5553
});
@@ -67,7 +65,6 @@ describe('telemetry', () => {
6765
tool_name: 'test-tool',
6866
tool_status: 'succeeded' as const,
6967
tool_exec_time_ms: 100,
70-
tool_call_number: 1,
7168
};
7269

7370
trackToolCall(null, 'DEV', properties);

0 commit comments

Comments
 (0)