fix(core): rotate session ID on model fallback to prevent stateful API errors (#28469)

This commit is contained in:
amelidev
2026-07-23 13:36:46 -06:00
committed by GitHub
parent d76d2d0742
commit 3c1bb8c35d
5 changed files with 99 additions and 6 deletions
+8 -4
View File
@@ -86,6 +86,10 @@ export class CodeAssistServer implements ContentGenerator {
readonly config?: Config,
) {}
getEffectiveSessionId(): string | undefined {
return this.config?.getSessionId() ?? this.sessionId;
}
async generateContentStream(
req: GenerateContentParameters,
userPromptId: string,
@@ -117,7 +121,7 @@ export class CodeAssistServer implements ContentGenerator {
req,
userPromptId,
this.projectId,
this.sessionId,
this.getEffectiveSessionId(),
enabledCreditTypes,
),
req.config?.abortSignal,
@@ -153,7 +157,7 @@ export class CodeAssistServer implements ContentGenerator {
translatedResponse,
streamingLatency,
req.config?.abortSignal,
server.sessionId, // Use sessionId as trajectoryId
server.getEffectiveSessionId(), // Use sessionId as trajectoryId
);
if (response.consumedCredits) {
@@ -204,7 +208,7 @@ export class CodeAssistServer implements ContentGenerator {
req,
userPromptId,
this.projectId,
this.sessionId,
this.getEffectiveSessionId(),
undefined,
),
req.config?.abortSignal,
@@ -224,7 +228,7 @@ export class CodeAssistServer implements ContentGenerator {
translatedResponse,
streamingLatency,
req.config?.abortSignal,
this.sessionId, // Use sessionId as trajectoryId
this.getEffectiveSessionId(), // Use sessionId as trajectoryId
);
if (response.remainingCredits) {