Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:OpenHands OpenHands GithubManager Send Message

From Leeroopedia
Revision as of 11:42, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/OpenHands_OpenHands_GithubManager_Send_Message.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Platform_Integration, GitHub_API
Last Updated 2026-02-11 21:00 GMT

Overview

Concrete tool for posting agent progress messages and results back to GitHub issues, pull requests, and review threads, provided by the OpenHands enterprise integration layer.

Description

GithubManager.send_message posts a message (typically an agent progress update or final result) as a comment on the GitHub resource that originally triggered the webhook event. The method accepts a Message object containing the text to post and a ResolverViewInterface object that specifies the target resource (issue, PR, or inline review thread).

The method resolves the correct GitHub API endpoint based on the view type, authenticates using an installation access token, and creates the comment. It handles the differences between posting to issues (via the Issues API), pull requests (via the Pull Requests API), and inline review threads (via the Pull Request Review Comments API).

Usage

This method is called by the agent execution pipeline whenever the agent produces output that should be visible to users on GitHub. Common scenarios include:

  • Posting intermediate progress updates during execution
  • Posting the final result (success or failure) when the agent completes
  • Posting clarifying questions when the agent needs human input

Code Reference

Source Location

  • Repository: OpenHands
  • File: enterprise/integrations/github/github_manager.py
  • Lines: L198-228

Signature

async def send_message(
    self,
    message: Message,
    github_view: ResolverViewInterface,
) -> None:

Import

from integrations.github.github_manager import GithubManager

I/O Contract

Inputs

Name Type Required Description
message Message Yes Pydantic model containing the text to post. The source field should be SourceType.OPENHANDS to indicate the message originates from the agent. The message field contains the comment body (markdown-formatted string).
github_view ResolverViewInterface Yes The typed view object representing the target GitHub resource. Provides the repository name, issue/PR number, and comment thread ID needed to route the message to the correct API endpoint.

Outputs

Name Type Description
(none) None The method returns nothing. Its sole effect is the creation of a comment on the specified GitHub resource via the GitHub API.

Message Routing

The method routes messages to different GitHub API endpoints based on the view type:

View Type API Endpoint Method
GithubIssue /repos/{owner}/{repo}/issues/{number}/comments issue.create_comment(body)
GithubIssueComment /repos/{owner}/{repo}/issues/{number}/comments issue.create_comment(body)
GithubPRComment /repos/{owner}/{repo}/issues/{number}/comments issue.create_comment(body)
GithubInlinePRComment /repos/{owner}/{repo}/pulls/{number}/comments/{id}/replies comment.create_reply(body)

For most view types, the message is posted as a top-level comment on the issue or PR. For inline PR comments, the message is posted as a reply to the specific review thread, maintaining the context of the inline discussion.

Authentication

The method authenticates to the GitHub API using the same installation token mechanism as other GithubManager methods:

  1. Retrieves the installation ID from the github_view.
  2. Calls _get_installation_access_token(installation_id) to obtain a scoped token.
  3. Constructs a PyGithub Github client with the token.
  4. Uses the client to create the comment on the target resource.

Usage Examples

Basic Usage

from integrations.github.github_manager import GithubManager
from integrations.models import Message, SourceType

manager = GithubManager(
    token_manager=token_manager,
    data_collector=data_collector,
)

# Create a message from the agent
agent_message = Message(
    source=SourceType.OPENHANDS,
    message="I've analyzed the issue and created a fix in PR #123.",
    ephemeral=False,
)

# Post the message to the GitHub resource
await manager.send_message(
    message=agent_message,
    github_view=github_view,
)

Posting Progress Updates

# During agent execution, post intermediate updates
progress_message = Message(
    source=SourceType.OPENHANDS,
    message="Working on the fix. Currently analyzing the test suite...",
    ephemeral=False,
)

await manager.send_message(
    message=progress_message,
    github_view=github_view,
)

Related Pages

Implements Principle

Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment