Interactive Q&A (/ask)
Relevant source files
The following files were used as context for generating this wiki page:
Interactive Q&A (/ask) is a command-driven feature of the PR-Agent that allows users to ask specific questions about changes within a Pull Request. It serves as a conversational interface for developers to gain deeper insights into code modifications, logic, or potential side effects directly within the GitHub comment interface.
This feature is part of a suite of interactive commands, including /review, /describe, and /improve, which trigger automated agent actions across repositories managed by the central configuration.
Sources: README.md:20-24
Command Execution Flow
When a user submits a comment starting with /ask <question>, the PR-Agent processes the request by analyzing the PR context and generating a targeted response. While the logic for processing the natural language question resides within the PR-Agent core, the automation and environment settings are governed by the central configuration files in this repository.
Workflow Integration
The command is typically processed through GitHub Actions. The repository provides a reusable workflow that monitors PR comments for specific triggers.
A sequence diagram showing the flow from a user comment to the agent's response on a Pull Request.
Sources: README.md:16-18, README.md:24
Configuration and Overrides
The behavior of the /ask command is influenced by the global configuration found in .pr_agent.toml. This file establishes the default settings for the agent's interaction across all repositories owned by the organization.
Configuration Hierarchy
- Global Settings: Defined in
JWEB0689/pr-agent-settings/.pr_agent.toml. - Repository Overrides: Defined in a local
.pr_agent.tomlwithin a specific repository. - Command Execution: The agent loads settings by inheriting from the global file and applying any local overrides.
Sources: README.md:6-14
| Configuration Level | File Path | Impact |
|---|---|---|
| Global | JWEB0689/pr-agent-settings/.pr_agent.toml | Sets default behavior for /ask across all organization repos. |
| Local | {repo_root}/.pr_agent.toml | Overrides global settings for specific repository needs. |
Sources: README.md:8-14
Integration with Autonomous Tools
The /ask feature operates alongside autonomous scripts like autofix.py. While /ask provides information to the user, the autofix.py script acts on findings that might be generated during code reviews or as a result of AI-human interactions.
Data Acquisition for Context
To provide accurate answers, the system must retrieve PR data. The scripts/autofix.py file demonstrates how the environment retrieves context via the GitHub API, which is a similar mechanism used by the agent to understand the PR before answering a /ask query.
def gh_api_get(path):
"""GET a GitHub REST API path with GH_TOKEN; follows pagination for lists."""
token = os.environ.get("GH_TOKEN")
# ... logic to fetch pull request data, comments, and file contents ...
Sources: scripts/autofix.py:118-121
Context Limitations
When processing requests, the system observes specific constraints to maintain performance and avoid API overloads. These limits apply to the file context available for analysis:
| Variable | Value | Description |
|---|---|---|
MAX_FILE_BYTES | 80,000 | Maximum size of a file the system will read for context. |
MAX_CONTEXT_FILES | 12 | Maximum number of files processed in a single context window. |
Sources: scripts/autofix.py:32-33
Summary
The /ask <question> command provides an interactive layer to the PR-Agent, enabling developers to query specific aspects of a Pull Request. It relies on the central configuration for baseline behavior while allowing repository-specific overrides. By integrating with the broader automation suite, it ensures that developers have immediate, AI-driven insights into code changes during the review process.