feat: add fallback for models without tool calling support#3608
Merged
ComputelessComputer merged 1 commit intomainfrom Feb 4, 2026
Merged
Conversation
When generating template sections during summarization, the AI SDK's Output.object uses tool calling under the hood. Models like Gemma via LM Studio don't support tool calling, causing errors. This change adds a fallback mechanism: 1. First attempts structured output via tool calling (for models that support it) 2. On failure, falls back to plain text generation with JSON extraction 3. Validates the parsed JSON against the schema using Zod This allows models without tool calling support to still work with the summarization feature. Co-Authored-By: john@hyprnote.com <john@hyprnote.com>
✅ Deploy Preview for hyprnote canceled.
|
✅ Deploy Preview for hyprnote-storybook canceled.
|
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an issue where users get an error saying "tool calling not supported" when using models like Gemma via LM Studio for summarization.
The root cause: when no template is selected,
generateTemplateIfNeededuses the Vercel AI SDK'sOutput.object({ schema })to generate template sections. This internally uses tool calling, which models like Gemma don't support.Solution: Added a
generateStructuredOutputhelper that:Review & Testing Checklist for Human
/\{[\s\S]*\}/for JSON extraction - could it incorrectly match nested objects or fail on edge cases?null(same as original behavior) when both approaches failRecommended test plan:
Notes
errorvariable on line 206 is intentionally unused - it's caught to trigger the fallbacknullon failure, maintaining the original graceful degradation behaviorLink to Devin run: https://app.devin.ai/sessions/9cc7c5ed1c564bb5b24bb602f3391179
Requested by: @ComputelessComputer