Pull Request Agents#
This directory contains Pydantic AI agents for working with pull request data.
Changelog Generation Agent#
The changelog generation agent (changelog.py) creates comprehensive changelogs from merged pull requests.
Features#
- Fetches merged PRs from GitHub data sources
- Generates well-formatted changelog content grouped by category
- Handles date range filtering (e.g., "last week", "last month")
- Respects the 200 PR limit for performance
Requirements#
The agent requires:
- A deployment with GitHub data sources connected
- Pull request data indexed in LanceDB with
PULL_REQUEST_RAWorPULL_REQUEST_SUMMARYtables - The search service running (default:
localhost:8086)
Testing#
CLI Interactive Mode#
cd backend
poetry run python -m agent.experimental.pull_requests.agents.changelog
This launches an interactive CLI that:
- Uses a mock data source pointing to the pre-indexed dataset from
make setup-data - Connects to the real search service at
config.SEARCH_API_URL
Prerequisites for CLI testing:
- Run
make setup-datato download pre-indexed PR datasets - Run
make search-upto start the search service
Architecture#
The agent uses four tools to generate changelogs:
-
list_pull_requests - Fetches PRs from the specified time range
- Filters by state, author, and date range
- Returns up to 200 PRs ordered by updated timestamp
-
fetch_source - Retrieves full source content for PRs
-
edit_draft - Creates and edits the changelog draft
- Groups PRs by category (features, fixes, etc.)
- Formats as Markdown
-
read_draft - Reads the current draft content
Dependencies#
The agent uses Field(exclude=True) for protocol-typed dependencies to avoid Pydantic serialization issues:
search_client: SearchClientT- For searching PR datasource_store: SourceStoreT- For managing source metadata
Troubleshooting#
No data sources available
If you see this error, it means no GitHub data sources have PR tables indexed:
Error: No code changes data sources available to search.
Solution: Ensure your GitHub data sources have been indexed with PR extraction enabled. Check available_lancedb_tables contains PULL_REQUEST_RAW or PULL_REQUEST_SUMMARY.
Connection refused (port 8086)
If you see connection errors to localhost:8086:
ConnectionRefusedError: [Errno 61] Connection refused
Solution: Start the search service with make search-up in the backend directory.
HTTP 404 errors
If you see 404 errors when calling list_pull_requests:
HTTP 404 Client Error: Not Found for url: http://localhost:8086/pull-requests
Solution: The LanceDB data for the data source doesn't exist or is empty. Run make setup-data to download pre-indexed datasets. If the directories already exist but are empty, remove them first:
rm -rf ~/.dosu/data/local/lancedb/<data-source-id>
make setup-data
No PRs found for time period
If the agent reports no PRs found for the requested time period, the downloaded dataset may not have PRs from that date range. Try requesting a changelog without date filters or with a wider date range.
Integration#
The agent can be used as:
- A standalone CLI tool (for testing)
- A sub-agent within larger workflows via
sub_agent_tool
The sub_agent_tool export wraps the agent for use by orchestrator agents.