Implementation:OpenHands OpenHands SlackV1CallbackProcessor
| Knowledge Sources | |
|---|---|
| Domains | Platform_Integration, Slack_API, Conversation_Management |
| Last Updated | 2026-02-11 21:00 GMT |
Overview
Concrete tool for posting conversation summaries to Slack channels upon agent conversation completion, provided by the OpenHands enterprise Slack integration layer.
Description
The SlackV1CallbackProcessor class implements a callable callback that is invoked when an agent conversation reaches a terminal state (success, failure, or timeout). Its purpose is to generate a human-readable summary of the conversation and deliver it to the originating Slack channel or thread.
The __call__ method is the entry point, invoked by the conversation lifecycle manager when a conversation completes. It receives the conversation result context, orchestrates the summary generation, and triggers the Slack delivery. This method acts as a coordinator, delegating to the two internal helper methods.
The _request_summary method takes the completed conversation history and generates a concise summary. It prepares the conversation turns, agent actions, and outcomes into a structured prompt, then calls the language model to produce a natural-language summary suitable for posting in a Slack message. The summary includes key details such as what was requested, what actions the agent took, and the final outcome.
The _post_summary_to_slack method handles the Slack API interaction. It authenticates using the stored Slack bot token, constructs the message payload with appropriate formatting (Slack Block Kit or mrkdwn), and posts the summary to the correct channel and thread. It handles API errors gracefully, logging failures without propagating exceptions to avoid disrupting the conversation cleanup pipeline.
Usage
Use SlackV1CallbackProcessor as the callback handler for Slack-originated conversations. Register it during conversation creation so that it is automatically invoked when the conversation ends. The processor requires a valid Slack bot token and channel context to function.
Code Reference
Source Location
- Repository: OpenHands
- File: enterprise/integrations/slack/slack_v1_callback_processor.py
- Lines: 1-273
Signature
class SlackV1CallbackProcessor:
async def __call__(
self,
conversation_result: ConversationResult,
) -> None:
...
async def _request_summary(
self,
conversation_history: list[dict],
) -> str:
...
async def _post_summary_to_slack(
self,
channel_id: str,
thread_ts: str | None,
summary: str,
) -> None:
...
Import
from enterprise.integrations.slack.slack_v1_callback_processor import SlackV1CallbackProcessor
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| conversation_result | ConversationResult |
Yes | The terminal result of the conversation including status, conversation history, and metadata (for __call__) |
| conversation_history | list[dict] |
Yes | Ordered list of conversation turns containing agent actions and observations (for _request_summary) |
| channel_id | str |
Yes | The Slack channel ID where the summary should be posted (for _post_summary_to_slack) |
| thread_ts | str or None |
No | The Slack thread timestamp to post the summary as a threaded reply; if None, posts as a top-level message (for _post_summary_to_slack)
|
| summary | str |
Yes | The generated natural-language summary text to post (for _post_summary_to_slack) |
Outputs
| Name | Type | Description |
|---|---|---|
| (none) | None |
The __call__ method returns None; side effects are the Slack message post and logging
|
| summary | str |
The generated summary text (from _request_summary) |
Usage Examples
from enterprise.integrations.slack.slack_v1_callback_processor import SlackV1CallbackProcessor
# Create the callback processor with Slack context
callback = SlackV1CallbackProcessor(
slack_token="xoxb-slack-bot-token",
channel_id="C0123456789",
thread_ts="1234567890.123456",
)
# Register as the conversation completion callback
conversation = await conversation_manager.create_conversation(
...,
on_complete_callback=callback,
)
# The callback is invoked automatically when the conversation completes.
# It can also be invoked manually for testing:
await callback(conversation_result=result)