浏览代码

feat: add experimental.continue_loop_on_deny config option (#4729)

Co-authored-by: Aiden Cline <[email protected]>
Martijn Baay 2 月之前
父节点
当前提交
7368342bab
共有 2 个文件被更改,包括 4 次插入1 次删除
  1. 1 0
      packages/opencode/src/config/config.ts
  2. 3 1
      packages/opencode/src/session/processor.ts

+ 1 - 0
packages/opencode/src/config/config.ts

@@ -783,6 +783,7 @@ export namespace Config {
             .array(z.string())
             .array(z.string())
             .optional()
             .optional()
             .describe("Tools that should only be available to primary agents."),
             .describe("Tools that should only be available to primary agents."),
+          continue_loop_on_deny: z.boolean().optional().describe("Continue the agent loop when a tool call is denied"),
         })
         })
         .optional(),
         .optional(),
     })
     })

+ 3 - 1
packages/opencode/src/session/processor.ts

@@ -12,6 +12,7 @@ import { SessionRetry } from "./retry"
 import { SessionStatus } from "./status"
 import { SessionStatus } from "./status"
 import { Plugin } from "@/plugin"
 import { Plugin } from "@/plugin"
 import type { Provider } from "@/provider/provider"
 import type { Provider } from "@/provider/provider"
+import { Config } from "@/config/config"
 
 
 export namespace SessionProcessor {
 export namespace SessionProcessor {
   const DOOM_LOOP_THRESHOLD = 3
   const DOOM_LOOP_THRESHOLD = 3
@@ -49,6 +50,7 @@ export namespace SessionProcessor {
       },
       },
       async process(streamInput: StreamInput) {
       async process(streamInput: StreamInput) {
         log.info("process")
         log.info("process")
+        const shouldBreak = (await Config.get()).experimental?.continue_loop_on_deny !== true
         while (true) {
         while (true) {
           try {
           try {
             let currentText: MessageV2.TextPart | undefined
             let currentText: MessageV2.TextPart | undefined
@@ -228,7 +230,7 @@ export namespace SessionProcessor {
                     })
                     })
 
 
                     if (value.error instanceof Permission.RejectedError) {
                     if (value.error instanceof Permission.RejectedError) {
-                      blocked = true
+                      blocked = shouldBreak
                     }
                     }
                     delete toolcalls[value.toolCallId]
                     delete toolcalls[value.toolCallId]
                   }
                   }