Skip to main content

What this snippet demonstrates

This snippet shows how to configure:
  1. Timeout middleware to bound slow provider calls
  2. Redis connection pooling for shared cache or memory connections
  3. Shutdown handling so runners and Redis pools close cleanly

Timeout middleware

Apply per-request timeouts to prevent runaway LLM calls:

Per-request timeout override

Redis connection pooling

For Redis deployments, use connection pooling instead of creating a new client per request:

Using with memory store

Full example

Configuration reference

TimeoutConfig

PoolConfig