fix(web): await parseAsync in generateStructured instead of sync parse (#1204)

US
1h ago
+1-1

Problem

generateStructured called the synchronous adapter.parse(), which throws when mustUseLlamaBackendWorker() is true (worker-owned llama model). The adapter already offers parseAsync that handles the worker path. With a worker-owned llama model, generation succeeded but parsing threw.

Solution

Changed adapter.parse({...}) to await adapter.parseAsync({...}). Since generateStructured is already async, this is a one-line change. parseAsync handles the worker path and falls back to sync parse() otherwise.

Testing

  • TypeScript typecheck passes (no new errors)

Checklist

  • Reproduced the issue
  • No credentials or secrets in commit

Closes #1204.


Summary by cubic

Fixes generateStructured throwing during structured-output parsing when a worker-owned llama model is active.

generateStructured called the synchronous adapter.parse(), which throws when mustUseLlamaBackendWorker() is true. It now awaits adapter.parseAsync(), which handles the worker path and falls back to sync parse() otherwise. TypeScript typecheck passes.

Closes #1204.

Summary by CodeRabbit

  • Improvements
    • Structured output generation now waits for parsing to complete before returning results, so parsed output is ready when the operation finishes.
    • No changes were made to the public API or the way users interact with structured output generation.