Skip to content

Commit 5f2ed4f

Browse files
CopilotBukeLy
andcommitted
Apply reply_to_id fix to error and timeout messages for consistency
Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
1 parent b41ae6c commit 5f2ed4f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

agent-sdk-client/consumer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,25 @@ async def process_message(message_data: dict) -> None:
154154

155155
except httpx.TimeoutException:
156156
logger.warning(f"Agent Server timeout for chat_id={message.chat_id}")
157+
reply_to_id = _get_reply_to_id(message.message_id, thread_id, message.message_thread_id)
157158
await bot.send_message(
158159
chat_id=message.chat_id,
159160
text="Request timed out.",
160161
message_thread_id=thread_id,
162+
reply_to_message_id=reply_to_id,
161163
)
162164
raise # Re-raise to trigger SQS retry for transient errors
163165

164166
except Exception as e:
165167
logger.exception(f"Agent Server error for chat_id={message.chat_id}")
166168
error_text = f"Error: {str(e)[:200]}"
169+
reply_to_id = _get_reply_to_id(message.message_id, thread_id, message.message_thread_id)
167170
try:
168171
await bot.send_message(
169172
chat_id=message.chat_id,
170173
text=error_text,
171174
message_thread_id=thread_id,
175+
reply_to_message_id=reply_to_id,
172176
)
173177
except Exception as send_error:
174178
logger.error(f"Failed to send error message to Telegram: {send_error}")

0 commit comments

Comments
 (0)