Merge pull request #923 from GGGO076/fix/github-copilot-v2

fix: GitHub Copilot token refresh failure and reasoning field stripping
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-04-02 14:37:04 -03:00
committed by GitHub
2 changed files with 23 additions and 0 deletions

View File

@@ -55,6 +55,19 @@ export class GithubExecutor extends BaseExecutor {
);
delete modifiedBody.response_format;
}
// Strip reasoning_text / reasoning_content from assistant messages.
// GitHub Copilot converts these into Anthropic thinking blocks but cannot
// supply a valid `signature`, causing upstream 400 errors.
if (Array.isArray(modifiedBody.messages)) {
for (const msg of modifiedBody.messages) {
if (msg.role === "assistant") {
delete msg.reasoning_text;
delete msg.reasoning_content;
}
}
}
return modifiedBody;
}
@@ -167,6 +180,10 @@ export class GithubExecutor extends BaseExecutor {
...githubTokens,
copilotToken: copilotResult.token,
copilotTokenExpiresAt: copilotResult.expiresAt,
providerSpecificData: {
copilotToken: copilotResult.token,
copilotTokenExpiresAt: copilotResult.expiresAt,
},
};
}
return githubTokens;
@@ -179,6 +196,10 @@ export class GithubExecutor extends BaseExecutor {
refreshToken: credentials.refreshToken,
copilotToken: copilotResult.token,
copilotTokenExpiresAt: copilotResult.expiresAt,
providerSpecificData: {
copilotToken: copilotResult.token,
copilotTokenExpiresAt: copilotResult.expiresAt,
},
};
}

View File

@@ -141,6 +141,8 @@ export async function checkAndRefreshToken(provider: string, credentials: any) {
copilotToken: copilotToken.token,
copilotTokenExpiresAt: copilotToken.expiresAt,
};
// Sync to top-level so buildHeaders() picks up the fresh token
updatedCredentials.copilotToken = copilotToken.token;
}
}
}