How to controll use of RAM

Hello guys,

I’m current using this config on my agent server with node:

cli.runApp(
new ServerOptions({
agent: path.resolve(
process.cwd(),
process.env.NODE_ENV === ‘development’
? ‘src/ai/agent.ts’
: ‘dist/ai/agent.js’,
),
jobMemoryLimitMB: 350,
jobMemoryWarnMB: 300,
}),
);

But only define a max of job memory no is the better solution, because when the user use this limit, just crash the connection. So, how can I “clear” memory to don’t crash? I can to define max of context? What is the best solution to do this scalable?