48-Hour Field Notes: The Free Model Returned Valid JSON, and My Schema Said Nothing
说明与用途
在48小时的现场测试中,免费LLM返回空数组,导致模式认为是有效的。添加minItems:1和预检探针捕获配置错误并提高可靠性。
问题
A nightly extraction job using a free model tier returned empty arrays because the schema did not enforce a minimum item count, leading to silent failures and wasted retries.
结果
Adding minItems:1 prevented silent empty results, the pre‑flight probe caught configuration and environment issues early, and the refined retry taxonomy reduced wasted compute and avoided silent failures.
工作流
- 1. Define JSON schema with required fields and minItems:1 for records.
- 2. Run a pre‑flight probe: send ten identical requests, ambiguous blob, oversized blob, wrong model name, idle window test, and kill worker test.
- 3. If probe passes, launch nightly job.
- 4. On validation failure, perform one repair attempt then fail; do not retry content failures.
- 5. On transport or rate_limited failures, retry with bounded backoff.
- 6. On config failures (401/403/404), stop the run immediately.
- 7. Log all events and preserve journal outside the worker’s disk.
证据
The model, faced with a blob it could not parse confidently, made a reasonable choice and returned nothing rather than inventing line items.
The one-keyword fix is "minItems": 1, and it is the single highest-value line in the whole article.
A mistyped model name produced a 4xx on every request. My retry wrapper treated everything that was not a 200 as transient, so the job cheerfully backed off and retried for hours.
- 记录日期: 2026-10-18T21:56:17.189Z