extract console error to util func (#11675)

This commit is contained in:
Abhi
2025-10-22 16:09:10 -04:00
committed by GitHub
parent a7faa2080f
commit b40f67b76a
9 changed files with 19 additions and 63 deletions

View File

@@ -1199,24 +1199,13 @@ export class Config {
!allowedTools || allowedTools.includes(definition.name);
if (isAllowed && !isExcluded) {
try {
const messageBusEnabled = this.getEnableMessageBusIntegration();
const wrapper = new SubagentToolWrapper(
definition,
this,
messageBusEnabled ? this.getMessageBus() : undefined,
);
registry.registerTool(wrapper);
} catch (error) {
console.error(
`Failed to wrap agent '${definition.name}' as a tool:`,
error,
);
}
} else if (this.getDebugMode()) {
debugLogger.log(
`[Config] Skipping registration of agent '${definition.name}' due to allow/exclude configuration.`,
const messageBusEnabled = this.getEnableMessageBusIntegration();
const wrapper = new SubagentToolWrapper(
definition,
this,
messageBusEnabled ? this.getMessageBus() : undefined,
);
registry.registerTool(wrapper);
}
}
}

View File

@@ -1502,9 +1502,8 @@ ${JSON.stringify(
break;
}
}
} catch (error) {
} catch (_) {
// If the test framework times out, that also demonstrates the infinite loop
console.error('Test timed out or errored:', error);
}
// Assert that the fix works - the loop should stop at MAX_TURNS

View File

@@ -267,7 +267,7 @@ class MemoryToolInvocation extends BaseToolInvocation<
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);
console.error(
console.warn(
`[MemoryTool] Error executing save_memory for fact "${fact}": ${errorMessage}`,
);
return {

View File

@@ -107,10 +107,6 @@ describe('summarizers', () => {
expect(mockGeminiClient.generateContent).toHaveBeenCalledTimes(1);
expect(result).toBe(longText);
expect(console.error).toHaveBeenCalledWith(
'Failed to summarize tool output.',
error,
);
});
it('should construct the correct prompt for summarization', async () => {

View File

@@ -13,6 +13,7 @@ import type {
import type { GeminiClient } from '../core/client.js';
import { DEFAULT_GEMINI_FLASH_LITE_MODEL } from '../config/models.js';
import { getResponseText, partToString } from './partUtils.js';
import { debugLogger } from './debugLogger.js';
/**
* A function that summarizes the result of a tool execution.
@@ -90,7 +91,7 @@ export async function summarizeToolOutput(
)) as unknown as GenerateContentResponse;
return getResponseText(parsedResponse) || textToSummarize;
} catch (error) {
console.error('Failed to summarize tool output.', error);
debugLogger.warn('Failed to summarize tool output.', error);
return textToSummarize;
}
}