# PR-Agent for Gitea PR-Agent runs as a webhook server next to Gitea on `server0`. Gitea sends pull-request and comment events over the `gitea_gitea` Docker network; the endpoint is not published to the internet. | Piece | Value | |---|---| | Image | `pragent/pr-agent:0.49.0-gitea_app` | | Container | `pr-agent` | | Webhook URL, from Gitea | `http://pr-agent:3000/api/v1/gitea_webhooks` | | Config | `/opt/pr-agent/.env` (root, mode 600) | | Logs | `ssh … agent@server0 logs` | | Deploy / restart | `ssh … agent@server0 deploy` | | Status | `ssh … agent@server0 status` | | Upgrade | edit the root-owned compose file, then run `deploy` | ## Gitea side 1. The bot user `pr-agent` is a collaborator on `CV_Website/CV_Site_Nuxt` with write permission. Its personal access token is scoped to `read:repository`, `write:issue` and `read:user`. 2. The repository webhook sends `push`, `issues`, `pull_request` and `issue_comment` events, with JSON content type and the shared secret. 3. Gitea's `[webhook] ALLOWED_HOST_LIST` includes `private:3000`. Without it, Gitea's default egress policy refuses webhook deliveries to private addresses, including the Docker network. ## Operator access The agent does not log in as `noel`. A dedicated `agent` account has one forced command and three actions: ```sh ssh -i ~/.ssh/pr_agent_control -o IdentitiesOnly=yes agent@91.99.207.62 status ssh -i ~/.ssh/pr_agent_control -o IdentitiesOnly=yes agent@91.99.207.62 logs ssh -i ~/.ssh/pr_agent_control -o IdentitiesOnly=yes agent@91.99.207.62 deploy ``` The SSH key is restricted with `restrict,command=…`; the account has no Docker group, no general sudo, and no shell. Sudo permits only the three root-owned helper scripts in `/usr/local/sbin`, and those helpers operate on the fixed `/opt/pr-agent/docker-compose.yml`. The compose file, `.env` and helpers are root-owned, so the agent cannot turn “restart” into a different container or a host mount. `setup-agent-access.sh` creates the account and moves the stack to `/opt/pr-agent`. `remove-noel-access.sh` then removes the inherited access from `noel`: the `docker` and `sudo` groups, the keys in `/home/noel/.ssh/authorized_keys`, and the old PR-Agent directory. Run both on the server as root, and only run the second after the restricted command works and you have another admin path. For git, use a repository-scoped deploy key instead of the personal Gitea key: `~/.ssh/pr_agent_gitea.pub` is added as a write deploy key on `CV_Website/CV_Site_Nuxt`. The old personal key must be removed from Gitea, or it still grants every repository the user can see. ## AI model The agent uses OpenCode Go's OpenAI-compatible endpoint: ```text model openai/glm-5.3-flash fallback openai/glm-5.3 api base https://opencode.ai/inference/go/openai/v1 ``` `CONFIG__CUSTOM_MODEL_MAX_TOKENS` tells PR-Agent the context limit, because the model is not in its token table. The effective review budget is still capped by PR-Agent's default `config.max_model_tokens` of 32000. OpenCode Go requires an `x-opencode-session` header; PR-Agent sends the stable id `pr-agent` through `LITELLM__EXTRA_HEADERS`. The transfer file used during installation was empty, so set the key as root and redeploy: ```sh sudoedit /opt/pr-agent/.env # set OPENAI__KEY=… sudo /usr/local/sbin/pr-agent-deploy ``` ## First check Open a pull request in `CV_Website/CV_Site_Nuxt`. The server runs `/describe` and `/review` on open/reopen; comment commands such as `/review`, `/improve` and `/ask` are handled from the PR conversation. If nothing appears: ```sh ssh -i ~/.ssh/pr_agent_control -o IdentitiesOnly=yes agent@91.99.207.62 logs ``` A `403` in the Gitea webhook delivery log means the secret does not match or `ALLOWED_HOST_LIST` is still missing; a `401` from PR-Agent means the signature header and secret disagree.