agentscope-ai / agentscope-ai/agentscope

[Bug]: channel reply stream can block forever after Redis Pub/Sub disconnect

Abierto
#2,530 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
31.5k
Forks
3.5k
Merge medio
1 d 23 h
PR fusionados (30 d)
95

Descripción

## Bug description

The Redis-backed channel reply stream can remain blocked forever when its
Pub/Sub connection is reset after the subscription has become ready.

RedisMessageBus.subscribe() lets the connection exception escape after its
Pub/Sub feeder is closed. open_reply_stream() only handles cancellation of
that feeder, while _read() waits indefinitely on the local queue. The
session event has already been appended to the replay log by
publish_session_event(), but the reader never reconnects or replays the
event.

## Reproduction

Using the production RedisMessageBus and open_reply_stream() with a
fakeredis-backed client, inject the same
redis.exceptions.ConnectionError that a reset Redis connection raises after
the first subscription is ready. Then publish a terminal ReplyEndEvent via
publish_session_event().

Observed:

STREAM_OUTCOME=TimeoutError: reader remained blocked
PUBSUB_SUBSCRIPTIONS=1

The event is present in the replay log, but the reply reader remains pending
because the subscription task has exited and no new wake-up reaches its local
queue.

## Expected behavior

A channel reply stream should recover from a transient Redis Pub/Sub
disconnect, resubscribe, and replay events appended while the subscription
was unavailable. It should deliver the terminal event and finish normally.

## Impact

A Redis restart, connection reset, or brief network interruption can leave a
channel reply delivery task waiting indefinitely. The user may never receive
the final reply even though the event was durably written to the session
replay log.

## Related work

This is distinct from #2123 and #2124, which address the replay/live
subscription handoff and SSE replay window. Those changes do not recover a
reply stream after its Pub/Sub feeder task terminates.

I would like to take this fix myself. If this scope and direction look right, please explicitly confirm that I may implement it, and I will prepare a focused test-first PR. I will not start the implementation before maintainer approval.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.