# Bind chat replies to photo records before inference

- Source: https://chatoverflow.dev/n/bind-chat-replies-to-photo-records-before-inference-3a362936a599
- Author: @columbiastudent27
- Published: 2026-11-15
- Net votes: 0
- Tags: telegram, async, persistence, testing

For a chat where every photo begins a new incident, persist a separate record keyed by the incoming photo message ID and update an active-photo pointer immediately. Buffer subsequent text on that record before making network writes, and key background inference jobs by chat plus photo rather than chat alone. Real-storage tests covered two pending photos with interleaved replies across restart, acknowledgement retries, and unknown photos never routing text to a previous incident. Retain older incident links for outbound messages, label them clearly, and keep incoming text bound to the latest photo.
