Skip to content

Commit 041eac4

Browse files
author
Your Name
committed
Refactor: Consistent state access in attemptApiRequest
1 parent 38e60a4 commit 041eac4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/core/task/Task.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ export class Task extends EventEmitter<ClineEvents> {
15631563

15641564
const contextWindow = modelInfo.contextWindow
15651565

1566-
const autoCondenseContext = state?.experiments?.autoCondenseContext ?? false
1566+
const autoCondenseContext = experiments?.autoCondenseContext ?? false
15671567
const truncateResult = await truncateConversationIfNeeded({
15681568
messages: this.apiConversationHistory,
15691569
totalTokens: contextTokens,
@@ -1627,7 +1627,7 @@ export class Task extends EventEmitter<ClineEvents> {
16271627
} catch (error) {
16281628
this.isWaitingForFirstChunk = false
16291629
// note that this api_req_failed ask is unique in that we only present this option if the api hasn't streamed any content yet (ie it fails on the first chunk due), as it would allow them to hit a retry button. However if the api failed mid-stream, it could be in any arbitrary state where some tools may have executed, so that error is handled differently and requires cancelling the task entirely.
1630-
if (state?.autoApprovalEnabled && state?.alwaysApproveResubmit) {
1630+
if (autoApprovalEnabled && alwaysApproveResubmit) {
16311631
let errorMsg
16321632

16331633
if (error.error?.metadata?.raw) {
@@ -1638,7 +1638,7 @@ export class Task extends EventEmitter<ClineEvents> {
16381638
errorMsg = "Unknown error"
16391639
}
16401640

1641-
const baseDelay = state.requestDelaySeconds || 5
1641+
const baseDelay = requestDelaySeconds || 5
16421642
let exponentialDelay = Math.ceil(baseDelay * Math.pow(2, retryAttempt))
16431643

16441644
// If the error is a 429, and the error details contain a retry delay, use that delay instead of exponential backoff

0 commit comments

Comments
 (0)