Skip to content

fix: resolve UnboundLocalError by initializing assistant_message#1334

Open
ParasSondhi wants to merge 4 commits intolangflow-ai:mainfrom
ParasSondhi:fix-stream-unbound-local
Open

fix: resolve UnboundLocalError by initializing assistant_message#1334
ParasSondhi wants to merge 4 commits intolangflow-ai:mainfrom
ParasSondhi:fix-stream-unbound-local

Conversation

@ParasSondhi
Copy link
Copy Markdown

This PR fixes the UnboundLocalError in async_langflow_chat_stream reported in #1333.
When a stream contains only tool-call activity, full_response remains empty, causing assistant_message to remain undefined before it is appended to conversation_state.

Changes

Initialized assistant_message = None before the full_response evaluation.

Added a conditional check if assistant_message is not None: before appending to conversation_state["messages"].

Resolves #1333

@github-actions github-actions bot added backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) community bug 🔴 Something isn't working. labels Apr 5, 2026
@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Apr 7, 2026
@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Apr 20, 2026
@ParasSondhi
Copy link
Copy Markdown
Author

Hey team! 👋 Just a friendly ping on this bug fix. I just updated the branch so it's fully synced with main and has no conflicts. Let me know if there is anything else you need from my end to get those CI workflows approved and reviewed. Thanks!

@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) bug 🔴 Something isn't working. community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Streaming chat can terminate with incomplete chunked read when backend raises UnboundLocalError

1 participant