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:
@@ -114,6 +114,12 @@ export class GithubExecutor extends BaseExecutor {
|
|||||||
return !/gpt-5\.4/i.test(model);
|
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) {
|
transformRequest(model, body, stream, credentials) {
|
||||||
const transformed = { ...body };
|
const transformed = { ...body };
|
||||||
if (this.requiresMaxCompletionTokens(model) && transformed.max_tokens !== undefined) {
|
if (this.requiresMaxCompletionTokens(model) && transformed.max_tokens !== undefined) {
|
||||||
@@ -124,6 +130,11 @@ export class GithubExecutor extends BaseExecutor {
|
|||||||
if (!this.supportsTemperature(model) && transformed.temperature !== undefined) {
|
if (!this.supportsTemperature(model) && transformed.temperature !== undefined) {
|
||||||
delete transformed.temperature;
|
delete transformed.temperature;
|
||||||
}
|
}
|
||||||
|
// Strip thinking/reasoning_effort — unsupported on /chat/completions
|
||||||
|
if (!this.supportsThinking(model)) {
|
||||||
|
delete transformed.thinking;
|
||||||
|
delete transformed.reasoning_effort;
|
||||||
|
}
|
||||||
return transformed;
|
return transformed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user