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 GithubIssue Initialize Conversation

From Leeroopedia
Revision as of 11:42, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/OpenHands_OpenHands_GithubIssue_Initialize_Conversation.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 initializing a new agent conversation session from a GitHub issue webhook event, provided by the OpenHands enterprise integration layer.

Description

GithubIssue.initialize_new_conversation creates a new agent conversation session by assembling metadata from the GitHub issue event and delegating to either the v0 or v1 conversation backend. The method is defined on the GithubIssue dataclass, which represents a parsed GitHub issue webhook event, and returns a ConversationMetadata object that the caller uses to track the conversation lifecycle.

The method determines which backend to use based on the v1_enabled flag on the dataclass. It then constructs a ResolverUserContext object containing all the information the agent will need (repository URL, issue details, user identity, permissions) and passes it to the appropriate backend-specific creation method.

Usage

This method is called during the webhook processing pipeline after acknowledgment has been sent and (optionally) after solvability analysis has been performed. It is the step that transitions from "webhook processing" to "agent execution".

Code Reference

Source Location

  • Repository: OpenHands
  • File: enterprise/integrations/github/github_view.py
  • Lines: L163-193

Class Context

@dataclass
class GithubIssue:
    issue_number: int
    installation_id: str
    full_repo_name: str
    is_public_repo: bool
    user_info: UserInfo
    raw_payload: dict
    conversation_id: str
    uuid: str
    should_extract: bool
    send_summary_instruction: bool
    title: str
    description: str
    previous_comments: list[str]
    v1_enabled: bool

Signature

def initialize_new_conversation(self) -> ConversationMetadata:

Import

from integrations.github.github_view import GithubIssue

Related Context Class

# From enterprise/integrations/resolver_context.py:L9-82
class ResolverUserContext:
    repo_url: str
    issue_number: int
    issue_title: str
    issue_body: str
    previous_comments: list[str]
    user_info: UserInfo
    installation_id: str
    full_repo_name: str
    is_public_repo: bool
    ...

I/O Contract

Inputs

Name Type Required Description
self GithubIssue Yes The dataclass instance populated with all fields from the parsed webhook payload. No additional parameters are passed; all data comes from the instance fields.

Outputs

Name Type Description
metadata ConversationMetadata A metadata object containing the conversation ID, creation timestamp, status, and backend version. Used by the caller to track the conversation lifecycle and associate it with the originating webhook event.

Internal Routing

The method routes to one of two backend-specific creation methods:

Condition Method Called Description
self.v1_enabled == True _create_v1_conversation() Creates a conversation using the v1 execution backend, which supports streaming events, callback processors, and advanced agent capabilities.
self.v1_enabled == False _create_v0_conversation() Creates a conversation using the legacy v0 execution backend, which uses a simpler request-response model.

Metadata Assembly

The method assembles a ResolverUserContext from the dataclass fields:

  1. Repository information -- full_repo_name, is_public_repo, installation_id
  2. Issue details -- issue_number, title, description, previous_comments
  3. User identity -- user_info (containing the GitHub username, Keycloak ID, and permissions)
  4. Configuration -- should_extract, send_summary_instruction

This context object is then serialized and sent to the conversation backend via an HTTP POST request.

Usage Examples

Basic Usage

from integrations.github.github_view import GithubIssue

# github_issue is a GithubIssue instance created by the factory
metadata = github_issue.initialize_new_conversation()

print(metadata.conversation_id)  # e.g., "conv-uuid-1234"
print(metadata.status)           # e.g., "CREATED"

Within the Pipeline

# In the receive_message flow:
# 1. Permission check passed
# 2. View created by factory
# 3. Acknowledgment reaction added

# 4. Create the conversation
metadata = github_view.initialize_new_conversation()

# 5. Store the conversation ID for tracking
await store_conversation_mapping(
    event_id=webhook_delivery_id,
    conversation_id=metadata.conversation_id,
)

Related Pages

Implements Principle

Page Connections

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