[GH-ISSUE #4358] [BUG]: Failed to calculate number of tokens on agent request #2776

Closed
opened 2026-02-22 18:31:12 -05:00 by yindo · 3 comments
Owner

Originally created by @socketbox on GitHub (Sep 2, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4358

How are you running AnythingLLM?

Docker (local)

What happened?

Burned through my budget on a single agent request. This appeared in the console:

[backend] info: [AgentHandler] Attached rag-memory plugin to Agent cluster
[backend] info: [AgentHandler] Attached document-summarizer plugin to Agent cluster
[backend] info: [AgentHandler] Attached web-scraping plugin to Agent cluster
[backend] info: [AgentHandler] Attached web-browsing plugin to Agent cluster
[backend] info: [AgentHandler] Attached MCP::google-maps:maps_geocode MCP tool to Agent cluster
[backend] info: [AgentHandler] Attached MCP::google-maps:maps_reverse_geocode MCP tool to Agent cluster
[backend] info: [AgentHandler] Attached MCP::google-maps:maps_search_places MCP tool to Agent cluster
[backend] info: [AgentHandler] Attached MCP::google-maps:maps_place_details MCP tool to Agent cluster
[backend] info: [AgentHandler] Attached MCP::google-maps:maps_distance_matrix MCP tool to Agent cluster
[backend] info: [AgentHandler] Attached MCP::google-maps:maps_elevation MCP tool to Agent cluster
[backend] info: [AgentHandler] Attached MCP::google-maps:maps_directions MCP tool to Agent cluster
[backend] info: [AgentHandler] [debug]: @agent is attempting to call `web-browsing` tool
[backend] info: [AgentHandler] [debug]: @agent is attempting to call `web-browsing` tool
[backend] info: [AgentHandler] [debug]: @agent is attempting to call `web-browsing` tool
[backend] info: [AgentHandler] [debug]: @agent is attempting to call `web-scraping` tool
[backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data.
[collector] info: -- Working URL <myurl redacted> => (text) --
[collector] error: getPageContent failed to be fetched by puppeteer - falling back to fetch! TimeoutError: Navigation timeout of 180000 ms exceeded
    at new Deferred (file:///app/collector/node_modules/puppeteer-core/lib/esm/puppeteer/util/Deferred.js:23:34)
    at Deferred.create (file:///app/collector/node_modules/puppeteer-core/lib/esm/puppeteer/util/Deferred.js:65:16)
    at new LifecycleWatcher (file:///app/collector/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/LifecycleWatcher.js:72:46)
    at CdpFrame.goto (file:///app/collector/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Frame.js:138:29)
    at CdpFrame.<anonymous> (file:///app/collector/node_modules/puppeteer-core/lib/esm/puppeteer/util/decorators.js:104:27)
    at CdpPage.goto (file:///app/collector/node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.js:568:43)
    at PuppeteerWebBaseLoader._scrape (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:49:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PuppeteerWebBaseLoader.load (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:74:22)
    at async getPageContent (/app/collector/processLink/convert/generic.js:155:18)
[backend] info: [TokenManager] Returning existing instance for model: claude-sonnet-4-20250514
Failed to calculate number of tokens, falling back to approximate count Error: Unknown model
    at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13)
    at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59)
    at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75)
    at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44)
    at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28)
    at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15)
    at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22)
[backend] error: (node:131) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
[backend] warn: MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit
Failed to calculate number of tokens, falling back to approximate count Error: Unknown model
    at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13)
    at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59)
    at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75)
    at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44)
    at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28)
    at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15)
    at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22)
Failed to calculate number of tokens, falling back to approximate count Error: Unknown model
    at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13)
    at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59)
    at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75)
    at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44)
    at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28)
    at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15)
    at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22)
Failed to calculate number of tokens, falling back to approximate count Error: Unknown model
    at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13)
    at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59)
    at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75)
    at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44)
    at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28)
    at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15)
    at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22)
Failed to calculate number of tokens, falling back to approximate count Error: Unknown model
    at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13)
    at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59)
    at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75)
    at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44)
    at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28)
    at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15)
    at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22)
Failed to calculate number of tokens, falling back to approximate count Error: Unknown model
    at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13)
    at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59)
    at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75)
    at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44)
    at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28)
    at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15)
    at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22)
