open-swe/agent/tools/github_comment.py
Aran Yogesh b735afb445
feat: add GitHub PR comment trigger and reply support [closes OPE-1] (#1014)
* feat: add GitHub PR comment trigger and reply support

* refactor: improve readability of GitHub integration

* linting

* fix: resolve github token from thread metadata and improve PR trigger flow

* fix: fall back to OAuth for GitHub webhook when no token in thread metadata

* give me commit message github integeration working without a breaking

* auth.py refactor

* fix: validate cached GitHub token before use to handle expiry

* liniting

* ci unitest formatting

* feat: post PR comments as GitHub App bot instead of user OAuth token

* resolved comments

* slack resolveed comments

* Refactor docstring and comments in get_slack_repo_config

Removed unnecessary comments and cleaned up docstring formatting.

* cr

* cr

* cr

* cr

---------

Co-authored-by: bracesproul <braceasproul@gmail.com>
2026-03-09 17:14:13 -07:00

28 lines
1 KiB
Python

import asyncio
from typing import Any
from langgraph.config import get_config
from ..utils.github_app import get_github_app_installation_token
from ..utils.github_comments import post_github_comment
def github_comment(message: str, issue_number: int) -> dict[str, Any]:
"""Post a comment to a GitHub issue or pull request."""
config = get_config()
configurable = config.get("configurable", {})
repo_config = configurable.get("repo", {})
if not issue_number:
return {"success": False, "error": "Missing issue_number argument"}
if not repo_config:
return {"success": False, "error": "No repo config found in config"}
if not message.strip():
return {"success": False, "error": "Message cannot be empty"}
token = asyncio.run(get_github_app_installation_token())
if not token:
return {"success": False, "error": "Failed to get GitHub App installation token"}
success = asyncio.run(post_github_comment(repo_config, issue_number, message, token=token))
return {"success": success}