GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(agent): stop a denied tool looping past the repeated-failure halt by Vasanthdev2004 · Pull Request #866 · Twigpine/zero Conversation
|
| mutation | fails |
|---|---|
| revert the denial re-key to text signature | TestPermissionDenialStreakSurvivesVaryingReasonText, TestAnotherToolSucceedingDoesNotClearAFailingToolsStreak |
| delete the content-blind bound | TestToolFailingWithDifferentErrorsEveryTimeStillStops, TestSuccessResetsBothFailureCounters |
| let a signature change reset the content-blind counter | same two |
TestSuccessResetsBothFailureCounters is the regression guard that makes the new bound safe to add — it drives the tool to one below the bound, succeeds once, and requires a full fresh count afterwards rather than a resumed one.
Behaviour when nothing is looping is unchanged: toolFailureStopAt and toolFailureHintAt keep their values and their existing semantics.
One existing test call site gains the new parameter. internal/agent green, gofmt and vet clean.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe tool loop classifies structured policy refusals only for failed results and passes denial categories to guardrails. Guardrails track repeated signatures and varied failures, reset counters after success, and stop at either threshold. Tests cover classification, isolation, retry hints, end-to-end halting, posture behavior, and stop-message wording. ChangesTool failure guardrails
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant ToolRegistry
participant ToolExecutionLoop
participant PolicyClassifier
participant Guardrails
ToolRegistry-->>ToolExecutionLoop: Return result with refusal metadata
ToolExecutionLoop->>PolicyClassifier: Classify failed result
PolicyClassifier-->>ToolExecutionLoop: Return refusal and retriable status
ToolExecutionLoop->>Guardrails: Pass result and denial category
Guardrails-->>ToolExecutionLoop: Return stop outcome and stop-answer cause
Merge Risk:
|
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly and concisely describes the main change: stopping denied tools from exceeding the repeated-failure halt. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 82.35% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 13 files. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
fix/guardrail-denial-counter-rekey
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
internal/agent/guardrails_test.go (1)
262-283: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExercise the same-signature counter reset.
Both loops use a new error string on every call. Therefore,
countstays at1and this test only proves theanyErrorCountreset. Add repeated identical failures before and after the success, then assert that the sixth post-success failure stops the tool.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/agent/guardrails_test.go` around lines 262 - 283, Update TestSuccessResetsBothFailureCounters to use the same failure signature repeatedly in both loops, rather than generating distinct error strings. Ensure the pre-success sequence establishes both counters, then verify that after the success the sixth identical post-success failure stops the tool, proving the signature-specific count reset as well as the any-error reset.
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/agent/loop.go`:
- Around line 742-743: In internal/agent/loop.go at lines 742-743, update the
failure flag passed to observeToolResult to include cases where
toolResult.DenialReason is non-empty, so that policy denials are tracked as
failures. In internal/agent/guardrails.go at lines 510-512, preserve the
category-based counting logic for denials but prevent InjectHint from being
called when a denial is present, since schema hints should not encourage
retrying blocked behavior. In internal/agent/guardrails_test.go at lines
217-234, add a new Run-level regression test that submits repeated categorized
denials and asserts that the run terminates at the toolFailureStopAt limit
rather than continuing until the turn limit.
---
Nitpick comments:
In `@internal/agent/guardrails_test.go`:
- Around line 262-283: Update TestSuccessResetsBothFailureCounters to use the
same failure signature repeatedly in both loops, rather than generating distinct
error strings. Ensure the pre-success sequence establishes both counters, then
verify that after the success the sixth identical post-success failure stops the
tool, proving the signature-specific count reset as well as the any-error reset.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2eb0a201-6787-4a37-9f48-63bf467db61d
internal/agent/guardrails.gointernal/agent/guardrails_test.gointernal/agent/loop.go
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Zero automated PR reviewVerdict: No blockers found Blockers
Validation
ScopeHead: This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jatmn @anandh8x @gnanam1990 — one guard change, but it lands differently for each of you, so here's the short version of why I'm tagging all three. The repeated-failure halt has never been able to fire on a permission denial. It keys the streak on the first 80 characters of the error text, and a denial message embeds the path or command that was refused — so the text is different every call while the refusal is identical. The record rebuilt at 1 each time and a halt set to 6 was simply unreachable. I hit it for real: 384 denied calls, 26 minutes, no files, no error. @jatmn — the part worth your scepticism is the second counter, not the re-key. It's content-blind, so nothing about the error text can reset it, and it stops at 12 rather than 6. I chose the looser bound because a model iterating on a tricky edit legitimately fails several times with different errors while converging, and cutting those runs short would be a worse bug than the one I'm fixing. That's the same argument that moved @anandh8x — this touches the agent loop, one line at the @gnanam1990 — most relevant to #829. Zeromaxing raises the turn budget 80 → 480 and says so in the banner, which means it multiplies this exact failure by six: a run that would have burned 80 turns going nowhere now burns 480. The 384-call run I measured was under zeromaxing. This fix is upstream of your PR, so #829 gets it for free, but it's worth knowing the posture was amplifying a real unbounded loop rather than just a slow one. This generalises #702 rather than replacing it. That fix made one error message id-invariant so its streak could count; this keys denials on Six tests, and every guard mutation-checked — reverting the re-key, deleting the content-blind bound, or letting a signature change reset it each turn tests red. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Two blocking issues remain on the latest commit:
internal/agent/loop.go:742-743 still passes only isRetriableToolError(toolResult) as the guard failure flag. Categorized denials intentionally return false there, so observeToolResult takes its success branch and deletes the record before it can key on DenialReason. I reproduced this against the exact head: six varying DenialPermissionDenied results never stop. Please count retriableFailure OR a non-empty toolResult.DenialReason, while keeping schema-hint injection disabled for denials, and add a Run-level regression so the production call path, not only the guard helper, is covered.
internal/agent/guardrails.go:529-530 returns the signature-specific record.count even when the new content-blind anyErrorCount is what trips the stop. With twelve distinct errors, count is 1, so loop.go:753 reports that the tool failed 1 time with the same error. Return enough outcome information to produce the correct count and a truthful generic or differentiated stop message; cover the rendered final answer.
The focused tests added by the PR pass and focused vet is clean, but they do not exercise either integration behavior above.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@anandh8x both fixed in 1. Denials now count. The flag is split rather than widened. 2. The count is truthful. 3. The Run-level regression you asked for: I checked it catches your bug rather than assuming. Reverting the flag split: It loops past the bound and dies on the no-output guard 13 turns later — and the helper-level
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/agent/guardrails_test.go`:
- Around line 310-312: The alwaysPromptingTool type is declared twice at package
scope in the test file, which causes a Go redeclaration error. Locate the second
alwaysPromptingTool declaration elsewhere in the file and remove it, preserving
the one shown in the diff that includes the explanatory comment about its
purpose in the Run-level test.
In `@internal/agent/loop.go`:
- Around line 743-749: Update toolResultFromPrePermissionReject to set
ToolResult.DenialReason when converting a pre-permission rejection, mapping the
rejection error type or message to the appropriate DenialCategory such as
DenialFiltered or DenialPermissionDenied. Preserve the existing output and
non-retriable behavior while ensuring categorized pre-permission denials are
counted by the observeToolResult countedFailure logic.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e568f8b9-8d71-42a2-82e8-ad5992a3d842
internal/agent/guardrails.gointernal/agent/guardrails_test.gointernal/agent/loop.go
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Verified empirically on the branch (checked out, built).
What I checked
guardrails.go:524 turns TestRunStopsARepeatedlyDeniedToolAtTheFailureBound red — a 10-denial run no longer halts at 6; it loops until the no-output guard trips at turn 13. The tests exercise the fix, not just the shape.observeToolResult keeps a content-blind anyErrorCount backstop (guardrails.go:541,548, toolFailureAnyErrorStopAt = 12) incremented on every failure regardless of signature. So a denial that isn't categorized (DenialNone), or any non-denial error whose prose varies, still halts. DenialCategory doesn't need to be exhaustive, which is what makes this hold up where #702's per-message id-invariance couldn't. Good call superseding that approach with a structural one.Varied + anyErrorCount, :553), so a tool that failed 12 different ways isn't described as "failed once".:505-509): a categorized denial counts toward the streak but gets no schema hint — a policy refusal isn't a call-shape problem. Correct.guardrails.go, its test, and the one call site in loop.go.Well shaped. The two-tier bound is the right design.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@anandh8x your changes-requested is the only thing blocking this now, and I believe it is stale. You filed it at 12:27 on 4 August, against the head before
gnanam approved on 5 August and jatmn on 6 August, both after that commit. A look when you get a moment would unblock it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
c519809 to
ca6ff84
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Rebased onto current main, so this is mergeable again. Force-pushed, which dismissed the approvals; sorry @gnanam1990 @jatmn, re-requesting. One conflict, in the failure-stop branch of the loop. Main had added
Still open on this PR, unchanged by the rebase: the denial re-key does not fire on the production path, because |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Correction to my previous comment: I was wrong. The re-key is NOT a no-op, and there is nothing outstanding here. I said countedFailure := retriableFailure || toolResult.DenialReason != DenialNone and passes that as the counted-failure argument while still passing Proven rather than re-read, and at the call path rather than the helper, since a helper-level test is exactly what let the original defect through. Mutating that line back to plain Restored, it halts at 6 and passes, along with So the rebase is the only thing that happened here, and this is ready as far as I am concerned. Sorry for the noise, @gnanam1990 @jatmn. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@anandh8x your changes-requested here is from the 4th and predates the fix, so this is only blocked on a re-look. You reproduced the failure on the head at the time, and you were right: my six unit tests all called I re-checked it today by mutation rather than by reading, after wrongly telling this thread it was still broken: reverting that line makes the run take 10 denied calls instead of halting at 6. Rebased onto main, mergeable, CI green. gnanam1990 and jatmn approved after your review. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I found issues that need to be addressed before this is ready.
[P1] Cover the headless Permission required path in this loop fix
internal/agent/loop.go:742
The author’s verified regression covers an OnPermissionRequest denial, which correctly reaches this PR’s typed DenialPermissionDenied path. This separate, existing headless fallback still escapes the same guard: without that callback, the loop skips the prompt branch and registry.RunWithOptions returns Error: Permission required ... without a category; isRetriableToolError deliberately returns false for that text. Consequently countedFailure is false and observeToolResult clears the record on every repeated prompt-tool call, so this blocked execution path still runs until MaxTurns instead of reaching the new halt. Categorize this fallback result or include it in the counted-denial condition, and add a Run-level regression without a permission callback.
[P2] Keep policy denials out of the execution-profile failure trigger
internal/agent/loop.go:744
The new nonzero outcomes for categorized denials are passed directly to profileController, whose OnToolFailureStreak trigger only checks outcome.Count. This changes the built-in Fast profile after two repeated permission/filter/sandbox/hook denials: it restores the displaced turn budget and effort even though no tool executed. That contradicts the trigger's stated contract as a same-tool retriable failure streak and turns a user/policy refusal into an avoidable cost and behavior escalation. Continue counting denials for the guard halt, but exclude them from the profile failure-escalation signal.
[P3] Do not claim all failures had different errors without tracking that
internal/agent/guardrails.go:548
Reaching anyErrorCount proves only that the tool failed consecutively without a success. It does not prove pairwise-distinct errors: for example, five A failures, five B failures, then two C failures reaches 12 while never hitting the six-identical-error stop. The new Varied flag nevertheless makes the final answer say that every failure had a different error. Use wording such as “with varying errors,” or record uniqueness before making the stronger claim; the current test covers only twelve distinct errors.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
ca6ff84 to
b303e4c
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I found issues that need to be addressed before this is ready.
[P1] Count the uncategorized policy refusals in this guard
internal/agent/loop.go:742
countedFailure only accepts retriable errors or results that already carry a DenialReason, but the headless prompt path has neither: when OnPermissionRequest is nil, the loop skips its typed-denial branch and registry.RunWithOptions returns Error: Permission required ... with an empty category. isRetriableToolError deliberately rejects that output, so every repeated prompt call takes observeToolResult's success branch and clears the record. Direct sandbox preflight denials for non-shell tools have the same problem: their SandboxDecision is discarded during tools.Result to ToolResult conversion, leaving the Sandbox block error uncategorized. Thus headless prompt calls and varying out-of-workspace writes can still loop to MaxTurns rather than the new halt. Categorize those registry outcomes (or count these policy refusals explicitly) and cover both paths through Run.
[P2] Keep policy denials out of the execution-profile failure trigger
internal/agent/loop.go:744
The new nonzero outcomes for categorized denials are forwarded straight to profileController, whose OnToolFailureStreak trigger only tests outcome.Count. Consequently, two repeated permission, filter, sandbox, or hook denials in the Fast profile restore the displaced turn budget and reasoning effort even though no tool executed. That contradicts the trigger's documented same-tool retriable-failure contract and spends the one-shot escalation on a user/policy refusal. Continue counting denials for the loop halt, but exclude them from the profile failure-escalation signal.
[P3] Do not state an error pattern the guard does not track
internal/agent/guardrails.go:387
anyErrorCount establishes only that the tool failed consecutively without a success; it does not establish that all failures differed. For example, five A failures, five B failures, and two C failures reach the new bound without reaching the six-same-signature bound, yet Varied makes the final answer say every failure had a different error. The category-keyed denial path has the inverse problem: it intentionally aggregates refusal reasons that can differ by path or command, then the six-count branch calls them the same error. Use neutral wording such as repeated/varying failures, or record the information needed to make either stronger claim, and add a mixed-signature regression.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@anandh8x your 4 August change request is still open here. Both findings were fixed in c519809 that afternoon: a denial now counts toward the repeated-failure streak through the split |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Merged main at 2ffe183 and renamed this branch's imports to the Twigpine module path from #1105. The merge had no conflicts, and nothing else changed. The rename also covers the two |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I found no code-level blockers on head 3322a8b3f1d39ec2efcc1d158e5e04e5e9fc202b. Merge and review hygiene items remain before landing.
Refresh onto live main. origin/main is 164150633a8b2e6ae864ae02fd7105b201eeb68e while the branch merge-base with main is still 5d080ef46b099e4b2bb99f516f559a70cef22957 (one mainline commit ahead, including #1167). GitHub reports mergeable: MERGEABLE but mergeStateStatus: BLOCKED and reviewDecision: CHANGES_REQUESTED. Rebase or merge current main, re-run CI on the resolved tree, and re-request review.
Dismiss stale CHANGES_REQUESTED. anandh8x’s block at 4641b18a predates the countedFailure / isPolicyRefusal wiring and Run-level denial regressions; head includes 69900830 (jatmn LGTM) plus a merge of recent main. A fresh approval from anandh8x (or an explicit dismiss) is still required for GitHub’s review gate even though the underlying defect is fixed.
Required checks on head. All listed GitHub Actions checks for this head are green (unit tests, race, smoke, Zero Review). CodeRabbit is paused after active pushes; not a functional blocker.
Overlap / supersession. No open duplicate PR located for the same guardrail + policy-refusal provenance scope; this remains the authoritative fix for the denial streak bypass described in the PR and #702.
🟢 Thanks for the contribution. I do not see any actionable issues from my review.
What was verified on this head
guardrails.go, loop.go, parallel_tools.go, tools/registry.go, tools/types.go, tools/local_capture.go, plus regression tests.go test ./internal/agent/ passes locally on the review checkout; key regressions including TestRunStopsARepeatedlyDeniedToolAtTheFailureBound, TestRunHaltsARealSandboxDenialOnTheCategoryBound, TestAnExecutedErrorCannotImpersonateARefusal, and TestParallelSiblingsAreFinalizedWhenTheGuardHalts pass.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…counter-rekey #1182 also marks the repeated-failure halt Incomplete under the headless completion gate. This branch already does that a few lines below the conflict, with a reason that says whether the tool failed or was refused, so the branch side is kept and the duplicate block from main is dropped. The reason still names the tool, which is what the #1182 test asserts. #1182's empty-turn change merges as is. #1182 also added an alwaysSucceedingTool test fixture that collides with the one in policy_refusal_status_test.go. They are different tools, so this branch's copy is renamed to blockTextShellTool.
failureKindNone and toolFailureCauseNone were never referenced, so the pinned unused check flagged them. The zero values stay reserved with a blank identifier.
|
@jatmn this push dismissed your approval, sorry. #1182 landed on main with an overlapping change to
8474e82 then drops two zero-value constants that were never referenced ( |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I found issues that need to be addressed before this is ready.
Rebase onto current main before merge. The PR branch is one commit behind live main (d99f92b8 — feat(providers): MiniMax catalog #1180) while merge-base remains 5aa54fe1. GitHub reports the PR mergeable today, but landing without rebasing risks missing that commit and any conflict resolution on shared agent files.
Parallel read-ahead executes an entire eligible batch before the guard consumes the first failure in that turn. parallel_tools.go states guard counters stay byte-identical to sequential execution, but closeOutRemaining deliberately does not call observeToolResult for drained siblings. A halt on the first consumed call in an up-to-eight batch can therefore perform up to seven extra failing executions before stop (see parallel_readahead_halt_test.go). That may be an acceptable tradeoff; if maintainers intend halt bounds to cap executions rather than consumption order, document or adjust in a follow-up — not necessarily blocking if consumption-order bounds are the product contract.
Prior jatmn / anandh8x / CodeRabbit threads on counting uncategorized refusals, output-based inference, and countedFailure are addressed on head (countedFailure := retriableFailure || policyRefusal, structured isPolicyRefusal, registry refusalResult gates). No remaining action on those specific line items unless regressions appear after rebase.
📍 Where: internal/agent/guardrails.go (toolFailureIncompleteReason), internal/agent/loop.go (guard halt sets IncompleteReason when RequireCompletionSignal)
💥 What fails: When the content-blind bound stops a run with toolFailureCauseVariedMixed, the user-facing stop answer correctly says the tool "failed or was refused" twelve times, but Result.IncompleteReason still says the tool "failed repeatedly" without mentioning refusals.
func toolFailureIncompleteReason(toolName string, cause toolFailureCause) string { if cause.Refused() { return "halted after `" + toolName + "` was refused repeatedly, without completing the task" } return "halted after `" + toolName + "` failed repeatedly, without completing the task" }
VariedMixed is not Refused(), so headless zero exec exit semantics cite incomplete text that disagrees with the public halt answer for the same halt.
🔎 Root cause: This PR added toolFailureCauseVariedMixed and matching stop-answer wording but did not extend toolFailureIncompleteReason for that cause. Merge-base had neither mixed causes nor cause-aware incomplete text (only an inline "failed … same error" string on every guard halt).
📜 Stated contract:
Neither "failed" alone nor "refused" alone is true of this sequence, so the wording says both.
(refusal_provenance_test.go, mixed case in TestTheContentBlindBoundKeepsRefusalProvenance — asserted on stop answer wording; this PR also wires guard halts to toolFailureIncompleteReason for headless runs per TestGuardHaltIsIncompleteUnderTheCompletionGate: a guard halt is unfinished work and headless must hear about it via Incomplete.)
🏷️ Attribution: PR-introduced (mixed cause and stop answer on this branch; incomplete helper added here but not updated for mixed).
📌 In this PR:
toolFailureStopAnswer mixed branch — correcttoolFailureIncompleteReason — missing mixed branchloop.go guard halt → IncompleteReason — uses incomplete helper onlyRequireCompletionSignal check that IncompleteReason matches for VariedMixed🔒 Unchanged on main: Interactive runs without RequireCompletionSignal should remain unaffected.
🔧 Required correction: Teach toolFailureIncompleteReason to describe mixed halts consistently with toolFailureStopAnswer. Add a Run-level test with RequireCompletionSignal for a mixed VariedMixed halt that asserts IncompleteReason matches that combined semantics.
🛠️ Author fix: Close the root cause on every row under In this PR in one pass — helper, halt wiring, and regression test together. Do not change halt thresholds or revert mixed stop-answer wording.
🚫 Out of scope: Rewriting unrelated completion-gate reasons (empty turns, max turns, acceptance gate).
closeOutRemaining drops provider call IDs on finalized siblings📍 Where: internal/agent/loop.go (closeOutRemaining tool message append vs main consumption path)
💥 What fails: When a turn ends early (guard halt, abort, tool stop) after parallel read-ahead, siblings finalized through closeOutRemaining append tool results with ToolCallID but without ToolCallProviderID. The normal consumption path sets both fields for strict provider replay.
🔎 Root cause: This PR added closeOutRemaining to record pre-executed parallel siblings but omitted a field the main loop and appendAbortedToolResults already set. Merge-base early exit used aborted placeholders with provider IDs only; this path is new in the diff.
📜 Stated contract:
Anthropic rejects a tool_use with no answering tool_result.
(Comment above guard halt / transcript validity in loop.go; Codex/OpenAI replay paths also key on ToolCallProviderID.)
🏷️ Attribution: PR-introduced.
📌 In this PR:
ToolCallProviderID: call.ProviderCallIDcloseOutRemaining sibling append — omits ToolCallProviderIDappendAbortedToolResults — includes provider ID (contrast)🔒 Unchanged on main: Sequential-only turns without read-ahead early exit.
🔧 Required correction: Set ToolCallProviderID: nextCall.ProviderCallID on the zeroruntime.Message built inside closeOutRemaining, matching the main path. Extend parallel read-ahead halt tests if message fields are asserted.
🛠️ Author fix: Fix the sibling append and any test expectations together in one pass. Do not change parallel eligibility or guard thresholds.
🚫 Out of scope: Broader transcript schema changes unrelated to provider pairing.
Forged permission_action on executed tool results. On head, executedToolResult strips policy_refusal but not permission_action, and countedFailure now counts isPolicyRefusal outcomes—so a tool that sets Meta["permission_action"]="deny" on an executed error is treated more like a refusal than on merge-base (where only retriableFailure fed the guard and the streak cleared). Built-in tools do not do this; the parallel to TestRunTreatsAForgedRefusalMarkerAsAnExecutedFailure is suggestive but not a verbatim contract for permission_action. Strip at the execution boundary, narrow isPolicyRefusal, or accept the theoretical gap—optional hardening, not raised as a merge-blocking finding after attribution review.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
- toolFailureIncompleteReason gains the mixed branch, so a headless run halted by the content-blind bound over failures and refusals says the tool failed or was refused, as the stop answer does. - closeOutRemaining sets ToolCallProviderID on a drained sibling's tool result, matching the consumption path, so a strict replay can pair it. - executedToolResult strips permission_action as well as the refusal marker. The loop reads a denied permission action as a refusal, so an executed failure carrying one was counted toward the refusal halt. The key is a tools constant now, and the loop uses it too. - The parallel read-ahead comment says what differs from sequential execution: a halt can leave up to seven sibling reads already run. Reported by @jatmn.
|
@jatmn thanks. I merged main at 7c55a09, which was clean and brought only #1180 and the release, and fixed both findings in 2edaba9:
I also took the forged On read-ahead, the bounds count consumed results and the extra executions are reads by the eligibility rule, so I kept that behaviour and corrected the Each fix fails its test when reverted on its own (4 mutations). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Merged current main (ef1ca39) in 98fc068 so the branch isn't behind when you get to the 3 November fixes. It merged without conflicts and nothing in the PR's own changes moved. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🟢 I do not see any actionable code-level issues on head 98fc068095fb3c84222c9576a6876e0fd8108122. I am rechecking this as a maintainer after my own 2026-11-02 CHANGES_REQUESTED; the two P2 items I called out there are fixed on this head, so I would not block merge on code grounds.
anandh8x still has an August CHANGES_REQUESTED from before countedFailure / Run-level denial regressions; I verified those fixes on head—whoever owns that review should re-approve or dismiss. CI is green on this head.98fc068 onto current main; HEAD..origin/main is one commit (today’s release-please 0.13.1 prep). I am fine landing after a quick merge of that tip; rebase only if we want linear history. GitHub reports mergeable.observeToolResult (up to seven extra read-only executions in a worst case). If we want bounds on executions rather than consumption, that is a follow-up—not something I would hold #866 on.| Who | Topic | My read on head 98fc068 |
|---|---|---|
| anandh8x | Pass countedFailure into the guard; correct stop count/cause for the content-blind bound |
Resolved — loop.go countedFailure := retriableFailure || policyRefusal, observeToolResult(..., hintable, ...), cause-aware toolFailureStopAnswer + tests |
| Me (Nov 2) | toolFailureIncompleteReason for VariedMixed must match stop answer |
Resolved — mixed branch in toolFailureIncompleteReason; mixed_halt_reason_test.go with RequireCompletionSignal |
| Me (Nov 2) | closeOutRemaining must set ToolCallProviderID on drained siblings |
Resolved — loop.go:767; asserted in parallel_readahead_halt_test.go |
| Me (Nov 2) | Forged permission_action on executed results |
Resolved — executedToolResult strips policy_refusal and permission_action; registry + run-level forged-marker tests |
| CodeRabbit | Denial counting, duplicate alwaysPromptingTool, capture disabled-driver, sandbox run-path |
Resolved on head for the paths this PR owns |
| gnanam1990 | Stale-base only | Withdrawn earlier; branch has merged main again at 98fc068 |
I did not find any remaining technical open items from those threads on this head unless a rebase introduces regressions.
guardrails.go, loop.go, parallel_tools.go, local_capture.go, registry.go, types.go, and the regression tests.anyErrorCount, structured isPolicyRefusal (no output sniffing), headless Incomplete under RequireCompletionSignal, parallel sibling finalization with provider call IDs.Nothing I would require before merge. Optional later: parallel read-ahead execution vs consumption caps; rolling refusalResult onto other RejectBeforePermission tools outside this diff—I would not expand #866’s scope for that.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.