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 openaiexport 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:
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
| Parameter | Type | Default | Description |
|---|---|---|---|
access_token | Optional[str] | None | GitHub access token for authentication. If not provided, will use GITHUB_ACCESS_TOKEN environment variable. |
base_url | Optional[str] | None | Optional base URL for GitHub Enterprise installations. |
Toolkit Functions
| Function | Description |
|---|---|
search_repositories | Searches GitHub repositories based on a query. Max 1000 results per query. |
list_repositories | Lists all repositories for the authenticated user. |
get_repository | Gets details about a specific repository. |
create_repository | Creates a new repository. |
delete_repository | Deletes a repository. Requires admin permissions. |
get_repository_languages | Gets the languages used in a repository. |
get_repository_stars | Gets the star count for a repository. |
get_repository_with_stats | Gets repository information including statistics. |
list_branches | Lists all branches in a repository. |
create_branch | Creates a new branch from a source branch. |
set_default_branch | Sets the default branch for a repository. |
get_branch_content | Gets the root directory content of a specific branch. |
get_pull_requests | Lists pull requests with state, sort, and direction filters. |
get_pull_request | Gets details about a specific pull request. |
get_pull_request_changes | Gets the file changes in a pull request. |
get_pull_request_count | Counts pull requests matching state, author, base, and head filters. |
get_pull_request_with_details | Gets pull request details including comments, labels, and metadata. |
get_pull_request_comments | Gets all comments on a pull request. |
create_pull_request | Creates a new pull request. |
create_pull_request_comment | Comments on a specific line of a file in a pull request. |
edit_pull_request_comment | Edits an existing pull request comment. |
create_review_request | Requests reviewers for a pull request. |
list_issues | Lists issues for a repository with pagination. |
get_issue | Gets details about a specific issue. |
create_issue | Creates a new issue in a repository. |
edit_issue | Edits the title or body of an issue. |
close_issue | Closes an issue. |
reopen_issue | Reopens a closed issue. |
assign_issue | Assigns users to an issue. |
label_issue | Adds labels to an issue. |
comment_on_issue | Adds a comment to an issue. |
list_issue_comments | Lists comments on an issue. |
create_file | Creates a new file in a repository. |
get_file_content | Gets the content of a file in a repository. |
update_file | Updates an existing file in a repository. |
delete_file | Deletes a file from a repository. |
get_directory_content | Gets the contents of a directory in a repository. |
search_code | Searches for code with language, repo, user, path, and filename filters. |
search_issues_and_prs | Searches 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.