File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed
Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff 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 ( ) ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { Log } from "../util/log"
1616import { SessionLock } from "./lock"
1717import { ProviderTransform } from "@/provider/transform"
1818import { SessionRetry } from "./retry"
19+ import { Config } from "@/config/config"
1920
2021export 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
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ import { Command } from "../command"
5050import { $ , fileURLToPath } from "bun"
5151import { ConfigMarkdown } from "../config/markdown"
5252import { SessionSummary } from "./summary"
53+ import { Config } from "@/config/config"
5354
5455export 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
You can’t perform that action at this time.
0 commit comments