Review feedback can be injected after the session toggle is turned off
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
- Start a worker with automatic review feedback enabled (the default).
- Claim or observe a PR containing a changes-requested review, causing its review rows to be persisted with
auto_inject_review = true. - Turn Automatically send review feedback off before a later PR observation/delivery pass.
- Trigger or wait for the lifecycle PR observation.
- 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.gocopiesSessionRecord.AutoInjectReviewinto persisted review/comment rows.backend/internal/lifecycle/reactions.godecides delivery fromreview.AutoInjectReview/comment.AutoInjectReview, but does not also require the currentSessionRecord.AutoInjectReviewvalue after loading the session.backend/internal/lifecycle/reactions.go::ApplyReviewBatchsimilarly loads the current session but never gates delivery on its current toggle.backend/internal/service/review/review.go::deliverableRunsuses 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:
- captured enabled → toggle off before lifecycle delivery → not injected;
- captured disabled → toggle on later → not injected;
- captured enabled and still enabled → injected;
- AO internal review batch follows the same rules.
Related
Assigned to @codebanditssss (review pr #5180)
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.
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.