You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(chat): an approved command runs once, and a step that did not run is never reported as executed (#21959) - #21964
After the graph's approval resume, execute_tools re-dispatched execute_command. The dispatch seam already recognises the approved call through the fingerprint set (ctx.approved_fingerprints, #18430) and returns RUN, but the terminal service then resolves the line again from the role policy (resolve_command_line in services/agent_terminal/ai_line_gate.py). A MEDIUM command is held there, queued as pending_approval, persisted as a second approval card, and polled and never answered. The recorded step (status pending_approval or outcome_unknown) was then counted as an executed step, so the model reported a success that never happened.
Fix: the seam marks an execute_command call whose exact fingerprint the person approved (COMMAND_APPROVED_KEY, reusing the existing fingerprint binding, no new mechanism). The mark travels to decide_command, which treats it as line 2 satisfied. Line 3 (refuse), the risk assessment and the agent permission check still apply. A model-supplied mark is dropped at the seam, and a yes for command X never matches command Y, because the fingerprint covers the raw params.
The approval is consumed by the call it marks, so a duplicate or retried call of the same fingerprint is held again.
Design: a human yes on the exact command satisfies a "needs a human yes" hold in the terminal, including the role-based hold on a HIGH-risk command. The approver is the chat owner the resume route already checked. REFUSE (line 3), the risk assessment and the agent permission check still block.
The continuation prompt counts and describes only steps known to have run (chat_workflow/step_outcome.py). did_execute fails closed: only success, executed (compose) and completed (delegate), or an error carrying a real exit code or output, count. A permission-denied record or an unknown status is NOT RUN.
#13250 (the double gate) is not unified here; only what these two issues need.
chat_workflow/tool_handler.py, tools/terminal_tool.py, services/agent_terminal/service.py, services/agent_terminal/ai_line_gate.py: person_approved carried through to decide_command.
chat_workflow/step_outcome.py (new) and chat_workflow/manager.py: executed-steps count and a "NOT RUN" line for pending, denied, refused or timed-out steps.
Grandfathered files do not grow: tool_handler 3572 to 3571, manager 3728 to 3727. Three small formatting-only hunks in tool_handler.py (two logger calls, one metadata dict) and one in manager.py (_log_task_complete) are the minimum needed to stay at or under the file-size ceiling; check_python_file_size.py exits 0.
The second card stored and streamed on resume (#21751's live recurrence) came from the second terminal gate; with that gate no longer firing for an approved call, there is one card.
Verification
pytest autobot-backend/tests/unit/chat_workflow/test_approved_command_runs_once_21959.py: 17 passed. They cover approve then resume running once with no second gate, an unapproved command still held, a yes for one command not covering another, a forged flag dropped, a refusal not lifted, and a pending step reported as not run and not counted.
Related chat_workflow suites (-k approval or hold or continuation or held or execution_result or command): 239 passed.
ruff check and black --check clean on touched files.
Code ACs met: #21959 AC1 and AC2; #21751's card-count AC (test pinned in #21749, live recurrence root-caused here).
Previously approved terminal commands can now proceed when the exact command is resumed, with approval applying only once.
Workflow summaries now distinguish steps that ran from those that did not, including pending, refused, timed-out and denied steps.
Bug Fixes
Continuation prompts now count steps that actually ran rather than all recorded steps, and failed commands are still counted as run when execution results are present.
Approval markers are cleared before evaluating a command, preventing an incoming marker from granting approval.
The change adds one-time approval propagation for matching terminal commands and updates workflow history reporting. Continuation prompts count executed steps, and formatted history marks steps that did not run.
Changes: Command approval
Layer / File(s)
Summary
Mark and forward command approvals autobot-backend/chat_workflow/tool_dispatch_guards.py, autobot-backend/chat_workflow/tool_handler.py, autobot-backend/tools/terminal_tool.py
A matching approval fingerprint marks an execute_command call, and the fingerprint is consumed. The person_approved value passes through the tool handler and terminal tool. Two log changes only reformat existing messages and metadata.
Apply approval at the command gate autobot-backend/services/agent_terminal/ai_line_gate.py, autobot-backend/services/agent_terminal/service.py, autobot-backend/tests/unit/chat_workflow/test_approved_command_runs_once_21959.py
The command decision gate accepts person_approved and allows a marked command unless approval is forced. Tests cover matching fingerprints, one-time use, forged markers, refusals, permission checks, and terminal dispatches.
Workflow step history
Layer / File(s)
Summary
Classify and report workflow steps autobot-backend/chat_workflow/step_outcome.py, autobot-backend/chat_workflow/manager.py, autobot-backend/tests/unit/chat_workflow/test_approved_command_runs_once_21959.py
New helpers classify executed steps, count them, and return a NOT RUN note for other steps. The manager uses these results in formatted history and continuation prompts. Tests cover status classification and prompt counts.
Merge Risk: Moderate · previous review 54322
When a command is refused, the continuation prompt can still report it as executed. The assistant may then describe the step as done after the command never ran. The approval changes themselves look sound. Fix the refusal case so refused steps stay marked NOT RUN before merging.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names two changes: an approved command runs once, and a step that did not run is never reported as executed. Both match the objectives and the file summaries. The approval marker (person_app…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names two changes: an approved command runs once, and a step that did not run is never reported as executed. Both match the objectives and the file summaries. The approval marker (person_approved) is carried through the tool dispatch, terminal service and ai_line_gate, and the continuation prompt counts only executed steps via did_execute, executed_count and not_run_note. The title is specific and concise. It uses the fix(chat) prefix and the issue number, which fits the convention for this repository.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Notice: 29 open PRs — past the runaway threshold (25)
This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.
This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.
If the queue is draining normally, ignore this. Otherwise:
Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
Look for a loop opening near-identical PRs
Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.
main shrank service.py to 860 lines; the person_approved plumbing grew it to 869.
The two decide_command flags now pass through as keyword flags, so the file stays at 860.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
…NOT RUN (#21959)
_format_command_failure and _record_failed_step defaulted a missing return_code
to 1, so a refusal (no exit code, no output) counted as a run that failed. Both
now carry an exit code only when the result has one (key omitted, never None,
#14148).
mrveiss
added
the
land-next
Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397)
label
Nov 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #21959, Refs #21751, Refs #13250
Thinking Path
After the graph's approval resume,
execute_toolsre-dispatchedexecute_command. The dispatch seam already recognises the approved call through the fingerprint set (ctx.approved_fingerprints, #18430) and returns RUN, but the terminal service then resolves the line again from the role policy (resolve_command_lineinservices/agent_terminal/ai_line_gate.py). A MEDIUM command is held there, queued aspending_approval, persisted as a second approval card, and polled and never answered. The recorded step (statuspending_approvaloroutcome_unknown) was then counted as an executed step, so the model reported a success that never happened.Fix: the seam marks an
execute_commandcall whose exact fingerprint the person approved (COMMAND_APPROVED_KEY, reusing the existing fingerprint binding, no new mechanism). The mark travels todecide_command, which treats it as line 2 satisfied. Line 3 (refuse), the risk assessment and the agent permission check still apply. A model-supplied mark is dropped at the seam, and a yes for command X never matches command Y, because the fingerprint covers the raw params.The approval is consumed by the call it marks, so a duplicate or retried call of the same fingerprint is held again.
Design: a human yes on the exact command satisfies a "needs a human yes" hold in the terminal, including the role-based hold on a HIGH-risk command. The approver is the chat owner the resume route already checked. REFUSE (line 3), the risk assessment and the agent permission check still block.
The continuation prompt counts and describes only steps known to have run (
chat_workflow/step_outcome.py).did_executefails closed: onlysuccess,executed(compose) andcompleted(delegate), or anerrorcarrying a real exit code or output, count. A permission-denied record or an unknown status is NOT RUN.#13250 (the double gate) is not unified here; only what these two issues need.
What Changed
chat_workflow/tool_dispatch_guards.py:COMMAND_APPROVED_KEY,_carry_person_approval, forged-key drop.chat_workflow/tool_handler.py,tools/terminal_tool.py,services/agent_terminal/service.py,services/agent_terminal/ai_line_gate.py:person_approvedcarried through todecide_command.chat_workflow/step_outcome.py(new) andchat_workflow/manager.py: executed-steps count and a "NOT RUN" line for pending, denied, refused or timed-out steps.tests/unit/chat_workflow/test_approved_command_runs_once_21959.py(new).tool_handler.py(two logger calls, one metadata dict) and one inmanager.py(_log_task_complete) are the minimum needed to stay at or under the file-size ceiling;check_python_file_size.pyexits 0.The second card stored and streamed on resume (#21751's live recurrence) came from the second terminal gate; with that gate no longer firing for an approved call, there is one card.
Verification
pytest autobot-backend/tests/unit/chat_workflow/test_approved_command_runs_once_21959.py: 17 passed. They cover approve then resume running once with no second gate, an unapproved command still held, a yes for one command not covering another, a forged flag dropped, a refusal not lifted, and a pending step reported as not run and not counted.-k approval or hold or continuation or held or execution_result or command): 239 passed.ruff checkandblack --checkclean on touched files.Code ACs met: #21959 AC1 and AC2; #21751's card-count AC (test pinned in #21749, live recurrence root-caused here).
Not yet verified (ticked only after deploy)
touchrequest, approved once on the local install, creates the file and the reply matches.Model Used
Claude Sonnet 5.5
Summary by CodeRabbit