refactor: Prevent memory leaks by nullifying boundModel.client in disposeClient function

This commit is contained in:
Danny Avila 2025-04-13 11:09:01 -04:00
parent 59818c77ba
commit a326c18b74
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
2 changed files with 5 additions and 0 deletions

View file

@ -238,6 +238,9 @@ function disposeClient(client) {
client.run.Graph.streamBuffer = null; client.run.Graph.streamBuffer = null;
client.run.Graph.clientOptions = null; client.run.Graph.clientOptions = null;
client.run.Graph.graphState = null; client.run.Graph.graphState = null;
if (client.run.Graph.boundModel?.client) {
client.run.Graph.boundModel.client = null;
}
client.run.Graph.boundModel = null; client.run.Graph.boundModel = null;
client.run.Graph.systemMessage = null; client.run.Graph.systemMessage = null;
client.run.Graph.reasoningKey = null; client.run.Graph.reasoningKey = null;

View file

@ -787,6 +787,8 @@ class AgentClient extends BaseClient {
[Callback.TOOL_ERROR]: logToolError, [Callback.TOOL_ERROR]: logToolError,
}, },
}); });
config.signal = null;
}; };
await runAgent(this.options.agent, initialMessages); await runAgent(this.options.agent, initialMessages);