clodds 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/index.js +3 -1
- package/dist/agents/index.js.map +1 -1
- package/package.json +1 -1
package/dist/agents/index.js
CHANGED
|
@@ -16350,13 +16350,15 @@ async function createAgentManager(config, feeds, db, sessionManager, sendMessage
|
|
|
16350
16350
|
};
|
|
16351
16351
|
const contextManager = (0, context_1.createContextManager)(contextConfig, memory);
|
|
16352
16352
|
const effectiveMaxTokens = (contextConfig.maxTokens ?? 128000) - (contextConfig.reserveTokens ?? 4096);
|
|
16353
|
+
// Estimate tool definitions once (they don't change during the conversation)
|
|
16354
|
+
const toolsTokenEstimate = (0, context_1.estimateTokens)(JSON.stringify(tools), modelId);
|
|
16353
16355
|
const estimateSubmitTokens = () => {
|
|
16354
16356
|
const system = (0, context_1.estimateTokens)(finalSystemPrompt, modelId);
|
|
16355
16357
|
const msgs = messages.reduce((sum, m) => {
|
|
16356
16358
|
const content = typeof m.content === 'string' ? m.content : JSON.stringify(m.content);
|
|
16357
16359
|
return sum + (0, context_1.estimateTokens)(content, modelId) + 4;
|
|
16358
16360
|
}, 0);
|
|
16359
|
-
return system + msgs;
|
|
16361
|
+
return system + msgs + toolsTokenEstimate;
|
|
16360
16362
|
};
|
|
16361
16363
|
// Add all messages to context manager for tracking
|
|
16362
16364
|
for (const msg of messages) {
|