Skip to content

Commit 9993732

Browse files
authored
Merge branch 'dev' into feat/python_sdk
2 parents 62f7da5 + b66e7b6 commit 9993732

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

packages/opencode/src/config/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ export namespace Config {
586586
.optional(),
587587
})
588588
.optional(),
589+
chatMaxRetries: z.number().optional().describe("Number of retries for chat completions on failure"),
589590
disable_paste_summary: z.boolean().optional(),
590591
})
591592
.optional(),

packages/opencode/src/session/compaction.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Log } from "../util/log"
1616
import { SessionLock } from "./lock"
1717
import { ProviderTransform } from "@/provider/transform"
1818
import { SessionRetry } from "./retry"
19+
import { Config } from "@/config/config"
1920

2021
export namespace SessionCompaction {
2122
const log = Log.create({ service: "session.compaction" })
@@ -258,12 +259,14 @@ export namespace SessionCompaction {
258259
}
259260

260261
let stream = doStream()
262+
const cfg = await Config.get()
263+
const maxRetries = cfg.experimental?.chatMaxRetries ?? MAX_RETRIES
261264
let result = await process(stream, {
262265
count: 0,
263-
max: MAX_RETRIES,
266+
max: maxRetries,
264267
})
265268
if (result.shouldRetry) {
266-
for (let retry = 1; retry < MAX_RETRIES; retry++) {
269+
for (let retry = 1; retry < maxRetries; retry++) {
267270
const lastRetryPart = result.parts.findLast((p) => p.type === "retry")
268271

269272
if (lastRetryPart) {
@@ -300,7 +303,7 @@ export namespace SessionCompaction {
300303
stream = doStream()
301304
result = await process(stream, {
302305
count: retry,
303-
max: MAX_RETRIES,
306+
max: maxRetries,
304307
})
305308
if (!result.shouldRetry) {
306309
break

packages/opencode/src/session/prompt.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import { Command } from "../command"
5050
import { $, fileURLToPath } from "bun"
5151
import { ConfigMarkdown } from "../config/markdown"
5252
import { SessionSummary } from "./summary"
53+
import { Config } from "@/config/config"
5354

5455
export namespace SessionPrompt {
5556
const log = Log.create({ service: "session.prompt" })
@@ -330,12 +331,14 @@ export namespace SessionPrompt {
330331
})
331332

332333
let stream = doStream()
334+
const cfg = await Config.get()
335+
const maxRetries = cfg.experimental?.chatMaxRetries ?? MAX_RETRIES
333336
let result = await processor.process(stream, {
334337
count: 0,
335-
max: MAX_RETRIES,
338+
max: maxRetries,
336339
})
337340
if (result.shouldRetry) {
338-
for (let retry = 1; retry < MAX_RETRIES; retry++) {
341+
for (let retry = 1; retry < maxRetries; retry++) {
339342
const lastRetryPart = result.parts.findLast((p) => p.type === "retry")
340343

341344
if (lastRetryPart) {
@@ -372,7 +375,7 @@ export namespace SessionPrompt {
372375
stream = doStream()
373376
result = await processor.process(stream, {
374377
count: retry,
375-
max: MAX_RETRIES,
378+
max: maxRetries,
376379
})
377380
if (!result.shouldRetry) {
378381
break

0 commit comments

Comments
 (0)