Skip to content

docs: Update method name for structured output in Ollama docs#807

Open
apikodes wants to merge 4 commits intostrands-agents:mainfrom
apikodes:patch-1
Open

docs: Update method name for structured output in Ollama docs#807
apikodes wants to merge 4 commits intostrands-agents:mainfrom
apikodes:patch-1

Conversation

@apikodes
Copy link
Copy Markdown

@apikodes apikodes commented May 2, 2026

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:

DeprecationWarning: Agent.structured_output method is deprecated. You should pass in `structured_output_model` directly into the agent invocation. see: https://strandsagents.com/latest/documentation/docs/user-guide/concepts/agents/structured-output/

Related Issues

Type of Change

  • Content update/revision
  • Typo/formatting fix

Checklist

  • I have read the CONTRIBUTING document
  • My changes follow the project's documentation style
  • Links in the documentation are valid and working

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@apikodes apikodes temporarily deployed to manual-approval May 2, 2026 22:46 — with GitHub Actions Inactive
@apikodes apikodes temporarily deployed to manual-approval May 2, 2026 22:46 — with GitHub Actions Inactive
@apikodes apikodes changed the title Update method name for structured output in Ollama docs docs: Update method name for structured output in Ollama docs May 2, 2026
Comment thread src/content/docs/user-guide/concepts/model-providers/ollama.mdx Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

Assessment: Request Changes

The intent of this PR is correct — the Agent.structured_output() method is deprecated and the docs should be updated. However, the fix replaces it with Agent.structured_output_model() which is also not a valid method on the Agent class.

Per the project's own structured output documentation, structured_output_model is a parameter passed to the agent invocation, not a method. The correct migration pattern is:

# 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!

Comment thread src/content/docs/user-guide/concepts/model-providers/ollama.mdx Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

Documentation Preview Ready

Your 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

Comment thread src/content/docs/user-guide/concepts/model-providers/ollama.mdx Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Assessment: Request Changes

The code example is now correct and follows the recommended structured_output_model parameter pattern — nice update! One remaining issue: the descriptive text on line 200 still references the deprecated Agent.structured_output() method with its old API link, which contradicts the corrected code below it. Updating that sentence to describe only the new approach will make the docs consistent.

Small change, almost there! 👍

Copy link
Copy Markdown
Contributor

@gautamsirdeshmukh gautamsirdeshmukh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there, happy to shepherd this along if you are able to take care of the remaining callout!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Assessment: Approve

All previous feedback has been addressed. The code example now correctly uses the structured_output_model parameter pattern, the descriptive text references the agent invocation with appropriate API link, and the overall pattern is consistent with the project's structured output documentation.

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the churn – could you please remove this little addition? It causes the code example to get cut off --->

Image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_info I think something like book or book_analysis would fit better (matches with the structured output model name), this also aligns with how Ollama's own structured output examples are written

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is everything :) thanks again for picking this up!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants