refactor: address code review feedback

- Make getProviderLabel() switch exhaustive with explicit openai/gemini
  arms instead of falling through to env-var checks in default
- Add clarifying comment on additionalProperties override in schema
  normalization
This commit is contained in:
salmanrajz
2026-04-02 12:36:05 +04:00
parent e494015e9a
commit 14de9cf0fb
2 changed files with 6 additions and 6 deletions

View File

@@ -19,13 +19,11 @@ function getProviderLabel(): string {
return 'Google Vertex'
case 'foundry':
return 'Azure Foundry'
default:
if (process.env.CLAUDE_CODE_USE_OPENAI === '1' || process.env.CLAUDE_CODE_USE_OPENAI === 'true') {
case 'openai':
return 'OpenAI-compatible API'
}
if (process.env.CLAUDE_CODE_USE_GEMINI === '1' || process.env.CLAUDE_CODE_USE_GEMINI === 'true') {
case 'gemini':
return 'Gemini API'
}
default:
return 'API'
}
}

View File

@@ -259,6 +259,8 @@ function normalizeSchemaForOpenAI(
// OpenAI strict mode requires every property to be listed in required[]
const allKeys = Object.keys(normalizedProps)
record.required = Array.from(new Set([...existingRequired, ...allKeys]))
// OpenAI strict mode requires additionalProperties: false on all object
// schemas — override unconditionally to ensure nested objects comply.
record.additionalProperties = false
} else {
// For Gemini: keep only existing required keys that are present in properties