LLM: allow sparse optional edits — disable strict JSON schema

The Responses API via Vercel AI Gateway requires `required` to
include every key when `strict:true`. Our TweakEditsSchema has 7
optional song knobs, so sparse edits (e.g. only {brightness: 0.3})
were rejected with 400: Missing 'arrangement'.

- src/llm/llmTweak.js: createOpenAI({ strictJsonSchema: false }) so
  the gateway accepts optional properties; keeps zod validation +
  clampEdits as the real guardrail.
- src/llm/spec.js: drop .strict() on TweakEditsSchema — extra keys
  are stripped rather than erroring, more robust against model drift.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Dejvino
2026-09-13 20:30:54 +02:00
co-authored by Claude
parent a0eaf2ef95
commit e8c04e7798
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -97,6 +97,7 @@ export async function requestSongTweak({ spec, track, look, hint = '', config =
baseURL: isDev ? '/__llm/v1' : cfg.gatewayUrl,
apiKey: cfg.apiKey,
fetch: isDev ? proxyFetch : undefined,
strictJsonSchema: false,
});
const modelId = cfg.model;
+1 -1
View File
@@ -19,7 +19,7 @@ export const TweakEditsSchema = z.object({
dynamics: z.number().min(0).max(1).optional(),
transition: z.number().min(0).max(1).optional(),
arrangement: z.enum(ARRANGEMENT_VALUES).optional(),
}).strict();
});
export const TweakResultSchema = z.object({
rationale: z.string().min(1).max(800),