fix(core): break agent loop on permission rejection with feedback#33623
Open
Haohao-end wants to merge 1 commit into
Open
fix(core): break agent loop on permission rejection with feedback#33623Haohao-end wants to merge 1 commit into
Haohao-end wants to merge 1 commit into
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: I found a potentially related PR: Related PR:
Why it might be related: |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #28793
Type of change
What does this PR do?
When a user rejects a tool call with a feedback message, the permission system throws
CorrectedError(carrying the user's reason in.feedback). This is a separate class fromRejectedError(plain rejection, no message).The loop-break checks in both the V1 processor and V2 session runner only caught
RejectedErrorandQuestion.RejectedError, missingCorrectedErrorentirely. Soctx.blockedwas never set, the agent loop kept running, and the parent re-delegated the same command indefinitely — infinite loop.Changes:
packages/opencode/src/session/processor.ts— addedPermissionV1.CorrectedErrorto theinstanceofcheck so the V1 loop breaks on rejection-with-feedback.packages/core/src/session/runner/llm.ts— extended the V2 halt check (renamedisQuestionRejected→isHalted) to also matchPermissionV2.RejectedErrorandPermissionV2.CorrectedError.CorrectedError.messagealready includes the feedback text, soerrorMessage()picks it up and the reason reaches the model as part of the tool-error result. The missing piece was the loop-break itself.How did you verify your code works?
bun typecheckpasses for bothpackages/coreandpackages/opencode.bash: "deny"and a subagent with bash access. Rejected a delegated bash command with a reason in the permission prompt. The agent loop now halts immediately instead of retrying indefinitely.Screenshots / recordings
N/A — logic change, no UI impact.
Checklist