π OpenHands: AI-Driven Development
fix(backend): fix callback state not persisting due to dual-session conflict (#12627)
Tim O'Farrell11c87caba402
diff --git a/enterprise/server/conversation_callback_processor/github_callback_processor.py b/enterprise/server/conversation_callback_processor/github_callback_processor.pyindex 403125001f..f87118f1ea 100644--- a/enterprise/server/conversation_callback_processor/github_callback_processor.py+++ b/enterprise/server/conversation_callback_processor/github_callback_processor.py@@ -14,7 +14,6 @@ from storage.conversation_callback import (ConversationCallback,ConversationCallbackProcessor,)-from storage.database import session_makerfrom openhands.core.logger import openhands_logger as loggerfrom openhands.core.schema.agent import AgentState@@ -108,13 +107,10 @@ class GithubCallbackProcessor(ConversationCallbackProcessor):f'[GitHub] Sent summary instruction to conversation {conversation_id} {summary_event}')- # Update the processor state+ # Update the processor state - the outer session will commit thisself.send_summary_instruction = Falsecallback.set_processor(self)callback.updated_at = datetime.now()- with session_maker() as session:- session.merge(callback)- session.commit()return# Extract the summary from the event store@@ -130,14 +126,15 @@ class GithubCallbackProcessor(ConversationCallbackProcessor):logger.info(f'[GitHub] Summary sent for conversation {conversation_id}')- # Mark callback as completed status+ # Mark callback as completed status - the outer session will commit thiscallback.status = CallbackStatus.COMPLETEDcallback.updated_at = datetime.now()- with session_maker() as session:- session.merge(callback)- session.commit()except Exception as e:logger.exception(f'[GitHub] Error processing conversation callback: {str(e)}')+ # Mark callback as error to prevent infinite re-invocation+ # The outer session will commit this+ callback.status = CallbackStatus.ERROR+ callback.updated_at = datetime.now()