Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@civvic
Copy link
Contributor

@civvic civvic commented Jan 21, 2026

Demonstrates add_msg pollution bug across dialogs

Setup: Create two dialogs, 'dlg_a' and 'dlg_b'

In 'dlg_a', run this code in the same message:

msg1 = add_msg("Message in dlg_b", dname='dlg_b', placement='at_end')
print(f"Created {msg1} in dlg_b")
print(f"__msg_id is now: {__msg_id}")

# Now add a message to this dialog (dlg_a)

msg2 = add_msg("Message in same dialog")
print(f"Created {msg2} - should be in dlg_a, after msg1")

Bug:

msg2 doesn't get created anywhere because __msg_id in 'dlg_a' scope was set by the first add_msg call with a message id from dlg_b.

Impact: Any function that calls add_msg with different dname values pollutes the caller's __msg_id, breaking subsequent message placement. If the add_msg calls happen in different messages, __msg_id is reset to the message id and the issue won't happen.

Possible fix: add_msg should call set_var('__msg_id', ...) only if dname parameter is not set.

Workaround: Always pass explicit id and placement parameters when calling several add_msg after cross-dialog operations in one message.

@jph00
Copy link
Contributor

jph00 commented Jan 25, 2026

Thanks for the fix! :)

@jph00 jph00 merged commit 0cc7806 into AnswerDotAI:main Jan 25, 2026
@jph00 jph00 added the bug Something isn't working label Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants