Skip to content

Fix synapse variable shadowing in dendrite_with_retries#83

Open
sniper-noob wants to merge 1 commit into
It-s-AI:mainfrom
sniper-noob:fix/synapse-variable-shadowing
Open

Fix synapse variable shadowing in dendrite_with_retries#83
sniper-noob wants to merge 1 commit into
It-s-AI:mainfrom
sniper-noob:fix/synapse-variable-shadowing

Conversation

@sniper-noob
Copy link
Copy Markdown

@sniper-noob sniper-noob commented Mar 14, 2026

The loop variable synapse shadows the function parameter synapse. On retry attempts, the original query is lost and replaced with the last response from the previous iteration.

Fix: Rename loop variable from synapse to resp.

Example:

  • Before: synapse param gets overwritten by loop
    for i, synapse in enumerate(responses): # overwrites param!

  • 2nd retry: synapse is now responses[-1], not original query

  • After: param preserved
    for i, resp in enumerate(responses): # param intact

  • 2nd retry: synapse is still the original query

The loop `for i, synapse in enumerate(responses)` shadows the function parameter `synapse` (the original query TextSynapse). On retry attempts, the original query is lost and replaced with the last response from the previous iteration, sending corrupted data on retries.

Fix: Rename loop variable from `synapse` to `resp` to preserve the original parameter.

Example:
  dendrite_with_retries(synapse=TextSynapse(texts=["hello"]), cnt_attempts=3)

  Before (BUG):
    Attempt 1: sends correct synapse -> responses come back
    for i, synapse in enumerate(responses):  # synapse param overwritten!
    Attempt 2: sends responses[-1] instead of original query -> wrong data

  After (FIX):
    Attempt 1: sends correct synapse -> responses come back
    for i, resp in enumerate(responses):  # synapse param preserved
    Attempt 2: sends original synapse again -> correct retry behavior
@sniper-noob sniper-noob force-pushed the fix/synapse-variable-shadowing branch from 295d4a0 to 69c7464 Compare March 14, 2026 23:12
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.

1 participant