[GH-ISSUE #15576] gemma4:26b / 31b issues with structured output #35704

Open
opened 2026-04-22 20:23:18 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @jbcallaghan on GitHub (Apr 14, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/15576

What is the issue?

Issue:

gemma4:26b / 31b has issues with structured output where in the following example it says there is no context.

Summary:

A RAG solution has a tool calling node that calls tools to retrieve documents (context) that is then used by a final answer node to provide a structured output citing the used documents.

The tool calls are executed correctly, the tool response includes context_id: xxx content: This document blah

However the final node with structured output always returns a response where the model can't find any context. This is not the case when using other models such as nemo, gpt-oss, qwen, deepseek etc

Simplified Example:

class CitedAnswer(BaseModel):
"""
Structured answer to a user question.
"""
content: str = Field(
description=(
"The final answer to the user's question based ONLY on the supplied context. "
)
)
context_id: List[str] = Field(
description=(
" Cite ONLY the context_id values from the provided sources that were explicitly used in forming the answer"
)
)

final_model.format= CitedAnswer.model_json_schema()

Relevant log output


OS

No response

GPU

No response

CPU

No response

Ollama version

No response

Originally created by @jbcallaghan on GitHub (Apr 14, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/15576 ### What is the issue? Issue: gemma4:26b / 31b has issues with structured output where in the following example it says there is no context. Summary: A RAG solution has a tool calling node that calls tools to retrieve documents (context) that is then used by a final answer node to provide a structured output citing the used documents. The tool calls are executed correctly, the tool response includes context_id: xxx content: This document blah However the final node with structured output always returns a response where the model can't find any context. This is not the case when using other models such as nemo, gpt-oss, qwen, deepseek etc Simplified Example: class CitedAnswer(BaseModel): """ Structured answer to a user question. """ content: str = Field( description=( "The final answer to the user's question based ONLY on the supplied context. " ) ) context_id: List[str] = Field( description=( " Cite ONLY the `context_id` values from the provided sources that were *explicitly* used in forming the answer" ) ) final_model.format= CitedAnswer.model_json_schema() ### Relevant log output ```shell ``` ### OS _No response_ ### GPU _No response_ ### CPU _No response_ ### Ollama version _No response_
GiteaMirror added the bug label 2026-04-22 20:23:18 -05:00
Author
Owner

@PureBlissAK commented on GitHub (Apr 18, 2026):

🤖 Automated Triage & Analysis Report

Issue: #15576
Analyzed: 2026-04-18T18:19:29.868473

Analysis

  • Type: unknown
  • Severity: medium
  • Components: unknown

Implementation Plan

  • Effort: medium
  • Steps:

This issue has been triaged and marked for implementation.

<!-- gh-comment-id:4274304977 --> @PureBlissAK commented on GitHub (Apr 18, 2026): <!-- ollama-issue-orchestrator:v1 issue:15576 --> ## 🤖 Automated Triage & Analysis Report **Issue**: #15576 **Analyzed**: 2026-04-18T18:19:29.868473 ### Analysis - **Type**: unknown - **Severity**: medium - **Components**: unknown ### Implementation Plan - **Effort**: medium - **Steps**: *This issue has been triaged and marked for implementation.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#35704