mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 21:03:08 +00:00
chore: remove debug logging from agent-service
Removed all debug console.log statements from agent-service.ts to avoid polluting production logs. This addresses code review feedback from gemini-code-assist. Removed debug logs for: - sendMessage() entry and session state - Event emissions (started, message, stream, complete) - Provider execution - SDK session ID capture - Tool use detection - Queue processing - emitAgentEvent() calls Kept console.error logs for actual errors (session not found, execution errors, etc.) as they are useful for troubleshooting. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -144,27 +144,12 @@ export class AgentService {
|
|||||||
imagePaths?: string[];
|
imagePaths?: string[];
|
||||||
model?: string;
|
model?: string;
|
||||||
}) {
|
}) {
|
||||||
console.log('[AgentService] sendMessage() called:', {
|
|
||||||
sessionId,
|
|
||||||
messageLength: message?.length,
|
|
||||||
workingDirectory,
|
|
||||||
imageCount: imagePaths?.length || 0,
|
|
||||||
model,
|
|
||||||
});
|
|
||||||
|
|
||||||
const session = this.sessions.get(sessionId);
|
const session = this.sessions.get(sessionId);
|
||||||
if (!session) {
|
if (!session) {
|
||||||
console.error('[AgentService] ERROR: Session not found:', sessionId);
|
console.error('[AgentService] ERROR: Session not found:', sessionId);
|
||||||
throw new Error(`Session ${sessionId} not found`);
|
throw new Error(`Session ${sessionId} not found`);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[AgentService] Session found:', {
|
|
||||||
sessionId,
|
|
||||||
messageCount: session.messages.length,
|
|
||||||
isRunning: session.isRunning,
|
|
||||||
workingDirectory: session.workingDirectory,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (session.isRunning) {
|
if (session.isRunning) {
|
||||||
console.error('[AgentService] ERROR: Agent already running for session:', sessionId);
|
console.error('[AgentService] ERROR: Agent already running for session:', sessionId);
|
||||||
throw new Error('Agent is already processing a message');
|
throw new Error('Agent is already processing a message');
|
||||||
@@ -213,19 +198,16 @@ export class AgentService {
|
|||||||
session.abortController = new AbortController();
|
session.abortController = new AbortController();
|
||||||
|
|
||||||
// Emit started event so UI can show thinking indicator
|
// Emit started event so UI can show thinking indicator
|
||||||
console.log('[AgentService] Emitting "started" event for session:', sessionId);
|
|
||||||
this.emitAgentEvent(sessionId, {
|
this.emitAgentEvent(sessionId, {
|
||||||
type: 'started',
|
type: 'started',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Emit user message event
|
// Emit user message event
|
||||||
console.log('[AgentService] Emitting "message" event for session:', sessionId);
|
|
||||||
this.emitAgentEvent(sessionId, {
|
this.emitAgentEvent(sessionId, {
|
||||||
type: 'message',
|
type: 'message',
|
||||||
message: userMessage,
|
message: userMessage,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('[AgentService] Saving session messages');
|
|
||||||
await this.saveSession(sessionId, session.messages);
|
await this.saveSession(sessionId, session.messages);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -278,13 +260,8 @@ export class AgentService {
|
|||||||
const allowedTools = sdkOptions.allowedTools as string[] | undefined;
|
const allowedTools = sdkOptions.allowedTools as string[] | undefined;
|
||||||
|
|
||||||
// Get provider for this model
|
// Get provider for this model
|
||||||
console.log('[AgentService] Getting provider for model:', effectiveModel);
|
|
||||||
const provider = ProviderFactory.getProviderForModel(effectiveModel);
|
const provider = ProviderFactory.getProviderForModel(effectiveModel);
|
||||||
|
|
||||||
console.log(
|
|
||||||
`[AgentService] Using provider "${provider.getName()}" for model "${effectiveModel}"`
|
|
||||||
);
|
|
||||||
|
|
||||||
// Build options for provider
|
// Build options for provider
|
||||||
const options: ExecuteOptions = {
|
const options: ExecuteOptions = {
|
||||||
prompt: '', // Will be set below based on images
|
prompt: '', // Will be set below based on images
|
||||||
@@ -311,13 +288,6 @@ export class AgentService {
|
|||||||
// Set the prompt in options
|
// Set the prompt in options
|
||||||
options.prompt = promptContent;
|
options.prompt = promptContent;
|
||||||
|
|
||||||
console.log('[AgentService] Executing query via provider:', {
|
|
||||||
model: effectiveModel,
|
|
||||||
promptLength: typeof promptContent === 'string' ? promptContent.length : 'array',
|
|
||||||
hasConversationHistory: !!conversationHistory.length,
|
|
||||||
sdkSessionId: session.sdkSessionId,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Execute via provider
|
// Execute via provider
|
||||||
const stream = provider.executeQuery(options);
|
const stream = provider.executeQuery(options);
|
||||||
|
|
||||||
@@ -329,7 +299,6 @@ export class AgentService {
|
|||||||
// Capture SDK session ID from any message and persist it
|
// Capture SDK session ID from any message and persist it
|
||||||
if (msg.session_id && !session.sdkSessionId) {
|
if (msg.session_id && !session.sdkSessionId) {
|
||||||
session.sdkSessionId = msg.session_id;
|
session.sdkSessionId = msg.session_id;
|
||||||
console.log(`[AgentService] Captured SDK session ID: ${msg.session_id}`);
|
|
||||||
// Persist the SDK session ID to ensure conversation continuity across server restarts
|
// Persist the SDK session ID to ensure conversation continuity across server restarts
|
||||||
await this.updateSession(sessionId, { sdkSessionId: msg.session_id });
|
await this.updateSession(sessionId, { sdkSessionId: msg.session_id });
|
||||||
}
|
}
|
||||||
@@ -352,10 +321,6 @@ export class AgentService {
|
|||||||
currentAssistantMessage.content = responseText;
|
currentAssistantMessage.content = responseText;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
|
||||||
'[AgentService] Emitting "stream" event, text length:',
|
|
||||||
responseText.length
|
|
||||||
);
|
|
||||||
this.emitAgentEvent(sessionId, {
|
this.emitAgentEvent(sessionId, {
|
||||||
type: 'stream',
|
type: 'stream',
|
||||||
messageId: currentAssistantMessage.id,
|
messageId: currentAssistantMessage.id,
|
||||||
@@ -369,7 +334,6 @@ export class AgentService {
|
|||||||
};
|
};
|
||||||
toolUses.push(toolUse);
|
toolUses.push(toolUse);
|
||||||
|
|
||||||
console.log('[AgentService] Tool use detected:', toolUse.name);
|
|
||||||
this.emitAgentEvent(sessionId, {
|
this.emitAgentEvent(sessionId, {
|
||||||
type: 'tool_use',
|
type: 'tool_use',
|
||||||
tool: toolUse,
|
tool: toolUse,
|
||||||
@@ -385,7 +349,6 @@ export class AgentService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[AgentService] Emitting "complete" event');
|
|
||||||
this.emitAgentEvent(sessionId, {
|
this.emitAgentEvent(sessionId, {
|
||||||
type: 'complete',
|
type: 'complete',
|
||||||
messageId: currentAssistantMessage?.id,
|
messageId: currentAssistantMessage?.id,
|
||||||
@@ -783,8 +746,6 @@ export class AgentService {
|
|||||||
queue: session.promptQueue,
|
queue: session.promptQueue,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`[AgentService] Processing next queued prompt for session ${sessionId}`);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.sendMessage({
|
await this.sendMessage({
|
||||||
sessionId,
|
sessionId,
|
||||||
@@ -803,11 +764,6 @@ export class AgentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private emitAgentEvent(sessionId: string, data: Record<string, unknown>): void {
|
private emitAgentEvent(sessionId: string, data: Record<string, unknown>): void {
|
||||||
console.log('[AgentService] emitAgentEvent() called:', {
|
|
||||||
sessionId,
|
|
||||||
eventType: data.type,
|
|
||||||
dataKeys: Object.keys(data),
|
|
||||||
});
|
|
||||||
this.events.emit('agent:stream', { sessionId, ...data });
|
this.events.emit('agent:stream', { sessionId, ...data });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user