Просмотр исходного кода

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

Co-authored-by: Aiden Cline <[email protected]>
Martijn Baay 2 месяцев назад
Родитель
Сommit
7368342bab

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

@@ -783,6 +783,7 @@ export namespace Config {
             .array(z.string())
             .optional()
             .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(),
     })

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

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