📞 fix: Model End Callback and Streamline Client Cleanup (#10438)

* fix: update agent context handling in ModelEndHandler due to new MultiAgentGraph

* refactor: streamline client cleanup process by utilizing property arrays for potential circular reference removal
This commit is contained in:
Danny Avila 2025-11-10 13:50:17 -05:00 committed by GitHub
parent 360ec22964
commit 09c309bc78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 97 additions and 57 deletions

View file

@ -41,7 +41,11 @@ class ModelEndHandler {
}
try {
if (metadata.provider === Providers.GOOGLE || graph.clientOptions?.disableStreaming) {
const agentContext = graph.getAgentContext(metadata);
if (
agentContext.provider === Providers.GOOGLE ||
agentContext.clientOptions?.disableStreaming
) {
handleToolCalls(data?.output?.tool_calls, metadata, graph);
}
@ -49,14 +53,13 @@ class ModelEndHandler {
if (!usage) {
return;
}
if (metadata?.model) {
usage.model = metadata.model;
const modelName = metadata?.ls_model_name || agentContext.clientOptions?.model;
if (modelName) {
usage.model = modelName;
}
this.collectedUsage.push(usage);
const streamingDisabled = !!(
graph.clientOptions?.disableStreaming || graph?.boundModel?.disableStreaming
);
const streamingDisabled = !!agentContext.clientOptions?.disableStreaming;
if (!streamingDisabled) {
return;
}