Skip to content

Commit abab31f

Browse files
yohiclaude
andcommitted
fix(permission): honor continue_loop_on_deny for doom_loop rejections
doom_loop拒否時の処理をfailToolCall経由に統一し、既存の権限拒否ハンドラと 挙動を揃える。これにより以下を解決する: - ctx.blocked のハードコード(true)をやめ、ctx.shouldBreak (continue_loop_on_deny設定)を尊重する - 拒否されたツールコールをerror状態へ遷移させる(cleanup任せにしない) - DeniedError経由の拒否でもループを停止する(failToolCallの判定に追加) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 0efb8db commit abab31f

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

packages/opencode/src/session/processor.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,11 @@ export const layer = Layer.effect(
205205
time: { start: match.part.state.time.start, end: Date.now() },
206206
},
207207
})
208-
if (error instanceof PermissionV1.RejectedError || error instanceof Question.RejectedError) {
208+
if (
209+
error instanceof PermissionV1.RejectedError ||
210+
error instanceof PermissionV1.DeniedError ||
211+
error instanceof Question.RejectedError
212+
) {
209213
ctx.blocked = ctx.shouldBreak
210214
}
211215
yield* settleToolCall(toolCallID)
@@ -451,13 +455,15 @@ export const layer = Layer.effect(
451455
}),
452456
)
453457
if (Exit.isFailure(res)) {
454-
const cause = res.cause
455-
const error = Cause.squash(cause)
458+
const error = Cause.squash(res.cause)
459+
// A denied/rejected doom_loop prompt marks the tool call as errored and
460+
// stops the loop the same way other permission rejections do, honoring
461+
// `continue_loop_on_deny` via failToolCall (ctx.blocked = ctx.shouldBreak).
456462
if (error instanceof PermissionV1.RejectedError || error instanceof PermissionV1.DeniedError) {
457-
ctx.blocked = true
463+
yield* failToolCall(value.id, error)
458464
return
459465
}
460-
return yield* Effect.failCause(cause)
466+
return yield* Effect.failCause(res.cause)
461467
}
462468
return
463469
}

0 commit comments

Comments
 (0)