mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 13:52:43 +08:00
2.4 KiB
2.4 KiB
Conversation Callback Processor
This module provides a framework for processing conversation events and sending summaries or notifications to external platforms like Slack and GitLab.
Overview
The conversation callback processor system consists of two main components:
- ConversationCallback: A database model that stores information about callbacks to be executed when specific conversation events occur.
- ConversationCallbackProcessor: An abstract base class that defines the interface for processors that handle conversation events.
How It Works
ConversationCallback
The ConversationCallback class is a database model that stores:
- A reference to a conversation (
conversation_id) - The current status of the callback (
ACTIVE,COMPLETED, orERROR) - The type of processor to use (
processor_type) - Serialized processor configuration (
processor_json) - Timestamps for creation and updates
This model provides methods to:
get_processor(): Dynamically instantiate the processor from the stored type and JSON dataset_processor(): Store a processor instance by serializing its type and data
ConversationCallbackProcessor
The ConversationCallbackProcessor is an abstract base class that defines the interface for all callback processors. It:
- Is a Pydantic model that can be serialized to/from JSON
- Requires implementing the
__call__method to process conversation events - Receives the callback instance and an
AgentStateChangedObservationwhen called
Implemented Processors
SlackCallbackProcessor
The SlackCallbackProcessor sends conversation summaries to Slack channels when specific agent state changes occur. It:
- Monitors for agent state changes to
AWAITING_USER_INPUTorFINISHED - Sends a summary instruction to the conversation if needed
- Extracts a summary from the conversation
- Sends the summary to the appropriate Slack channel
- Marks the callback as completed
GithubCallbackProcessor and GitlabCallbackProcessor
The GithubCallbackProcessor and GitlabCallbackProcessor send conversation summaries to GitHub / GitLab issues when specific agent state changes occur. They:
- Monitors for agent state changes to
AWAITING_USER_INPUTorFINISHED - Sends a summary instruction to the conversation if needed
- Extracts a summary from the conversation
- Sends the summary to the appropriate Github or GitLab issue
- Marks the callback as completed