la-machina-engine 0.20.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -259,28 +259,59 @@ const result = await engine.run({
259
259
  }
260
260
  ```
261
261
 
262
- ### Done — JSON Mode, Parse Failed
262
+ ### Failed — JSON Mode, Parse / Schema Error
263
263
 
264
- When the model doesn't return valid JSON despite instructions:
264
+ When `outputFormat: 'json'` is requested but the final model output is
265
+ empty, not valid JSON, or fails the supplied `outputSchema`, the run
266
+ terminates as `status: 'failed'` with a typed code (engine ≥ 0.21.0). The
267
+ old permissive fallback (`status: 'done'` with `data` falling back to raw
268
+ text) is removed — a strict-JSON request that can't satisfy the contract
269
+ fails at the engine boundary so callers never mistake an empty/invalid
270
+ output for a successful structured result.
271
+
272
+ Raw parse failure:
265
273
 
266
274
  ```json
267
275
  {
268
276
  "runId": "run_abc",
269
- "status": "done",
270
- "data": "Here's the pricing: Starter at $29, Pro at $99, Enterprise at $299.",
277
+ "status": "failed",
278
+ "data": null,
271
279
  "meta": {
272
280
  "nodeId": "extract",
273
- "turns": 2,
274
- "tokensUsed": { "input": 5000, "output": 800 },
281
+ "turns": 0,
282
+ "tokensUsed": { "input": 0, "output": 0 },
275
283
  "durationMs": 6000,
276
- "output": "Here's the pricing: Starter at $29, Pro at $99, Enterprise at $299."
284
+ "transcript": { "path": "projects/run_abc/nodes/extract", "lastShardIndex": 0 }
277
285
  },
278
- "errors": [],
286
+ "errors": [
287
+ {
288
+ "code": "ERR_JSON_OUTPUT_PARSE",
289
+ "message": "Output is not valid JSON: …"
290
+ }
291
+ ],
279
292
  "timestamp": 1712966400000
280
293
  }
281
294
  ```
282
295
 
283
- `data` falls back to raw text. Client checks `typeof response.data === 'object'` to verify structured output.
296
+ Schema mismatch (parse succeeded, validation failed):
297
+
298
+ ```json
299
+ {
300
+ "runId": "run_abc",
301
+ "status": "failed",
302
+ "data": null,
303
+ "errors": [
304
+ {
305
+ "code": "ERR_JSON_OUTPUT_SCHEMA",
306
+ "message": "Output failed schema validation: …"
307
+ }
308
+ ]
309
+ }
310
+ ```
311
+
312
+ In both cases the engine still appends a `json_parse_failure` inspect
313
+ event (unchanged from Plan 026) — the failure is now visible BOTH in
314
+ inspect AND on the public run result.
284
315
 
285
316
  ### Paused — Human Approval Needed
286
317
 
@@ -456,8 +487,10 @@ await engine.resume({
456
487
  | `ERR_STREAM_PARSE` | Malformed API response | No — provider issue |
457
488
  | `ERR_STREAM_INCOMPLETE` | Stream ended without message_stop | Yes — transient |
458
489
  | `ERR_UNEXPECTED_STOP` | Unknown stop reason from API | No — investigate |
459
- | `SCHEMA_VALIDATION_FAILED` | JSON output doesn't match outputSchema | No — adjust schema or task |
460
- | `JSON_PARSE_FAILED` | Model didn't return valid JSON | No — adjust task |
490
+ | `ERR_JSON_OUTPUT_PARSE` | `outputFormat: 'json'` returned empty / non-JSON output (engine 0.21.0) | No — adjust task / prompt |
491
+ | `ERR_JSON_OUTPUT_SCHEMA` | JSON output failed `outputSchema` validation (engine ≥ 0.21.0) | No — adjust schema or task |
492
+ | `SCHEMA_VALIDATION_FAILED` | (Legacy inspect-only code; pre-0.21.0) JSON output doesn't match outputSchema | No — adjust schema or task |
493
+ | `JSON_PARSE_FAILED` | (Legacy inspect-only code; pre-0.21.0) Model didn't return valid JSON | No — adjust task |
461
494
 
462
495
  ### Workflow Runner Integration
463
496