chore: refactor discussion answering agent to merge answer_discussions.py into main.py

mainly to dedup duplicated functionality in both file.

PiperOrigin-RevId: 802291102
This commit is contained in:
Xiang (Sean) Zhou
2025-09-02 14:25:32 -07:00
committed by Copybara-Service
parent 831e2e6d4d
commit 408d3dfeb1
4 changed files with 141 additions and 199 deletions
@@ -6,7 +6,7 @@ This agent can be operated in three distinct modes:
- An interactive mode for local use.
- A batch script mode for oncall use.
- A fully automated GitHub Actions workflow (TBD).
- A fully automated GitHub Actions workflow.
---
@@ -31,26 +31,30 @@ This will start a local server and provide a URL to access the agent's web inter
## Batch Script Mode
The `answer_discussions.py` is created for ADK oncall team to batch process discussions.
The `main.py` script supports batch processing for ADK oncall team to process discussions.
### Features
* **Batch Process**: Taken either a number as the count of the recent discussions or a list of discussion numbers, the script will invoke the agent to answer all the specified discussions in one single run.
* **Single Discussion**: Process a specific discussion by providing its number.
* **Batch Process**: Process the N most recently updated discussions.
### Running in Interactive Mode
To run the agent in batch script mode, first set the required environment variables. Then, execute the following command in your terminal:
### Running in Batch Script Mode
To run the agent in batch script mode, first set the required environment variables. Then, execute one of the following commands:
```bash
export PYTHONPATH=contributing/samples
python -m adk_answering_agent.answer_discussions --numbers 27 36 # Answer specified discussions
```
Or `python -m adk_answering_agent.answer_discussions --recent 10` to answer the 10 most recent updated discussions.
# Answer a specific discussion
python -m adk_answering_agent.main --discussion_number 27
# Answer the 10 most recent updated discussions
python -m adk_answering_agent.main --recent 10
```
---
## GitHub Workflow Mode
The `main.py` is reserved for the Github Workflow. The detailed setup for the automatic workflow is TBD.
The `main.py` script is automatically triggered by GitHub Actions when new discussions are created in the Q&A category. The workflow is configured in `.github/workflows/discussion_answering.yml` and automatically processes discussions using the `--discussion_number` flag.
---