Agent client can reconnect forever on stale SSE events
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
Research direction
Start by reading the reconnect loop in the agent SSE client that backs stream_events and stream_events_sync, and the point where the reconnect budget and the existing reconnect-exhausted error are handled. Compare the incoming event id against the stored resume cursor, treating Redis Stream ids numerically with a fallback for nonstandard ids, and make the budget reset only when the cursor advances. Done means a test where every reconnect replays the same id ends in the reconnect-exhausted error with no duplicate progress, while id-less events still pass through. Note a pull request (#46976) is already open against this.
Written by the indexing model from the issue text.
Description
Description
The Dify Agent SSE client resets its reconnect budget whenever it receives any event. A misbehaving or stale upstream can replay the same event ID after every reconnect, causing the client to move no further while repeatedly restoring the budget and yielding duplicate progress.
Steps to reproduce
- Start
stream_eventsorstream_events_syncwith reconnects enabled. - Let the first connection deliver a numbered event and disconnect.
- Have every subsequent connection replay the same event ID and disconnect again.
Current behavior
Each replayed event resets the reconnect counter, so a finite max_reconnects value may never be exhausted. The duplicate event is also delivered repeatedly.
Expected behavior
Only an event that advances the resume cursor should restore the reconnect budget. Duplicate or older numbered events should be ignored, and repeated stale reconnects should eventually raise the existing reconnect-exhausted error. Events without an ID should remain deliverable for compatibility but should not count as cursor progress.
Proposed change
Compare canonical Redis Stream IDs numerically, use a backward-compatible fallback for nonstandard IDs, and apply the same cursor-progress rule to synchronous and asynchronous streaming clients.
- Dominant language
- Python
- Stars
- 162k
- Forks
- 25.6k
- Avg merge
- 15h 9m
- Merged PRs (30d)
- 606
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from langgenius/dify
-
OpenSearch: text_exists() queries OpenSearch _id instead of metadata.doc_id, so it always returns False for indexed chunksPossibly taken @SanemIzci claimed this 1 day ago. Open🐞 bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
langgenius/dify#47109 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Log only execution identifiers when a workflow worker starts a runPossibly taken @kinglegendzzh claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langgenius/dify#47094 · 2 reactions ·
Maintainers usually reply within 1 day
-
Node.js SDK declares a response body for 204 conversation deletionPossibly taken @Wang-Zephyr claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
langgenius/dify#46883 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Provider IDs with a trailing newline are silently accepted and propagatedPossibly taken @Batianxieshen1 claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
langgenius/dify#46875 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Agent Python SDK polling rejects function-tool results that SSE acceptsPossibly taken @EndlessRoad-max claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
langgenius/dify#46868 · 1 reaction ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
micronaut-projects/micronaut-core#14585 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
langgenius/graphon#443 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
[BUG]: Management endpoints /v1/memory/stats and /v1/memory/counts bypass API key authenticationOpen
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
docling-project/docling-serve#788 ·
Maintainers usually reply within 1 day
-
Mend: dependency security vulnerability untriaged
Difficulty 1/5 Under an hour Newbie friendliness 78/100
opensearch-project/cross-cluster-replication#1805 ·
Maintainers usually reply within 1 day