PullRequestDescriptionAgent
What it is
- An
Agentfactory and minimal agent class used to generate and persist a GitHub pull request description based on the current branch name and the diff againstorigin/main. - Provides two LangChain tools to:
- fetch the branch name + git diff
- store a generated PR description to
storage/datastore/git/pull_request_description.md(and a timestamped copy)
Public API
create_agent(agent_shared_state: Optional[AgentSharedState] = None, agent_configuration: Optional[AgentConfiguration] = None) -> Optional[Agent]- Creates and returns a configured
PullRequestDescriptionAgentinstance. - Sets a default
system_prompt(instructions for tool usage and output formatting). - Registers two tools:
git_diffandstore_pull_request_description.
- Creates and returns a configured
class PullRequestDescriptionAgent(Agent)- Concrete agent type; no additional behavior beyond the base
Agent.
- Concrete agent type; no additional behavior beyond the base
Configuration/Dependencies
- Depends on:
naas_abi_core.services.agent.Agent:Agent,AgentConfiguration,AgentSharedState- Chat model:
naas_abi_marketplace.ai.chatgpt.models.gpt_4_1_mini.model - LangChain:
langchain_core.tools.StructuredTool - Pydantic:
BaseModel,Field - System tools:
gitCLI available in environment (viasubprocess)
- Tool behavior:
git_diffruns:git branch --show-currentto obtain the current branch namegit diff origin/main -- . :!uv.lockto generate a diff (excludinguv.lock)
store_pull_request_descriptionwrites to:storage/datastore/git/pull_request_description.md- also copies to a timestamp-prefixed file in the same directory
Usage
from naas_abi_marketplace.applications.git.agents.PullRequestDescriptionAgent import create_agent
agent = create_agent()
# Agent execution API depends on the base `Agent` implementation.
# The agent is configured with tools and a system prompt instructing it to:
# 1) call `git_diff`
# 2) call `store_pull_request_description`
# 3) output a PR description starting with:
# "This pull request resolves #<branch_name_number>"
Caveats
- Requires a git repository with an
origin/mainreference available locally. - The diff is computed against
origin/main, not the localmain. - The agent’s system prompt mandates that the final PR description starts with:
This pull request resolves #<branch_name_number>where the number is at the beginning of the branch name.
- Writes files under
storage/datastore/git/; ensure the process has filesystem permissions.