mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-03 06:40:20 +01:00
💸 fix: Model Identifier Edge Case in Agent Transactions (#11988)
* 🔧 fix: Add skippedAgentIds tracking in initializeClient error handling - Enhanced error handling in the initializeClient function to track agent IDs that are skipped during processing. This addition improves the ability to monitor and debug issues related to agent initialization failures. * 🔧 fix: Update model assignment in BaseClient to use instance model - Modified the model assignment in BaseClient to use `this.model` instead of `responseMessage.model`, clarifying that when using agents, the model refers to the agent ID rather than the model itself. This change improves code clarity and correctness in the context of agent usage. * 🔧 test: Add tests for recordTokenUsage model assignment in BaseClient - Introduced new test cases in BaseClient to ensure that the correct model is passed to the recordTokenUsage method, verifying that it uses this.model instead of the agent ID from responseMessage.model. This enhances the accuracy of token usage tracking in agent scenarios. - Improved error handling in the initializeClient function to log errors when processing agents, ensuring that skipped agent IDs are tracked for better debugging.
This commit is contained in:
parent
8b159079f5
commit
43ff3f8473
3 changed files with 59 additions and 2 deletions
|
|
@ -306,6 +306,7 @@ const initializeClient = async ({ req, res, signal, endpointOption }) => {
|
|||
}
|
||||
} catch (err) {
|
||||
logger.error(`[initializeClient] Error processing agent ${agentId}:`, err);
|
||||
skippedAgentIds.add(agentId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -315,7 +316,12 @@ const initializeClient = async ({ req, res, signal, endpointOption }) => {
|
|||
if (checkAgentInit(agentId)) {
|
||||
continue;
|
||||
}
|
||||
await processAgent(agentId);
|
||||
try {
|
||||
await processAgent(agentId);
|
||||
} catch (err) {
|
||||
logger.error(`[initializeClient] Error processing chain agent ${agentId}:`, err);
|
||||
skippedAgentIds.add(agentId);
|
||||
}
|
||||
}
|
||||
const chain = await createSequentialChainEdges([primaryConfig.id].concat(agent_ids), '{convo}');
|
||||
collectEdges(chain);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue