fix(github): strip thinking/reasoning_effort for Copilot chat completions (closes #623)

GitHub Copilot /chat/completions endpoint does not support the thinking
or reasoning_effort fields. OpenClaw sends thinking: { type: "enabled" }
for Claude models which causes a 400 Bad Request.

Added supportsThinking() and strip both fields in transformRequest before
sending to the upstream endpoint.

Co-authored-by: anuragg-saxenaa <anuragg.saxenaa@gmail.com>
Made-with: Cursor
This commit is contained in:
anuragg-saxenaa
2026-04-17 12:34:22 +07:00
committed by decolua
parent 877b7446bb
commit 333af110ed

View File

@@ -114,6 +114,12 @@ export class GithubExecutor extends BaseExecutor {
return !/gpt-5\.4/i.test(model);
}
// GitHub Copilot /chat/completions doesn't support thinking/reasoning_effort.
// OpenClaw sends thinking: { type: "enabled" } for Claude models which causes 400.
supportsThinking() {
return false;
}
transformRequest(model, body, stream, credentials) {
const transformed = { ...body };
if (this.requiresMaxCompletionTokens(model) && transformed.max_tokens !== undefined) {
@@ -124,6 +130,11 @@ export class GithubExecutor extends BaseExecutor {
if (!this.supportsTemperature(model) && transformed.temperature !== undefined) {
delete transformed.temperature;
}
// Strip thinking/reasoning_effort — unsupported on /chat/completions
if (!this.supportsThinking(model)) {
delete transformed.thinking;
delete transformed.reasoning_effort;
}
return transformed;
}