Implementation:OpenHands OpenHands GithubV1CallbackProcessor Call
| Knowledge Sources | |
|---|---|
| Domains | Platform_Integration, GitHub_API |
| Last Updated | 2026-02-11 21:00 GMT |
Overview
Concrete tool for processing agent completion events and posting summaries back to GitHub, provided by the OpenHands enterprise integration layer.
Description
GithubV1CallbackProcessor.__call__ is the callback handler invoked for each event in an agent conversation's event stream. When a terminal event is detected (agent completion, timeout, or error), the processor generates a human-readable summary of the agent's work and posts it as a comment on the originating GitHub issue, pull request, or review thread.
The class inherits from EventCallbackProcessor and is specifically designed for the v1 conversation backend. It carries the original GitHub view data (serialized from the GithubViewType that triggered the conversation), a flag indicating whether a summary should be requested, and a flag for inline PR comment handling.
The processor delegates to two key helper methods:
- _request_summary -- Sends a request to the LLM to generate a concise summary of the conversation history.
- _post_summary_to_github -- Authenticates to the GitHub API and creates a comment with the generated summary.
Usage
This processor is registered as a callback when a v1 conversation is created. It is invoked automatically by the conversation event bus for each event in the stream. Application code does not call this processor directly; it is wired in during conversation initialization.
Code Reference
Source Location
- Repository: OpenHands
- File:
enterprise/integrations/github/github_v1_callback_processor.py - Lines: L38-107 (__call__), L232-293 (_request_summary), L130-152 (_post_summary_to_github)
Signature
async def __call__(
self,
conversation_id: UUID,
callback: EventCallback,
event: Event,
) -> EventCallbackResult | None:
Class Context
class GithubV1CallbackProcessor(EventCallbackProcessor):
github_view_data: dict[str, Any]
should_request_summary: bool
inline_pr_comment: bool
Helper Signatures
async def _request_summary(
self,
conversation_id: UUID,
) -> str:
async def _post_summary_to_github(
self,
summary: str,
) -> None:
Import
from integrations.github.github_v1_callback_processor import GithubV1CallbackProcessor
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| conversation_id | UUID |
Yes | The unique identifier of the agent conversation. Used to look up conversation metadata and event history for summary generation. |
| callback | EventCallback |
Yes | The callback registration object containing metadata about this callback (e.g., callback type, registration time). Passed by the event bus infrastructure. |
| event | Event |
Yes | The conversation event that triggered the callback invocation. The processor inspects this event to determine if it is a terminal event (completion, error, timeout). |
Outputs
| Name | Type | Description |
|---|---|---|
| result | None | Returns an EventCallbackResult when a terminal event is processed (summary generated and posted), indicating the callback has completed. Returns None for non-terminal events, indicating no action was taken and the callback should continue listening.
|
Processing Flow
The __call__ method follows this decision flow:
- Event inspection -- Check if the event is a terminal event (agent finished, error, or timeout).
- Early return -- If the event is not terminal, return
Noneimmediately. - Summary request -- If
should_request_summaryisTrue, call_request_summary(conversation_id)to generate a summary from the conversation history. - View reconstruction -- Deserialize
github_view_databack into a typed view object to determine the posting target. - Summary posting -- Call
_post_summary_to_github(summary)to post the summary as a comment on the originating GitHub resource. - Result return -- Return an
EventCallbackResultindicating successful completion.
Summary Generation
The _request_summary method (L232-293):
- Fetches the full conversation event history for the given
conversation_idvia an HTTP request to the conversation backend. - Formats the event history into a prompt suitable for the LLM.
- Submits the prompt to the LLM with instructions to produce a concise, user-facing summary.
- Parses the LLM response and returns the summary string.
The summary typically includes:
- A brief description of what the agent did
- Files that were modified or created
- Tests that were run and their results
- Any pull requests that were created
- Next steps or remaining issues
GitHub Posting
The _post_summary_to_github method (L130-152):
- Reconstructs the GitHub view from the stored
github_view_data. - Obtains an installation access token using the installation ID from the view.
- Creates a PyGithub client with the token.
- Routes the comment to the correct API endpoint based on the view type.
- For inline PR comments (
inline_pr_comment=True), posts as a reply to the review thread. - For all other types, posts as a top-level comment on the issue or PR.
Usage Examples
Basic Usage
from integrations.github.github_v1_callback_processor import GithubV1CallbackProcessor
# The processor is constructed during conversation creation
processor = GithubV1CallbackProcessor(
github_view_data=github_view.to_dict(),
should_request_summary=True,
inline_pr_comment=False,
)
# The event bus calls the processor for each event
result = await processor(
conversation_id=conversation_uuid,
callback=callback_registration,
event=agent_finished_event,
)
if result is not None:
print("Summary posted to GitHub")
else:
print("Non-terminal event, continuing...")
Registration During Conversation Creation
# During v1 conversation creation, the processor is registered as a callback
from integrations.github.github_v1_callback_processor import GithubV1CallbackProcessor
callback_processor = GithubV1CallbackProcessor(
github_view_data=github_view.to_dict(),
should_request_summary=True,
inline_pr_comment=isinstance(github_view, GithubInlinePRComment),
)
# Register with the conversation event bus
conversation.register_callback(
processor=callback_processor,
event_types=[EventType.AGENT_FINISHED, EventType.ERROR, EventType.TIMEOUT],
)