agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

Review feedback can be injected after the session toggle is turned off

Open neversettle17-101 opened this issue 3 months ago • 3 comments

Bug

Turning off Automatically send review feedback does not reliably stop review feedback from being injected into the worker. Feedback captured while the toggle was enabled remains marked injectable and can be delivered after the session-level toggle is off.

Source: live AO session report from @neversettle17-101 on 2026-08-11
Analyzed against: aab4c973d (origin/main)
AO daemon: source build, port 3001
Confidence: High
Priority: P2 — the worker can act on feedback the user explicitly disabled, but delivery can be avoided by leaving the toggle off before any PR/review is observed.

Reproduction

  1. Start a worker with automatic review feedback enabled (the default).
  2. Claim or observe a PR containing a changes-requested review, causing its review rows to be persisted with auto_inject_review = true.
  3. Turn Automatically send review feedback off before a later PR observation/delivery pass.
  4. Trigger or wait for the lifecycle PR observation.
  5. Observe that the changes-requested review body is still sent into the worker conversation.

Live evidence

For session agent-orchestrator-97, the session row/API reported autoInjectReview: false, while both changes-requested review rows for PR 3692 retained auto_inject_review = 1. Both review bodies were injected into the active worker.

Root Cause

The implementation intentionally snapshots the session policy onto each review/comment when it is first observed:

  • backend/internal/service/session/claim_pr.go copies SessionRecord.AutoInjectReview into persisted review/comment rows.
  • backend/internal/lifecycle/reactions.go decides delivery from review.AutoInjectReview / comment.AutoInjectReview, but does not also require the current SessionRecord.AutoInjectReview value after loading the session.
  • backend/internal/lifecycle/reactions.go::ApplyReviewBatch similarly loads the current session but never gates delivery on its current toggle.
  • backend/internal/service/review/review.go::deliverableRuns uses only the review-run snapshot.

The snapshot is useful to prevent feedback observed while disabled from being retroactively injected after re-enabling. However, using only the snapshot means disabling the live session is not a kill switch for feedback already observed. This conflicts with the UI promise in frontend/src/renderer/i18n/en.json: “When disabled, review comments will not be sent to the worker agent but will be displayed.”

Fix

Treat injection eligibility as the conjunction of both policies:

persisted_feedback.auto_inject_review && current_session.auto_inject_review

Keep the per-feedback snapshot so re-enabling does not inject feedback captured while disabled, but add a current-session guard in both external SCM observation delivery and AO review-run delivery. Add race/regression tests covering:

  1. captured enabled → toggle off before lifecycle delivery → not injected;
  2. captured disabled → toggle on later → not injected;
  3. captured enabled and still enabled → injected;
  4. AO internal review batch follows the same rules.

Related

  • #3468 — original toggle request.
  • PR #3709 — introduced the toggle and per-feedback snapshot behavior.

neversettle17-101 avatar Aug 11 '26 11:08 neversettle17-101

Assigned to @codebanditssss (review pr #5180)

Rishet11 avatar Sep 15 '26 18:09 Rishet11

reviewed pr #5180. the main toggle-off scenario is covered, but a write-boundary race remains: the session policy can flip off after the new check and before sendOnce() writes, because the final sessionguard predicate checks activity but not autoInjectReview. i requested changes on the pr and did not approve it; this issue remains open.

codebanditssss avatar Sep 15 '26 21:09 codebanditssss

I reproduced this against current main (f3da85d712e287b9bdba8a04b63cddba579257aa) in an isolated native Electron run and in backend integration tests.

In the UI, turning auto-inject off returned PATCH 200 and persisted the session setting as false, but the previously captured comment remained visible with its captured autoInjectReview=true. The UI does not mark that row as having been captured under the earlier setting.

The service/lifecycle/controller tests used real SQLite and exercised both comments and changes-requested review summaries. With capture enabled and then policy disabled, one outbound message was still delivered to a fake capture messenger (expected zero). A deterministic barrier that disabled the policy after the eligibility check but before sendOnce produced the same result. Turning capture off and then back on did not retro-inject older rows.

This confirms the stale-setting and write-boundary behavior. Scope: the SCM and outbound worker were fake; the native-daemon run did not send a real review or exercise the send race. No live agent/model or external review was used.

codebanditssss avatar Nov 28 '26 17:11 codebanditssss