Repository navigation
Conversation
A review's decision is keyed by (instance_id, step_id), which a span retry or a resume keeps. put_awaiting ignored the duplicate, so the re-run review went on with the first output's decision. It now stores a digest of the upstream summary and replaces the record when that differs; the same output keeps its decision.
| if upstream is not None: | ||
| filt = Filter.of(instance_id=instance_id, step_id=step_id) | ||
| filt = filt.where("upstream_digest", Ne(digest)) | ||
| self._doc_store.replace(REVIEWS_COLLECTION, filt, doc) |
There was a problem hiding this comment.
Old approval accepts new output
An operator can open output A, then submit their decision after the review times out and a retry registers output B. This replacement keeps the same identifiers, so the delayed set_decision(..., CONTINUE) approves B instead. set_decision checks only the identifiers and AWAITING, and the worker accepts the decision without checking the output. The task then continues with output the operator never saw.
Require the displayed review's digest or generation when saving a decision, and reject stale submissions.
How this was verified: Changed output replaces the record under the same identifiers, while the decision write and worker poll never compare the output's digest.
Knowledge Base Used: Task-step context and execution
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/task_step/review_store.py
Line: 79-82
Comment:
**Old approval accepts new output**
An operator can open output A, then submit their decision after the review times out and a retry registers output B. This replacement keeps the same identifiers, so the delayed `set_decision(..., CONTINUE)` approves B instead. `set_decision` checks only the identifiers and `AWAITING`, and the worker accepts the decision without checking the output. The task then continues with output the operator never saw.
Require the displayed review's digest or generation when saving a decision, and reject stale submissions.
**How this was verified:** Changed output replaces the record under the same identifiers, while the decision write and worker poll never compare the output's digest.
**Knowledge Base Used:** [Task-step context and execution](https://app.greptile.com/-/switch-tenant?tenant=scale-ai&next=%2Fcustom-context%2Fknowledge-base%2Fscaleapi%2Fagentenv-framework%2F-%2Fdocs%2Ftask-step-execution.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
What and why
A review's decision now holds for the output it was given on.
ReviewStore.put_awaitingstores a sha256 of theupstreamsummary with the record (upstream_digest). Registered again with a differentupstream, the review replaces its record with a new awaiting one that carries the new output. The same output, or a call withoutupstream, keeps a recorded decision, as before.ReviewTaskStepand the signature ofput_awaitingare unchanged.A
retry_configspan that covers a review re-runs the agent on a fresh world. The review then found the first attempt's decision under the same(instance_id, step_id)and went on at once. The retried output was collected whilereview_decisionscredited an operator who never saw it, and the stored review still showed the first output. A review that retries itself (an abort regenerates the output) aborted the new output on the old abort, and a resume of the same instance from before the review reused the old decision too. Keying on the run's attempt epoch instead doesn't work: every re-register of the instance bumps it, so a resume at the review would ask again about the same output.Closes #938
How it was tested
tst/unit/task_step/retry_test.py, with the real scheduler, instance store and review store; the operator useslist_awaitingandset_decision, as the hub would:test_a_review_the_retry_re_runs_waits_for_a_decision_on_the_new_output,test_a_review_that_regenerates_a_rejected_output_asks_about_the_new_oneandtest_a_resume_from_before_the_review_asks_about_the_new_outputfail on main and pass with the fix.test_a_resume_at_the_review_keeps_the_decision_given_on_its_outputpasses on main and with the fix. It fails if the re-open keys on the attempt epoch.tst/unit/task_step/test_review.py::test_a_decision_stands_for_the_output_it_was_given_on: the same output keeps the decision; a new one awaits with its ownupstream.tst/unit/task_stepwithtst/unit/config/test_reset_config.py: 4701 passed (main: 4696).tst/integration/task_step/review_store_test.py: 3 passed, unchanged. Fulltst/unitandpackages/agentenv-protocol/tests: 19905 passed, 8 skipped (main: 19900). The 2test_mcp_cli_builder.pycodegen tests fail on main too, in an environment whose systempython3lackshttpx.ruff checkclean;check_plugin_api.py: no break to the plugin surface.Risks
upstream_digest, so a re-register over it keeps its decision, as today (Nedoesn't match an absent field), until the store's 7-day TTL removes it. Stores without TTL support, such as the local SQLite one, keep it.Block merging until operator decisions are tied to the output the operator saw.
Fix with agent prompt
Summary
The PR stores an
upstream_digestand reopens a review when its summarized output changes.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Register output] --> B{Existing digest differs?} B -->|No| C[Keep existing decision] B -->|Yes| D[Replace with awaiting review] D --> E[Operator submits decision] E --> F[Worker continues or aborts] G[Delayed decision for old output] --> EReviews (1) · Last reviewed commit: "fix(review): a review asks again when th..." · Reviewed by Greptile