server_stats

Gather OS-level server statistics for system prompt injection.

All heavy reads (/proc, psutil) are wrapped in asyncio.to_thread() so the event loop is never blocked.

Results are cached for 30 seconds to avoid redundant psutil reads on every inference.

async server_stats.get_server_stats(background_task_count=0)[source]

Return a dict of live server statistics.

Results are cached for 30 seconds to avoid redundant psutil reads.

Parameters:

background_task_count (int) – Number of currently active background tool tasks, provided by the caller (typically from TaskManager).

Return type:

dict[str, Any]