Skip to content

fix(oss): remove redundant ellipsis from Field() examples#3099

Merged
Mason Daugherty (mdrxy) merged 5 commits into
langchain-ai:mainfrom
pawel-twardziak:fix/structured-output-field-ellipsis
Mar 13, 2026
Merged

fix(oss): remove redundant ellipsis from Field() examples#3099
Mason Daugherty (mdrxy) merged 5 commits into
langchain-ai:mainfrom
pawel-twardziak:fix/structured-output-field-ellipsis

Conversation

@pawel-twardziak

Copy link
Copy Markdown
Contributor

Remove redundant ... from Field(..., description="...") in models.mdx structured output examples, aligning with Pydantic v2 style already used in structured-output.mdx. Also adds a <Note> in the Pydantic tab explaining required vs optional fields, and an inline sentence in the TypedDict tab explaining the ... sentinel in Annotated syntax.

Type of change

Type: Fix typo/bug/link/formatting

Related issues/PRs

  • GitHub issue:

Fixes #3098

Checklist

  • I have read the contributing guidelines, including the language policy
  • I have tested my changes locally using docs dev
  • All code examples have been tested and work correctly
  • I have used root relative paths for internal links
  • I have updated navigation in src/docs.json if needed

Additional notes

Field(description="...") without ... is equivalent in Pydantic v2 fields with no default remain required. LangChain >= 0.3 requires Pydantic v2, so no backwards-compatibility concern.

@github-actions github-actions Bot added langchain For docs changes to LangChain oss external User is not a member of langchain-ai labels Mar 13, 2026
@github-actions github-actions Bot added the python For content related to the Python version of LangChain projects label Mar 13, 2026
@mdrxy
Mason Daugherty (mdrxy) merged commit ce5b396 into langchain-ai:main Mar 13, 2026
13 checks passed
@sangram11

Sangram Mohanty (sangram11) commented Mar 14, 2026

Copy link
Copy Markdown

Hi pawel-twardziak:
I verified the new change introduced in documents. I see that simply passing description in Field function makes it a mandatory field to be returned by LLM.

Although I tried to set it to optional it still returns me that field.
working_with_agents.ipynb

@mdrxy

Copy link
Copy Markdown
Member

Thanks for verifying Sangram Mohanty (@sangram11)! You're right — in Pydantic v2, Field(description="...") without the ... sentinel is equivalent; fields with no default are required by default. So this change is purely cosmetic/idiomatic.

Re: optional fields still being returned — that's expected LLM behavior. Most models will populate all fields present in the schema regardless of whether they're marked Optional. The Optional typing affects Pydantic validation (allowing None), not the model's generation behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external User is not a member of langchain-ai langchain For docs changes to LangChain oss python For content related to the Python version of LangChain projects

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Description about ellipses in with_structured_output method is missing

3 participants