Repository navigation
fix(antigravity): a mid-turn 404 shows its error and is retryable #39869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ca6df89
80bb225
85dd281
f0b16e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -368,6 +368,8 @@ export function acpPerTurnPromptUsage( | |||||||||||||||||||||||||||
| interface AcpPromptOutcomeFailure { | ||||||||||||||||||||||||||||
| readonly failure: OrchestrationV2ProviderFailure; | ||||||||||||||||||||||||||||
| readonly threadDisposition: "reusable" | "broken"; | ||||||||||||||||||||||||||||
| /** The native session can carry on: the turn resends this prompt once before failing. */ | ||||||||||||||||||||||||||||
| readonly resumeWith?: string; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export interface AcpAdapterV2Flavor { | ||||||||||||||||||||||||||||
|
|
@@ -1670,6 +1672,8 @@ interface ActiveAcpTurn { | |||||||||||||||||||||||||||
| foregroundIdle: Deferred.Deferred<void>; | ||||||||||||||||||||||||||||
| /** Counts the turn's prompts; only the latest one settles the turn. */ | ||||||||||||||||||||||||||||
| promptSequence: number; | ||||||||||||||||||||||||||||
| /** The turn already resent a prompt after a resumable outcome failure. */ | ||||||||||||||||||||||||||||
| outcomeResumed: boolean; | ||||||||||||||||||||||||||||
| /** Clock millis just before `session/prompt` was handed to the runtime. */ | ||||||||||||||||||||||||||||
| promptSentAt: number | null; | ||||||||||||||||||||||||||||
| /** Completed when an update after dispatch matches `cancelAfterPromptStarts.isStart`. */ | ||||||||||||||||||||||||||||
|
|
@@ -8967,7 +8971,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* ( | |||||||||||||||||||||||||||
| readonly promptParts: Effect.Success<ReturnType<typeof resolvePromptParts>> | null; | ||||||||||||||||||||||||||||
| readonly compactSession: AcpAdapterV2Flavor["compactSession"]; | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| ) => { | ||||||||||||||||||||||||||||
| ): Effect.Effect<void> => { | ||||||||||||||||||||||||||||
| const sequence = ++context.promptSequence; | ||||||||||||||||||||||||||||
| const superseded = () => context.promptSequence !== sequence; | ||||||||||||||||||||||||||||
| return prompt(superseded).pipe( | ||||||||||||||||||||||||||||
|
|
@@ -9034,6 +9038,43 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* ( | |||||||||||||||||||||||||||
| result.stopReason === "cancelled" | ||||||||||||||||||||||||||||
| ? undefined | ||||||||||||||||||||||||||||
| : yield* settle.checkPromptOutcome(result); | ||||||||||||||||||||||||||||
| const resumeWith = hiddenFailure?.resumeWith; | ||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||
| hiddenFailure !== undefined && | ||||||||||||||||||||||||||||
| resumeWith !== undefined && | ||||||||||||||||||||||||||||
| steersWithPrompt && | ||||||||||||||||||||||||||||
| !context.outcomeResumed | ||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||
|
Comment on lines
+9042
to
+9047
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exclude interrupted turns from automatic resumption. When Stop sets Add an interruption check to the resume condition: Suggested fix
Interrupted contexts then reach the existing settlement path, which finalizes them as Committable suggestion
|
||||||||||||||||||||||||||||
| context.outcomeResumed = true; | ||||||||||||||||||||||||||||
| yield* reportProviderRetry({ | ||||||||||||||||||||||||||||
| sessionId: context.nativeThreadId, | ||||||||||||||||||||||||||||
| failure: hiddenFailure.failure, | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| yield* steerWithPrompt({ | ||||||||||||||||||||||||||||
| threadId: context.input.threadId, | ||||||||||||||||||||||||||||
| runId: context.input.runId, | ||||||||||||||||||||||||||||
| providerThread: context.input.providerThread, | ||||||||||||||||||||||||||||
| providerTurnId: context.providerTurnId, | ||||||||||||||||||||||||||||
| message: { ...context.input.message, text: resumeWith, attachments: [] }, | ||||||||||||||||||||||||||||
| }).pipe( | ||||||||||||||||||||||||||||
| Effect.catchCause(() => | ||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||||||||
| runRuntimeCallbackAtGeneration( | ||||||||||||||||||||||||||||
| settle.generation, | ||||||||||||||||||||||||||||
| Effect.gen(function* () { | ||||||||||||||||||||||||||||
| if (context.finalized || context.interrupted) return; | ||||||||||||||||||||||||||||
| yield* Ref.set(runtimeRestartRequired, true); | ||||||||||||||||||||||||||||
| yield* terminalizeOpenForegroundTools(context, "failed"); | ||||||||||||||||||||||||||||
| yield* finalizeTurn(context, "failed", hiddenFailure.failure, { | ||||||||||||||||||||||||||||
| childTurnsContinue: hasSurvivingBackgroundWork(context), | ||||||||||||||||||||||||||||
| threadDisposition: hiddenFailure.threadDisposition, | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||
| Effect.forkIn(sessionScope), | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| if (hiddenFailure !== undefined) { | ||||||||||||||||||||||||||||
| yield* Ref.set(runtimeRestartRequired, true); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
@@ -9104,7 +9145,12 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* ( | |||||||||||||||||||||||||||
| error.success._tag === "AcpRequestError" && | ||||||||||||||||||||||||||||
| error.success.code === -32800); | ||||||||||||||||||||||||||||
| const failure = Cause.squash(cause); | ||||||||||||||||||||||||||||
| if (!interrupted && flavor.restartRuntimeAfterPromptError?.(failure) === true) { | ||||||||||||||||||||||||||||
| // A resumed prompt stands in for an outcome failure, which always restarts. | ||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||
| !interrupted && | ||||||||||||||||||||||||||||
| (context.outcomeResumed || | ||||||||||||||||||||||||||||
| flavor.restartRuntimeAfterPromptError?.(failure) === true) | ||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||
| yield* Ref.set(runtimeRestartRequired, true); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| // An agent that answered with an error may still finish tools it started, | ||||||||||||||||||||||||||||
|
|
@@ -9312,6 +9358,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* ( | |||||||||||||||||||||||||||
| promptDispatched, | ||||||||||||||||||||||||||||
| foregroundIdle: yield* Deferred.make<void>(), | ||||||||||||||||||||||||||||
| promptSequence: 0, | ||||||||||||||||||||||||||||
| outcomeResumed: false, | ||||||||||||||||||||||||||||
| promptSentAt: null, | ||||||||||||||||||||||||||||
| promptStarted, | ||||||||||||||||||||||||||||
| promptUsage: undefined, | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exclude binary length prefixes from the status capture.
turnFailuredecodes the entire payload before this match. A length-delimited string has a length prefix immediately before its text. (protobuf.dev)For
NOT_FOUND (code 404): Requested entity was not found for this model., that prefix is0x44(D). This regex capturesDNOT_FOUND, which becomes the displayed failure code. The current fixture uses0x37, so it misses this case.Extract the encoded string before matching its status. Preserve parsing of both supported error formats.