fix: trim persisted tool results and sanitize MCP schemas

This commit is contained in:
sooth
2026-04-02 07:49:58 -04:00
parent 9f48bb4431
commit 5c4469fe81
10 changed files with 449 additions and 26 deletions

View File

@@ -39,6 +39,7 @@ import {
resolveProviderRequest,
} from './providerConfig.js'
import { redactSecretValueForDisplay } from '../../utils/providerProfile.js'
import { sanitizeSchemaForOpenAICompat } from './openaiSchemaSanitizer.js'
const GITHUB_MODELS_DEFAULT_BASE = 'https://models.github.ai/inference'
const GITHUB_API_VERSION = '2022-11-28'
@@ -270,11 +271,7 @@ function normalizeSchemaForOpenAI(
schema: Record<string, unknown>,
strict = true,
): Record<string, unknown> {
if (!schema || typeof schema !== 'object' || Array.isArray(schema)) {
return (schema ?? {}) as Record<string, unknown>
}
const record = { ...schema }
const record = sanitizeSchemaForOpenAICompat(schema)
if (record.type === 'object' && record.properties) {
const properties = record.properties as Record<string, Record<string, unknown>>