Skip to content

Commit d8bc624

Browse files
committed
chore: reduce verbose logging to stay under 256KB limit
- Remove debug console.log statements from gmail tools - Remove debug console.log statements from composio client - Log conversation length instead of full content - Log message/step counts instead of full arrays
1 parent 8f03499 commit d8bc624

File tree

4 files changed

+12
-60
lines changed

4 files changed

+12
-60
lines changed

apps/interaction-worker/src/services/process-message/generate-response.ts

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -221,68 +221,42 @@ ${participants.map((p) => `- ${p.id}: ${p.phoneNumber} (timezone: ${p.timezone ?
221221
const composioApiKey = env.COMPOSIO_API_KEY;
222222
const gmailAuthConfigId = env.COMPOSIO_GMAIL_AUTH_CONFIG_ID;
223223

224-
console.log("[gmail_connect] Tool created with config:", {
225-
userId: visitorUserId,
226-
hasApiKey: !!composioApiKey,
227-
authConfigId: gmailAuthConfigId,
228-
});
229-
230224
tools.gmail_connect = tool({
231225
description:
232226
"Connect the user's Gmail account via OAuth. If they already have a connection, this will disconnect and reconnect. The tool automatically sends the OAuth link to the user - do NOT send the URL again via send_message_to_user.",
233227
inputSchema: z.object({}),
234228
execute: async () => {
235-
console.log("[gmail_connect] Tool execute called");
236-
237229
// First check if user already has a Gmail connection and disconnect it
238230
const existingGmailConnection = activeConnections.find(
239231
(c) => c.app.toLowerCase() === "gmail",
240232
);
241233

242234
if (existingGmailConnection) {
243-
console.log(
244-
"[gmail_connect] Existing connection found, disconnecting first...",
245-
{ connectionId: existingGmailConnection.connectionId },
246-
);
247-
const disconnected = await disconnectAccount(
235+
await disconnectAccount(
248236
composioApiKey,
249237
existingGmailConnection.connectionId,
250238
);
251-
console.log("[gmail_connect] Disconnect result:", { disconnected });
252239
}
253240

254-
console.log("[gmail_connect] Calling initiateConnection...");
255-
256241
const result = await initiateConnection(
257242
composioApiKey,
258243
visitorUserId,
259244
gmailAuthConfigId,
260245
);
261246

262-
console.log("[gmail_connect] initiateConnection result:", {
263-
hasResult: !!result,
264-
hasRedirectUrl: !!result?.redirectUrl,
265-
redirectUrl: result?.redirectUrl,
266-
});
267-
268247
if (result?.redirectUrl) {
269-
const response = {
248+
return {
270249
success: true,
271250
url: result.redirectUrl,
272-
// This sendToUser field automatically sends the message to the user
273251
sendToUser: `Click here to connect your Gmail: ${result.redirectUrl}`,
274252
};
275-
console.log("[gmail_connect] Returning success:", response);
276-
return response;
277253
}
278254

279-
const errorResponse = {
255+
return {
280256
success: false,
281257
sendToUser:
282258
"Sorry, I couldn't generate a Gmail connection link right now. Please try again later.",
283259
};
284-
console.log("[gmail_connect] Returning error:", errorResponse);
285-
return errorResponse;
286260
},
287261
});
288262

@@ -295,8 +269,6 @@ ${participants.map((p) => `- ${p.id}: ${p.phoneNumber} (timezone: ${p.timezone ?
295269
"Disconnect the user's Gmail account. Use this when the user wants to reconnect their Gmail or when there are credential/authentication errors with their current Gmail connection.",
296270
inputSchema: z.object({}),
297271
execute: async () => {
298-
console.log("[gmail_disconnect] Tool execute called");
299-
300272
// Use cached connections to avoid redundant API call
301273
const gmailConnection = cachedConnections.find(
302274
(c) => c.app.toLowerCase() === "gmail",
@@ -310,14 +282,12 @@ ${participants.map((p) => `- ${p.id}: ${p.phoneNumber} (timezone: ${p.timezone ?
310282
};
311283
}
312284

313-
// Disconnect the account
314285
const disconnected = await disconnectAccount(
315286
composioApiKey,
316287
gmailConnection.connectionId,
317288
);
318289

319290
if (disconnected) {
320-
console.log("[gmail_disconnect] Successfully disconnected Gmail");
321291
return {
322292
success: true,
323293
sendToUser:

apps/interaction-worker/src/services/process-message/process-agent-completion.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ export const processAgentCompletion = async (
191191
isGroup: conversation.isGroup,
192192
});
193193

194-
logger.info("Formatted conversation", {
195-
formattedConversation,
194+
logger.info("Formatted conversation for agent processing", {
195+
conversationLength: formattedConversation.length,
196196
});
197197

198198
// Generate response from interaction agent
@@ -215,7 +215,6 @@ export const processAgentCompletion = async (
215215

216216
completionLogger.info("Generated response", {
217217
messageCount: messagesToUser.length,
218-
messages: messagesToUser,
219218
});
220219

221220
// If the interaction agent didn't produce messages but the execution agent failed,

apps/interaction-worker/src/services/process-message/process-message.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const processMessage = async (
9090
agentId: interactionAgent.id,
9191
})
9292
.info("Formatted conversation for agent processing", {
93-
formattedConversation,
93+
conversationLength: formattedConversation.length,
9494
});
9595

9696
const { messagesToUser, hasUserMessages, steps } = await generateResponse(
@@ -108,8 +108,8 @@ export const processMessage = async (
108108
agentId: interactionAgent.id,
109109
})
110110
.info("Generated AI response", {
111-
messagesToUser,
112-
steps,
111+
messageCount: messagesToUser.length,
112+
stepCount: steps?.length || 0,
113113
});
114114

115115
// Only send messages if the agent explicitly chose to respond to user

packages/clients/src/composio.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,39 +75,22 @@ export const initiateConnection = async (
7575
userId: string,
7676
authConfigId: string,
7777
): Promise<{ redirectUrl: string; connectionId: string } | null> => {
78-
console.log("[Composio] initiateConnection called", {
79-
userId,
80-
authConfigId,
81-
hasApiKey: !!apiKey,
82-
apiKeyPrefix: apiKey?.substring(0, 8),
83-
});
84-
8578
try {
8679
const composio = new Composio({ apiKey });
87-
console.log("[Composio] Client created, calling initiate...");
88-
8980
const connectionRequest = await composio.connectedAccounts.initiate(
9081
userId,
9182
authConfigId,
9283
);
9384

94-
console.log("[Composio] initiate response:", {
95-
hasRedirectUrl: !!connectionRequest.redirectUrl,
96-
redirectUrl: connectionRequest.redirectUrl,
97-
id: connectionRequest.id,
98-
fullResponse: JSON.stringify(connectionRequest),
99-
});
100-
10185
return {
10286
redirectUrl: connectionRequest.redirectUrl || "",
10387
connectionId: connectionRequest.id || "",
10488
};
10589
} catch (error) {
106-
console.error("[Composio] initiateConnection error:", {
107-
message: error instanceof Error ? error.message : String(error),
108-
stack: error instanceof Error ? error.stack : undefined,
109-
error,
110-
});
90+
console.error(
91+
"[Composio] initiateConnection error:",
92+
error instanceof Error ? error.message : String(error),
93+
);
11194
return null;
11295
}
11396
};

0 commit comments

Comments
 (0)