docs: Update method name for structured output in Ollama docs#807
docs: Update method name for structured output in Ollama docs#807apikodes wants to merge 4 commits intostrands-agents:mainfrom
Conversation
|
Assessment: Request Changes The intent of this PR is correct — the Per the project's own structured output documentation, # Deprecated
result = agent.structured_output(MyModel, "prompt")
print(result.field)
# Recommended
result = agent("prompt", structured_output_model=MyModel)
print(result.structured_output.field)The code example and the explanatory text both need to be updated to reflect this parameter-based invocation pattern. See inline comments for specific suggestions. Thank you for identifying the deprecation issue — just needs the correct replacement pattern! |
Documentation Preview ReadyYour documentation preview has been successfully deployed! Preview URL: https://d3ehv1nix5p99z.cloudfront.net/pr-cms-807/docs/user-guide/quickstart/overview/ Updated at: 2026-05-07T14:58:31.189Z |
|
Assessment: Request Changes The code example is now correct and follows the recommended Small change, almost there! 👍 |
gautamsirdeshmukh
left a comment
There was a problem hiding this comment.
Hi there, happy to shepherd this along if you are able to take care of the remaining callout!
|
Assessment: Approve All previous feedback has been addressed. The code example now correctly uses the Thanks for iterating on this — the Ollama docs will now guide users to the correct, non-deprecated approach. |
| Analyze this book: "The Hitchhiker's Guide to the Galaxy" by Douglas Adams. | ||
| It's a science fiction comedy about Arthur Dent's adventures through space | ||
| after Earth is destroyed. It's widely considered a classic of humorous sci-fi. | ||
| after Earth is destroyed. It's widely considered a classic of humorous sci-fi with good ratings. |
There was a problem hiding this comment.
A few other callouts:
- I like the thought but let's remove the numbered list comments, I think the example is clear enough to where this is just adding noise
- No need to separate the prompt into it's own variable. Let's stay consistent with the existing example like so:
agent = Agent(model=ollama_model)
result = agent(
"""Analyze this book: "The Hitchhiker's Guide to the Galaxy" by Douglas Adams.
It's a science fiction comedy about Arthur Dent's adventures through space
after Earth is destroyed. It's widely considered a classic of humorous sci-fi.""",
structured_output_model=BookAnalysis,
)
- Instead of
result_infoI think something likebookorbook_analysiswould fit better (matches with the structured output model name), this also aligns with how Ollama's own structured output examples are written
There was a problem hiding this comment.
I believe this is everything :) thanks again for picking this up!
There was a problem hiding this comment.
Thanks for the feedback, this is updated now.
Updated the code to streamline the book analysis process using the Ollama model. Simplified the prompt handling and improved output access.

Description
When executing the example provided in the below documentation page:
https://strandsagents.com/docs/user-guide/concepts/model-providers/ollama/#structured-output
A deprecation warning is displayed as below:
Related Issues
Type of Change
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.