Skip to content

fix(lmi): bound Redis I/O in GlobalRateLimiter [CLD-320] - #464

Merged
ypicard merged 1 commit into
mainfrom
fix/bound-redis-io-rate-limiter
Jul 1, 2026
Merged

fix(lmi): bound Redis I/O in GlobalRateLimiter [CLD-320]#464
ypicard merged 1 commit into
mainfrom
fix/bound-redis-io-rate-limiter

Conversation

@ypicard

@ypicard ypicard commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Why

Agent trajectories were freezing forever, at random. Every LLM and embedding call goes through GlobalRateLimiter.try_acquire, which checks a Redis-backed rate limit. The coredis client was built with no socket timeout, so when an idle Redis connection got silently dropped (for example, an AWS NAT Gateway reaping the flow without sending a reset), the next Redis call blocked with nothing to break it. The existing acquire_timeout only bounds the polling sleep loop, not the Redis I/O, so the run hung indefinitely.

What changed

Pass stream_timeout and connect_timeout to RedisStorage. These flow through limits to coredis.Redis.from_url, so a stalled op now raises a bounded error instead of hanging. The error propagates to the caller rather than freezing the trajectory.

This is a minimal alternative to #460, which builds fail-open behavior, in-memory degradation, and auto-recovery on top of the same root fix. This PR does only the part that stops the freeze.

GlobalRateLimiter.try_acquire gates every LLM/embedding call on a Redis op
via coredis. The client was created with stream_timeout=None, so a silently
dropped idle connection made the await block forever; acquire_timeout only
bounds the asyncio.sleep polling loop, not the Redis I/O. Pass stream_timeout
and connect_timeout to RedisStorage so a stalled op raises a bounded coredis
error instead of hanging.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ypicard
ypicard requested review from jabra, maykcaldas and mskarlin July 1, 2026 23:20
@ypicard
ypicard marked this pull request as ready for review July 1, 2026 23:21
@ypicard
ypicard enabled auto-merge (squash) July 1, 2026 23:22
@ypicard
ypicard merged commit 9229eaf into main Jul 1, 2026
7 checks passed
@ypicard
ypicard deleted the fix/bound-redis-io-rate-limiter branch July 1, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants