Skip to content

Commit 82bfc7a

Browse files
committed
🤖 fix: reduce noisy tool errors on abort
Change-Id: I5cf741604f12af5586f6245ae890678405a402a7 Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent 9357ca3 commit 82bfc7a

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/node/services/providerService.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ export type { AWSCredentialStatus, ProviderConfigInfo, ProvidersConfigMap };
1515
export class ProviderService {
1616
private readonly emitter = new EventEmitter();
1717

18-
constructor(private readonly config: Config) {}
18+
constructor(private readonly config: Config) {
19+
// The provider config subscription may have many concurrent listeners (e.g. multiple windows).
20+
// Avoid noisy MaxListenersExceededWarning for normal usage.
21+
this.emitter.setMaxListeners(50);
22+
}
1923

2024
/**
2125
* Subscribe to config change events. Used by oRPC subscription handler.

src/node/services/streamManager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,8 @@ export class StreamManager extends EventEmitter {
10261026
error: unknown;
10271027
};
10281028

1029-
log.error(`Tool execution error for '${toolErrorPart.toolName}'`, {
1029+
const logLevel = streamInfo.abortController.signal.aborted ? log.debug : log.error;
1030+
logLevel(`Tool execution error for '${toolErrorPart.toolName}'`, {
10301031
toolCallId: toolErrorPart.toolCallId,
10311032
error: toolErrorPart.error,
10321033
});

src/node/services/tools/task.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export const createTaskTool: ToolFactory = (config: ToolConfiguration) => {
1414
const workspaceId = requireWorkspaceId(config, "task");
1515
const taskService = requireTaskService(config, "task");
1616

17+
if (abortSignal?.aborted) {
18+
throw new Error("Interrupted");
19+
}
20+
1721
const modelString =
1822
config.muxEnv && typeof config.muxEnv.MUX_MODEL_STRING === "string"
1923
? config.muxEnv.MUX_MODEL_STRING

0 commit comments

Comments
 (0)