Skip to content

Feat: Add GitHub Tool for Repository Interaction#1032

Open
oomis wants to merge 2 commits into
patterns-ai-core:mainfrom
oomis:feature/add-github-tool
Open

Feat: Add GitHub Tool for Repository Interaction#1032
oomis wants to merge 2 commits into
patterns-ai-core:mainfrom
oomis:feature/add-github-tool

Conversation

@oomis

@oomis oomis commented Dec 9, 2025

Copy link
Copy Markdown

Summary
This PR introduces Langchain::Tool::Github, enabling AI Agents to interact directly with GitHub repositories.
As the usage of Langchain.rb grows for developer-focused assistants (e.g., "Triage these issues" or "Explain this code"), having a native GitHub integration is essential. This implementation bridges that gap, allowing agents to retrieve context from issues, pull requests, and raw file content.
Features
Issue Listing: Fetch recent open issues for repository analysis.
Pull Request Retrieval: Get details, state, and body of specific PRs.
File Content Reading: Retrieve raw file content (Base64 decoded) for code analysis workflows.
Implementation Details
OpenAI Function Calling: Implemented using the define_function DSL, ensuring full compatibility with OpenAI's tool schema generation.
Lazy Loading: Uses depends_on "octokit" to ensure the gem is only loaded when the tool is initialized, keeping the core library lightweight.
Consistent Return Types: Returns Langchain::ToolResponse objects, maintaining consistency with the recent refactoring of other tools (e.g., Calculator).

Usage Example

require "langchain"

# Initialize the tool
github = Langchain::Tool::Github.new(access_token: ENV["GITHUB_ACCESS_TOKEN"])

# 1. List Issues
github.execute(
  action: "list_issues", 
  owner: "patterns-ai-core", 
  repo: "langchainrb", 
  limit: 3
)

# 2. Read File Content
github.execute(
  action: "file_content", 
  owner: "patterns-ai-core", 
  repo: "langchainrb", 
  path: "Gemfile"
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant