GitHub

GithubTools enable an Agent to manage GitHub repositories, issues, and pull requests.

GithubTools enables an Agent to access GitHub repositories and perform tasks such as listing open pull requests, issues and more.

Prerequisites

The following example requires the PyGithub library and a GitHub access token which can be obtained from here.

uv pip install -U agno PyGithub openai
export OPENAI_API_KEY="your_openai_api_key_here"
export GITHUB_ACCESS_TOKEN="your_github_access_token_here"

Example

The following agent lists open pull requests for a repository:

cookbook/91_tools/github_tools.py
from agno.agent import Agent
from agno.tools.github import GithubTools

agent = Agent(
    instructions=[
        "Use your tools to answer questions about the repo: agno-agi/agno",
        "Do not create any issues or pull requests unless explicitly asked to do so",
    ],
    tools=[
        GithubTools(
            include_tools=[
                "search_repositories",
                "get_repository",
                "list_repositories",
                "get_pull_requests",
                "list_issues",
            ]
        )
    ],
)

agent.print_response("List open pull requests", markdown=True)

Toolkit Params

ParameterTypeDefaultDescription
access_tokenOptional[str]NoneGitHub access token for authentication. If not provided, will use GITHUB_ACCESS_TOKEN environment variable.
base_urlOptional[str]NoneOptional base URL for GitHub Enterprise installations.

Toolkit Functions

FunctionDescription
search_repositoriesSearches GitHub repositories based on a query. Max 1000 results per query.
list_repositoriesLists all repositories for the authenticated user.
get_repositoryGets details about a specific repository.
create_repositoryCreates a new repository.
delete_repositoryDeletes a repository. Requires admin permissions.
get_repository_languagesGets the languages used in a repository.
get_repository_starsGets the star count for a repository.
get_repository_with_statsGets repository information including statistics.
list_branchesLists all branches in a repository.
create_branchCreates a new branch from a source branch.
set_default_branchSets the default branch for a repository.
get_branch_contentGets the root directory content of a specific branch.
get_pull_requestsLists pull requests with state, sort, and direction filters.
get_pull_requestGets details about a specific pull request.
get_pull_request_changesGets the file changes in a pull request.
get_pull_request_countCounts pull requests matching state, author, base, and head filters.
get_pull_request_with_detailsGets pull request details including comments, labels, and metadata.
get_pull_request_commentsGets all comments on a pull request.
create_pull_requestCreates a new pull request.
create_pull_request_commentComments on a specific line of a file in a pull request.
edit_pull_request_commentEdits an existing pull request comment.
create_review_requestRequests reviewers for a pull request.
list_issuesLists issues for a repository with pagination.
get_issueGets details about a specific issue.
create_issueCreates a new issue in a repository.
edit_issueEdits the title or body of an issue.
close_issueCloses an issue.
reopen_issueReopens a closed issue.
assign_issueAssigns users to an issue.
label_issueAdds labels to an issue.
comment_on_issueAdds a comment to an issue.
list_issue_commentsLists comments on an issue.
create_fileCreates a new file in a repository.
get_file_contentGets the content of a file in a repository.
update_fileUpdates an existing file in a repository.
delete_fileDeletes a file from a repository.
get_directory_contentGets the contents of a directory in a repository.
search_codeSearches for code with language, repo, user, path, and filename filters.
search_issues_and_prsSearches issues and pull requests with state, type, repo, and label filters.

You can use include_tools or exclude_tools to modify the list of tools the agent has access to. Learn more about selecting tools.

Optional filters and branches

The example uses the read-only methods shown above. Some other adapter paths forward None to PyGithub where its current SDK expects an omitted option or a string: provide explicit base and head filters for get_pull_request_count, and an explicit branch for create_file, update_file, and delete_file. Their omitted defaults can fail SDK validation before an HTTP request is sent.

Developer Resources