[model-gateway] Add Redis support as a history backend (#16300)

This commit is contained in:
Wenyi Xu
2026-01-11 01:03:00 -08:00
committed by GitHub
parent 7b089ae4e0
commit 3c16c58619
12 changed files with 1215 additions and 10 deletions
@@ -117,6 +117,9 @@ class RouterArgs:
oracle_pool_timeout_secs: int = 30
postgres_db_url: Optional[str] = None
postgres_pool_max: int = 16
redis_url: Optional[str] = None
redis_pool_max: int = 16
redis_retention_days: int = 30
# mTLS configuration for worker communication
client_cert_path: Optional[str] = None
client_key_path: Optional[str] = None
@@ -200,6 +203,9 @@ class RouterArgs:
postgres_group = parser.add_argument_group(
"PostgreSQL Database", "PostgreSQL database backend configuration"
)
redis_group = parser.add_argument_group(
"Redis Database", "Redis database backend configuration"
)
tls_group = parser.add_argument_group(
"TLS/mTLS Security", "TLS certificates for server and worker communication"
)
@@ -663,7 +669,7 @@ class RouterArgs:
f"--{prefix}history-backend",
type=str,
default=RouterArgs.history_backend,
choices=["memory", "none", "oracle", "postgres"],
choices=["memory", "none", "oracle", "postgres", "redis"],
help="History storage backend for conversations and responses (default: memory)",
)
@@ -733,6 +739,28 @@ class RouterArgs:
help="Maximum PostgreSQL connection pool size (default: 16, env: POSTGRES_POOL_MAX)",
)
# Redis configuration
redis_group.add_argument(
f"--{prefix}redis-url",
type=str,
default=os.getenv("REDIS_URL"),
help="Redis connection URL (env: REDIS_URL)",
)
redis_group.add_argument(
f"--{prefix}redis-pool-max",
type=int,
default=int(os.getenv("REDIS_POOL_MAX", RouterArgs.redis_pool_max)),
help="Maximum Redis connection pool size (default: 16, env: REDIS_POOL_MAX)",
)
redis_group.add_argument(
f"--{prefix}redis-retention-days",
type=int,
default=int(
os.getenv("REDIS_RETENTION_DAYS", RouterArgs.redis_retention_days)
),
help="Redis data retention in days (-1 for persistent, default: 30, env: REDIS_RETENTION_DAYS)",
)
# TLS/mTLS configuration
tls_group.add_argument(
f"--{prefix}client-cert-path",