assasin
02/28/2026, 3:42 PMasync function streamChatResponse(
validatedMessages: ChatUIMessage[],
model: AiModel = DEFAULT_AI_MODEL,
tools: ToolSet,
): Promise<ChatStreamResult> {
try {
const result: ChatStreamResult = streamText({
model: getModelInstance(model),
messages: await convertToModelMessages(validatedMessages),
tools,
stopWhen: stepCountIs(10),
onFinish: (event) => {
logger.info({ usage: event.usage }, `Stream finished`);
},
});
return result;
} catch (error) {
logger.error({ error, model }, 'Failed to stream chat response');
throw new Error('Failed to stream AI response', { cause: error });
}
}
When i pass in tools the system tokens shoots up from 200 to 7000. Any way to cache them? I cant seem to find anythingUday
02/28/2026, 3:59 PMCOMPOSIO_SEARCH_TOOLS to fetch tools based on use case. Doc for ref: https://docs.composio.dev/docs/tools-and-toolkits#meta-tools. Also, did you get a chance to checkout our chatbot on docs or Dashboard? It should really help you out.
Thanks!assasin
02/28/2026, 4:05 PMCOMPOSIO_SEARCH_TOOLS tool instead of session.tools() to pass the tools?assasin
02/28/2026, 4:05 PMassasin
02/28/2026, 4:07 PMassasin
03/01/2026, 3:42 AMUday
03/01/2026, 5:21 AMtools.get to obtain static tools and pass them to the LLM. This approach works well for deterministic scenarios and with a smaller number of tools. Another alternative is to manually execute COMPOSIO_SEARCH_TOOLS based on your specific use case to generate a list of relevant tools and pass it to the LLM.
Also, did you get a chance to checkout the chatbot I've mentioned earlier, it can help you with quicker responses, happy to help if the issue remains unresolved.