Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix: GitHub Copilot token refresh and reasoning field stripping
mac51c734e4388a
diff --git a/open-sse/executors/github.ts b/open-sse/executors/github.tsindex 95c8f1f762..42abe949a7 100644--- a/open-sse/executors/github.ts+++ b/open-sse/executors/github.ts@@ -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,+ },};}diff --git a/src/sse/services/tokenRefresh.ts b/src/sse/services/tokenRefresh.tsindex 87231e96a9..520e2d9992 100644--- a/src/sse/services/tokenRefresh.ts+++ b/src/sse/services/tokenRefresh.ts@@ -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;}}}