Repository navigation
fix(ollama): finish tool calls before native structured output - #3516
Open
guslegend0510 wants to merge 1 commit into
Open
guslegend0510 wants to merge 1 commit into
guslegend0510 wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This branch has not been deployed
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.
AgentScope-Java Version
2.1.0-SNAPSHOT
Description
Follow-up to #3455; refs #3452.
Live verification with Ollama 0.40.3 and qwen3:0.6b showed that combining tools and format could suppress a valid weather tool call. A parseable JSON response alone did not prove that the business tool had run.
Enable native structured output with application tools through two phases inside the Ollama provider. Tool reasoning requests omit format, including a configured default format. Tool calls return to the ordinary ReAct loop. When a round returns an answer without tool calls, keep it as an internal draft and make a separate request with the schema and without tools or tool_choice. Only the final structured response reaches the caller; its usage includes the hidden draft.
Tool-phase streaming is buffered until the provider can decide whether to execute tools or format the answer. The terminal logical model round therefore makes two physical HTTP requests. Formatting retries do not replay tools. Native failures with application tools persist completed tool state and propagate the error, preventing synthetic fallback from repeating business side effects. Calls without application tools retain their existing fallback.
Preserve both builder switches and expose them through ModelCreationContext. nativeStructuredOutputWithTools(false) selects the synthetic path when tools are present; nativeStructuredOutput(false) disables native routing entirely. Update the English and Chinese Ollama guides.
Validation
Checklist