Forgejo tools to edit and delete the agent's own comments #259

Merged
lucas merged 1 commit from agent/issue-254-comment-edit-tools into main 2026-11-11 11:20:08 +01:00
Collaborator

Adds the two comment-maintenance tools from #254 so the agent can correct itself on a public repository.

What

  • forgejo_update_comment — replaces the body of a comment the agent's own Forgejo account posted, on an issue or a pull request, plain or inline review comment.
  • forgejo_delete_comment — deletes such a plain comment. Refuses inline review comments: Forgejo's DELETE /issues/comments/{id} filters on the plain comment type and answers 204 without deleting, so an unchecked delete would report a success that never happened.

Both resolve the comment first (GET /issues/comments/{id}, falling back to the PR's review comments when that answers 204) and hard-refuse anything written by someone else. Forgejo authorises PATCH/DELETE for the poster or any user with write access — which the deck's token has — so the ownership check has to live in the tools; it compares against forgejo.agent_username, now carried on ForgejoToolContext.

Availability

attended unattended Forgejo sessions idea mode
forgejo_update_comment ask (default) allowed; CI watchdog confined to its reported issue allowed, issues only
forgejo_delete_comment ask (default) denied denied

No webhook loop guard needed: classifyForgejoDelivery already drops edited deliveries whose sender is the agent (self-edited).

Verification

  • bun test — 1630 pass, 1 fail; bun run typecheck — one error. Both are the pre-existing breakage of main filed as #258 (dispatcher.ts calls the removed this.swapLabels), reproduced on a pristine checkout of main before this branch.
  • New apps/server/src/forgejo/tools/comments.test.ts covers the pure ownership/target helpers; the policy, permission-filter, idea-mode and tool-inventory suites were extended for both tools.
  • The end-to-end pass against the live instance listed in the issue plan was not run: this session's own tool set is the one shipped with main, so it has no forgejo_update_comment to call. Worth doing before merge, in particular the inline-comment edit path and the 204 resolution behaviour on this instance's Forgejo version (the route/status claims come from v15.0.9 sources).

Closes: #254

Adds the two comment-maintenance tools from #254 so the agent can correct itself on a public repository. ## What - **`forgejo_update_comment`** — replaces the body of a comment the agent's own Forgejo account posted, on an issue or a pull request, plain or inline review comment. - **`forgejo_delete_comment`** — deletes such a plain comment. Refuses inline review comments: Forgejo's `DELETE /issues/comments/{id}` filters on the plain comment type and answers `204` *without deleting*, so an unchecked delete would report a success that never happened. Both resolve the comment first (`GET /issues/comments/{id}`, falling back to the PR's review comments when that answers `204`) and hard-refuse anything written by someone else. Forgejo authorises `PATCH`/`DELETE` for the poster *or* any user with write access — which the deck's token has — so the ownership check has to live in the tools; it compares against `forgejo.agent_username`, now carried on `ForgejoToolContext`. ## Availability | | attended | unattended Forgejo sessions | idea mode | |---|---|---|---| | `forgejo_update_comment` | ask (default) | allowed; CI watchdog confined to its reported issue | allowed, issues only | | `forgejo_delete_comment` | ask (default) | denied | denied | No webhook loop guard needed: `classifyForgejoDelivery` already drops `edited` deliveries whose sender is the agent (`self-edited`). ## Verification - `bun test` — 1630 pass, 1 fail; `bun run typecheck` — one error. Both are the pre-existing breakage of `main` filed as #258 (`dispatcher.ts` calls the removed `this.swapLabels`), reproduced on a pristine checkout of `main` before this branch. - New `apps/server/src/forgejo/tools/comments.test.ts` covers the pure ownership/target helpers; the policy, permission-filter, idea-mode and tool-inventory suites were extended for both tools. - The end-to-end pass against the live instance listed in the issue plan was **not** run: this session's own tool set is the one shipped with `main`, so it has no `forgejo_update_comment` to call. Worth doing before merge, in particular the inline-comment edit path and the `204` resolution behaviour on this instance's Forgejo version (the route/status claims come from v15.0.9 sources). Closes: #254
A comment the agent posted on a public repository could not be changed
afterwards: a typo or a wrong claim stayed, and in unattended sessions
nobody was there to clean it up either.

`forgejo_update_comment` replaces the body of a comment the agent's own
Forgejo account wrote — plain issue/pull-request comment or inline
review comment — and `forgejo_delete_comment` deletes such a plain
comment. Both resolve the comment first and refuse anything written by
someone else: Forgejo authorises its PATCH/DELETE routes for the poster
*or* any user with write access, which the deck's token has, so the
ownership check has to live in the tools. Delete additionally refuses
inline review comments, because Forgejo's issue-comment DELETE filters
on the plain comment type and answers 204 without removing them.

Editing is available wherever the agent talks: the unattended session
kinds (confined to the CI watchdog's reported issue) and idea mode.
Deleting stays attended-only, where it asks for approval.

Closes: #254
Co-Authored-By: Claude Opus 5 via omp-deck
omp-deck force-pushed agent/issue-254-comment-edit-tools from 3323b680dd to 532531d859 2026-11-11 10:54:20 +01:00 Compare
lucas merged commit 1f4064444f into main 2026-11-11 11:20:08 +01:00
lucas deleted branch agent/issue-254-comment-edit-tools 2026-11-11 11:20:08 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lucas/omp-deck!259
No description provided.