Implementation:OpenHands OpenHands GithubManager Add Reaction
| Knowledge Sources | |
|---|---|
| Domains | Platform_Integration, GitHub_API |
| Last Updated | 2026-02-11 21:00 GMT |
Overview
Concrete tool for adding emoji reactions to GitHub issues, pull requests, and comments as immediate visual acknowledgment, provided by the OpenHands enterprise integration layer.
Description
GithubManager._add_reaction adds an emoji reaction (typically "eyes") to the GitHub resource that triggered the webhook event. This provides immediate user-visible confirmation that the system has received and is processing the request. The method operates on a ResolverViewInterface object (the typed view produced by the factory) and uses an installation access token to authenticate against the GitHub API.
The companion method GithubManager._get_installation_access_token handles the two-step token acquisition process: generating a JWT from the GitHub App's credentials and exchanging it for a scoped installation access token.
Usage
This method is called internally by receive_message after the permission check passes and the view object has been created, but before the resolver job is dispatched. It is a private method (prefixed with _) and should not be called directly by code outside the GithubManager class.
Code Reference
Source Location
- Repository: OpenHands
- File:
enterprise/integrations/github/github_manager.py - Lines: L77-101 (_add_reaction), L70-75 (_get_installation_access_token)
Signature
def _add_reaction(
self,
github_view: ResolverViewInterface,
reaction: str,
installation_token: str,
) -> None:
Helper Signature
def _get_installation_access_token(
self,
installation_id: str,
) -> str:
Import
from integrations.github.github_manager import GithubManager
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| github_view | ResolverViewInterface |
Yes | The typed view object representing the GitHub resource (issue, comment, PR) to react to. Provides the repository name, issue number, and comment ID needed to target the correct resource. |
| reaction | str |
Yes | The reaction name to add. Common values: "eyes" (acknowledgment), "rocket" (processing started), "+1" (approval).
|
| installation_token | str |
Yes | A valid GitHub App installation access token with permission to write reactions on the target repository. |
Helper method inputs:
| Name | Type | Required | Description |
|---|---|---|---|
| installation_id | str |
Yes | The GitHub App installation ID, extracted from the webhook payload's installation.id field.
|
Outputs
| Name | Type | Description |
|---|---|---|
| (none) | None |
The method returns nothing. Its sole effect is the creation of an emoji reaction on the specified GitHub resource via the GitHub API. |
Token Acquisition Flow
The _get_installation_access_token method performs:
- Retrieves the GitHub App ID and private key from the TokenManager.
- Creates a
github.Auth.AppAuth(app_id, private_key)object. - Constructs a
github.GithubIntegration(auth=app_auth)instance. - Calls
integration.get_access_token(installation_id)to obtain a scoped token. - Returns the token string, which is valid for approximately 1 hour.
Reaction Target Resolution
The method determines where to add the reaction based on the view type:
| View Type | Reaction Target |
|---|---|
GithubIssue |
The issue itself (via issue.create_reaction())
|
GithubIssueComment |
The specific comment (via comment.create_reaction())
|
GithubPRComment |
The PR comment (via comment.create_reaction())
|
GithubInlinePRComment |
The inline review comment (via comment.create_reaction())
|
Usage Examples
Basic Usage
from integrations.github.github_manager import GithubManager
manager = GithubManager(
token_manager=token_manager,
data_collector=data_collector,
)
# Obtain the installation token
installation_token = manager._get_installation_access_token(
installation_id="12345678",
)
# Add an "eyes" reaction to acknowledge receipt
manager._add_reaction(
github_view=github_view,
reaction="eyes",
installation_token=installation_token,
)