Failed to calculate number of tokens, falling back to approximate count Error: Unknown model
    at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13)
    at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59)
    at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75)
    at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44)
    at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28)
    at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15)
    at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22)
[backend] error:    error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Your credit balance is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase credits."},"request_id":"req_011CSjvbLBxBd1GW4jLbnsmB"} Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Your credit balance is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase credits."},"request_id":"req_011CSjvbLBxBd1GW4jLbnsmB"}
    at AnthropicProvider.complete (/app/server/utils/agents/aibitat/providers/anthropic.js:203:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:607:24)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:663:14)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:663:14)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:663:14)
    at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:663:14)
    at async AIbitat.reply (/app/server/utils/agents/aibitat/index.js:589:21)
    at async AIbitat.chat (/app/server/utils/agents/aibitat/index.js:387:15)
    at async AIbitat.start (/app/server/utils/agents/aibitat/index.js:321:5)
[backend] info: [AgentHandler] End 74198740-c4e2-4265-9bf3-f033716ddeef::anthropic:claude-sonnet-4-20250514

Are there known steps to reproduce?

No response

Originally created by @socketbox on GitHub (Sep 2, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4358 ### How are you running AnythingLLM? Docker (local) ### What happened? Burned through my budget on a single agent request. This appeared in the console: ``` [backend] info: [AgentHandler] Attached rag-memory plugin to Agent cluster [backend] info: [AgentHandler] Attached document-summarizer plugin to Agent cluster [backend] info: [AgentHandler] Attached web-scraping plugin to Agent cluster [backend] info: [AgentHandler] Attached web-browsing plugin to Agent cluster [backend] info: [AgentHandler] Attached MCP::google-maps:maps_geocode MCP tool to Agent cluster [backend] info: [AgentHandler] Attached MCP::google-maps:maps_reverse_geocode MCP tool to Agent cluster [backend] info: [AgentHandler] Attached MCP::google-maps:maps_search_places MCP tool to Agent cluster [backend] info: [AgentHandler] Attached MCP::google-maps:maps_place_details MCP tool to Agent cluster [backend] info: [AgentHandler] Attached MCP::google-maps:maps_distance_matrix MCP tool to Agent cluster [backend] info: [AgentHandler] Attached MCP::google-maps:maps_elevation MCP tool to Agent cluster [backend] info: [AgentHandler] Attached MCP::google-maps:maps_directions MCP tool to Agent cluster [backend] info: [AgentHandler] [debug]: @agent is attempting to call `web-browsing` tool [backend] info: [AgentHandler] [debug]: @agent is attempting to call `web-browsing` tool [backend] info: [AgentHandler] [debug]: @agent is attempting to call `web-browsing` tool [backend] info: [AgentHandler] [debug]: @agent is attempting to call `web-scraping` tool [backend] info: [EncryptionManager] Loaded existing key & salt for encrypting arbitrary data. [collector] info: -- Working URL <myurl redacted> => (text) -- [collector] error: getPageContent failed to be fetched by puppeteer - falling back to fetch! TimeoutError: Navigation timeout of 180000 ms exceeded at new Deferred (file:///app/collector/node_modules/puppeteer-core/lib/esm/puppeteer/util/Deferred.js:23:34) at Deferred.create (file:///app/collector/node_modules/puppeteer-core/lib/esm/puppeteer/util/Deferred.js:65:16) at new LifecycleWatcher (file:///app/collector/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/LifecycleWatcher.js:72:46) at CdpFrame.goto (file:///app/collector/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Frame.js:138:29) at CdpFrame.<anonymous> (file:///app/collector/node_modules/puppeteer-core/lib/esm/puppeteer/util/decorators.js:104:27) at CdpPage.goto (file:///app/collector/node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.js:568:43) at PuppeteerWebBaseLoader._scrape (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:49:20) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async PuppeteerWebBaseLoader.load (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:74:22) at async getPageContent (/app/collector/processLink/convert/generic.js:155:18) [backend] info: [TokenManager] Returning existing instance for model: claude-sonnet-4-20250514 Failed to calculate number of tokens, falling back to approximate count Error: Unknown model at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13) at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59) at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75) at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44) at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28) at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15) at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22) [backend] error: (node:131) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit (Use `node --trace-warnings ...` to show where the warning was created) [backend] warn: MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit Failed to calculate number of tokens, falling back to approximate count Error: Unknown model at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13) at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59) at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75) at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44) at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28) at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15) at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22) Failed to calculate number of tokens, falling back to approximate count Error: Unknown model at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13) at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59) at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75) at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44) at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28) at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15) at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22) Failed to calculate number of tokens, falling back to approximate count Error: Unknown model at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13) at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59) at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75) at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44) at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28) at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15) at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22) Failed to calculate number of tokens, falling back to approximate count Error: Unknown model at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13) at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59) at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75) at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44) at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28) at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15) at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22) Failed to calculate number of tokens, falling back to approximate count Error: Unknown model at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13) at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59) at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75) at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44) at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28) at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15) at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22) Failed to calculate number of tokens, falling back to approximate count Error: Unknown model at getEncodingNameForModel (/app/server/node_modules/js-tiktoken/dist/lite.cjs:230:13) at encodingForModel (/app/server/node_modules/@langchain/core/dist/utils/tiktoken.cjs:23:59) at ChatAnthropic.getNumTokens (/app/server/node_modules/@langchain/core/dist/language_models/base.cjs:182:75) at LLMChain._getNumTokens (/app/server/node_modules/langchain/dist/chains/llm_chain.cjs:212:44) at MapReduceDocumentsChain._call (/app/server/node_modules/langchain/dist/chains/combine_docs_chain.cjs:180:73) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MapReduceDocumentsChain.invoke (/app/server/node_modules/langchain/dist/chains/base.cjs:58:28) at async summarizeContent (/app/server/utils/agents/aibitat/utils/summarize.js:55:15) at async Object.handler (/app/server/utils/agents/aibitat/plugins/web-scraping.js:45:31) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:646:22) [backend] error: error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Your credit balance is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase credits."},"request_id":"req_011CSjvbLBxBd1GW4jLbnsmB"} Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Your credit balance is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase credits."},"request_id":"req_011CSjvbLBxBd1GW4jLbnsmB"} at AnthropicProvider.complete (/app/server/utils/agents/aibitat/providers/anthropic.js:203:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:607:24) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:663:14) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:663:14) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:663:14) at async AIbitat.handleExecution (/app/server/utils/agents/aibitat/index.js:663:14) at async AIbitat.reply (/app/server/utils/agents/aibitat/index.js:589:21) at async AIbitat.chat (/app/server/utils/agents/aibitat/index.js:387:15) at async AIbitat.start (/app/server/utils/agents/aibitat/index.js:321:5) [backend] info: [AgentHandler] End 74198740-c4e2-4265-9bf3-f033716ddeef::anthropic:claude-sonnet-4-20250514 ``` ### Are there known steps to reproduce? _No response_
yindo added the needs info / can't replicate label 2026-02-22 18:31:12 -05:00
yindo closed this issue 2026-02-22 18:31:12 -05:00
Author
Owner

@shatfield4 commented on GitHub (Sep 2, 2025):

It looks like this error is just being thrown because you ran out of credits. If you load your API key with more credits and test again does it fix the error? I tested it using the same model as you (claude-sonnet-4-20250514) and I am unable to replicate this bug.

@shatfield4 commented on GitHub (Sep 2, 2025): It looks like this error is just being thrown because you ran out of credits. If you load your API key with more credits and test again does it fix the error? I tested it using the same model as you (`claude-sonnet-4-20250514`) and I am unable to replicate this bug.
Author
Owner

@socketbox commented on GitHub (Sep 3, 2025):

Yes, I guess it's a question of whether the agent burned through the budget because that's the way it's been designed, or whether a failure state caused it to go awry. Since I'm unable to set a limit for the agent, I will re-run the same query when my balance is lower. Potentially related issues: #3348, #3679

@socketbox commented on GitHub (Sep 3, 2025): Yes, I guess it's a question of whether the agent burned through the budget because that's the way it's been designed, or whether a failure state caused it to go awry. Since I'm unable to set a limit for the agent, I will re-run the same query when my balance is lower. Potentially related issues: #3348, #3679
Author
Owner

@timothycarambat commented on GitHub (Sep 3, 2025):

Closed until repro just to cleanup the board

@timothycarambat commented on GitHub (Sep 3, 2025): Closed until repro just to cleanup the board
yindo changed title from [BUG]: Failed to calculate number of tokens on agent request to [GH-ISSUE #4358] [BUG]: Failed to calculate number of tokens on agent request 2026-06-05 14:48:30 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#2776