LLM: fix strict schema 400 — correct providerOptions + chat model

Previous attempt set `strictJsonSchema:false` on createOpenAI()
(factory ignores unknown keys), so wire was still strict:true and
sparse edits {brightness:0.3} were rejected: Missing 'arrangement'.

- src/llm/llmTweak.js: use provider.chat(modelId) (/chat/completions,
  correct for Meta via gateway, not /responses) and pass
  `providerOptions:{ openai:{ strictJsonSchema:false } }` on
  generateObject where the SDK actually reads it.
- src/llm/spec.js: edits fields nullable instead of optional — strict
  requires every key in `required` when `additionalProperties:false`;
  nullable makes required = all 7 (model emits null for unchanged),
  clampEdits already strips nulls so NO_EDITS still works. Prompt now
  instructs "use null for unchanged, example { bpm:null,... }".
- test/llm.test.js: minimal valid result now all-null with one edit.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Dejvino
2026-09-13 20:48:14 +02:00
co-authored by Claude
parent e8c04e7798
commit 82ab88e6b0
3 changed files with 17 additions and 11 deletions
+6 -1
View File
@@ -52,8 +52,13 @@ test('buildTweakPrompt truncates long hint in system', () => {
});
test('TweakResultSchema validates a minimal valid result', () => {
const parsed = TweakResultSchema.parse({ rationale: 'Lower noise to calm the drop.', edits: { noise: 0.3 }, confidence: 0.8 });
const parsed = TweakResultSchema.parse({
rationale: 'Lower noise to calm the drop.',
edits: { bpm: null, brightness: null, noise: 0.3, noiseColour: null, dynamics: null, transition: null, arrangement: null },
confidence: 0.8,
});
assert.equal(parsed.edits.noise, 0.3);
assert.equal(parsed.edits.bpm, null);
assert.ok(parsed.rationale.length > 0);
});