Skip to content

Commit 2b0c3bd

Browse files
committed
fix(ai): update OpenAI Responses API parameter name
OpenAI changed the parameter name in their Responses API from `max_completion_tokens` to `max_output_tokens`. This caused requests to fail with: "Unsupported parameter: 'max_completion_tokens'. In the Responses API, this parameter has moved to 'max_output_tokens'." Root Cause: - openai_llm_provider.rs:360 - Used rename="max_completion_tokens" - openai_compatible_provider.rs:484 - Field name was max_completion_tokens (which becomes the JSON key without explicit rename) Fix: - Changed serde rename to "max_output_tokens" in both files - Updated test to verify new parameter name - Kept internal Rust field name as max_completion_tokens for clarity Impact: - OpenAI Responses API calls now use correct parameter - Compatible with current OpenAI API specification - No breaking changes to internal code (field name unchanged) Verified: - MCP server builds successfully - Serialization uses correct JSON key "max_output_tokens" Reference: https://platform.openai.com/docs/api-reference/responses/create
1 parent e8fe23c commit 2b0c3bd

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

crates/codegraph-ai/src/openai_compatible_provider.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,10 @@ struct ResponsesAPIRequest {
480480
input: String,
481481
#[serde(skip_serializing_if = "Option::is_none")]
482482
instructions: Option<String>,
483-
#[serde(skip_serializing_if = "Option::is_none")]
483+
#[serde(
484+
rename = "max_output_tokens",
485+
skip_serializing_if = "Option::is_none"
486+
)]
484487
max_completion_tokens: Option<usize>,
485488
#[serde(skip_serializing_if = "Option::is_none")]
486489
reasoning_effort: Option<String>,

crates/codegraph-ai/src/openai_llm_provider.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ struct OpenAIRequest {
357357
#[serde(skip_serializing_if = "Option::is_none")]
358358
instructions: Option<String>,
359359
#[serde(
360-
rename = "max_completion_tokens",
360+
rename = "max_output_tokens",
361361
skip_serializing_if = "Option::is_none"
362362
)]
363363
max_completion_tokens: Option<usize>,
@@ -461,7 +461,7 @@ mod tests {
461461
};
462462

463463
let json = serde_json::to_string(&request).unwrap();
464-
assert!(json.contains("\"max_completion_tokens\""));
464+
assert!(json.contains("\"max_output_tokens\""));
465465
assert!(!json.contains("\"max_completion_token\""));
466466
}
467467
}

0 commit comments

Comments
 (0)