summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDanilo Favato <[email protected]>2025-10-28 14:09:41 -0300
committerGitHub <[email protected]>2025-10-28 12:09:41 -0500
commitb66e7b6fce07ff9a225dd225fc198b16718a1239 (patch)
treea56d0eef03cb42b125c8fc24c9a683782a1a9d5e
parenteb398f1951764af812c7ef01f37f01da862a852a (diff)
downloadopencode-b66e7b6fce07ff9a225dd225fc198b16718a1239.tar.gz
opencode-b66e7b6fce07ff9a225dd225fc198b16718a1239.zip
tweak: add experimental chatMaxRetries to config (#2116)
Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Aiden Cline <[email protected]>
-rw-r--r--packages/opencode/src/config/config.ts1
-rw-r--r--packages/opencode/src/session/compaction.ts9
-rw-r--r--packages/opencode/src/session/prompt.ts9
3 files changed, 13 insertions, 6 deletions
diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts
index 42d59226e..83c518a68 100644
--- a/packages/opencode/src/config/config.ts
+++ b/packages/opencode/src/config/config.ts
@@ -586,6 +586,7 @@ export namespace Config {
.optional(),
})
.optional(),
+ chatMaxRetries: z.number().optional().describe("Number of retries for chat completions on failure"),
disable_paste_summary: z.boolean().optional(),
})
.optional(),
diff --git a/packages/opencode/src/session/compaction.ts b/packages/opencode/src/session/compaction.ts
index 657ac4475..4896d5f5e 100644
--- a/packages/opencode/src/session/compaction.ts
+++ b/packages/opencode/src/session/compaction.ts
@@ -16,6 +16,7 @@ import { Log } from "../util/log"
import { SessionLock } from "./lock"
import { ProviderTransform } from "@/provider/transform"
import { SessionRetry } from "./retry"
+import { Config } from "@/config/config"
export namespace SessionCompaction {
const log = Log.create({ service: "session.compaction" })
@@ -258,12 +259,14 @@ export namespace SessionCompaction {
}
let stream = doStream()
+ const cfg = await Config.get()
+ const maxRetries = cfg.experimental?.chatMaxRetries ?? MAX_RETRIES
let result = await process(stream, {
count: 0,
- max: MAX_RETRIES,
+ max: maxRetries,
})
if (result.shouldRetry) {
- for (let retry = 1; retry < MAX_RETRIES; retry++) {
+ for (let retry = 1; retry < maxRetries; retry++) {
const lastRetryPart = result.parts.findLast((p) => p.type === "retry")
if (lastRetryPart) {
@@ -300,7 +303,7 @@ export namespace SessionCompaction {
stream = doStream()
result = await process(stream, {
count: retry,
- max: MAX_RETRIES,
+ max: maxRetries,
})
if (!result.shouldRetry) {
break
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts
index adaa79f31..4d1aa0211 100644
--- a/packages/opencode/src/session/prompt.ts
+++ b/packages/opencode/src/session/prompt.ts
@@ -50,6 +50,7 @@ import { Command } from "../command"
import { $, fileURLToPath } from "bun"
import { ConfigMarkdown } from "../config/markdown"
import { SessionSummary } from "./summary"
+import { Config } from "@/config/config"
export namespace SessionPrompt {
const log = Log.create({ service: "session.prompt" })
@@ -330,12 +331,14 @@ export namespace SessionPrompt {
})
let stream = doStream()
+ const cfg = await Config.get()
+ const maxRetries = cfg.experimental?.chatMaxRetries ?? MAX_RETRIES
let result = await processor.process(stream, {
count: 0,
- max: MAX_RETRIES,
+ max: maxRetries,
})
if (result.shouldRetry) {
- for (let retry = 1; retry < MAX_RETRIES; retry++) {
+ for (let retry = 1; retry < maxRetries; retry++) {
const lastRetryPart = result.parts.findLast((p) => p.type === "retry")
if (lastRetryPart) {
@@ -372,7 +375,7 @@ export namespace SessionPrompt {
stream = doStream()
result = await processor.process(stream, {
count: retry,
- max: MAX_RETRIES,
+ max: maxRetries,
})
if (!result.shouldRetry) {
break