Limiting token usage with AI agents and long system prompts

I created an AI agent with a fairly long system prompt. It works, but the prompt is sent with every interaction, even if the user types “hello”.

What are the best practices to prevent this?

1 Like

Outside of context of n8n, I think the best practice for token preservation is prompt caching.

Here is also a guide about it on OpenAI here. Similar guides can be found for other major players. For the cache to stay valid the requests have to be happening pretty often though.

1 Like

Thanks, but this can be done only with API calls, not with the AI agent node and its tools, right?

1 Like

Correct, only with API right now (as far as I know).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.