-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Problem
Chat agent said "I don't have access to GitHub" when user asked about open issues. User had to correct it.
Solution
Add github tool to the chat handler using existing github_pr.py service:
- Read access: list_issues, list_prs, get_repo, get_issue
- Issue management: create_issue, update_issue, add_comment
- NO PR creation (worker agents only via spawn_task)
Files to Modify
backend/src/mainloop/services/github_pr.py- Addlist_open_issues()backend/src/mainloop/services/chat_handler.py- Addgithubtool
Implementation
1. Add list_open_issues() to github_pr.py
class IssueSummary(BaseModel):
"""Summary of a GitHub issue."""
number: int
title: str
state: str
author: str
created_at: datetime
updated_at: datetime
url: str
labels: list[str] = []
async def list_open_issues(repo_url: str, limit: int = 10) -> list[IssueSummary]:
"""List open issues for a repository."""
owner, repo = _parse_repo(repo_url)
gh = _get_github()
try:
response = await gh.rest.issues.async_list_for_repo(
owner=owner, repo=repo, state="open", per_page=limit,
)
# Filter out PRs (GitHub API returns PRs as issues too)
return [
IssueSummary(
number=issue.number,
title=issue.title,
state=issue.state,
author=issue.user.login,
created_at=issue.created_at,
updated_at=issue.updated_at,
url=issue.html_url,
labels=[label.name for label in issue.labels] if issue.labels else [],
)
for issue in response.parsed_data
if not hasattr(issue, 'pull_request') or issue.pull_request is None
]
except Exception:
return []2. Add github tool to chat_handler.py
Create tool with actions: list_issues, list_prs, get_repo, get_issue, create_issue, update_issue, add_comment
3. Update system prompt
base_prompt = """You are a helpful AI assistant that can also spawn autonomous coding agents.
You have access to:
- github: Read repo info and manage issues (list_issues, list_prs, get_repo, get_issue, create_issue, update_issue, add_comment)
- spawn_task: Spawn autonomous coding agents for development work
For information/issue management, use github.
For coding tasks (modify code, create PRs, run tests), use spawn_task after confirming with the user."""Permissions Model
| Tool | Capability |
|---|---|
github |
Read: list_issues, list_prs, get_repo, get_issue |
github |
Write: create_issue, update_issue, add_comment |
spawn_task |
Spawns worker agent (has full access including PR creation) |
Metadata
Metadata
Assignees
Labels
No labels