Skip to content

Document JSON schema derivation for return types in AIFunctionFactory#7400

Merged
stephentoub merged 3 commits intomainfrom
copilot/review-xml-comments-aifunctionfactory
Mar 17, 2026
Merged

Document JSON schema derivation for return types in AIFunctionFactory#7400
stephentoub merged 3 commits intomainfrom
copilot/review-xml-comments-aifunctionfactory

Conversation

Copy link
Contributor

Copilot AI commented Mar 17, 2026

The XML doc comments for AIFunctionFactory and friends thoroughly document JSON schema derivation for function parameters but say nothing about schema derivation for function return types (ReturnJsonSchema). The ExcludeResultSchema summary also reads backward relative to its property name.

Changes

  • AIFunctionFactory class-level doc: Added <remarks> covering that schemas are derived for both parameters and return types, and the knobs that control this (SerializerOptions, JsonSchemaCreateOptions, MarshalResult, ExcludeResultSchema).

  • All 5 Create* overloads: Added a <para> to each method's remarks explaining return type schema derivation — void/Task/ValueTasknull, Task<T>/ValueTask<T> → unwrapped, and referencing ExcludeResultSchema/JsonSchemaCreateOptions on the overloads that accept AIFunctionFactoryOptions.

  • AIFunctionDeclaration.JsonSchema: Added a <para> noting that AIFunctionFactory auto-derives this from method parameters.

  • AIFunctionDeclaration.ReturnJsonSchema: Expanded from a two-line remark to cover derivation mechanics, async unwrapping, and all conditions producing null.

  • AIFunctionFactoryOptions.ExcludeResultSchema: Fixed misleading summary. Was: "whether a schema should be created" (opposite of property name). Now: "whether to exclude generation of a JSON schema for the function's return type."

  • AIFunctionFactoryOptions.JsonSchemaCreateOptions: Clarified it governs schemas for both input parameters and return type.

Microsoft Reviewers: Open in CodeFlow

Copilot AI and others added 2 commits March 17, 2026 12:12
…FunctionFactoryOptions

- Expand AIFunctionFactory class-level doc to mention JSON schema derivation for both parameters and return types
- Add return type JSON schema paragraphs to all five Create* method remarks
- Expand AIFunctionDeclaration.JsonSchema doc to mention auto-generation by AIFunctionFactory
- Expand AIFunctionDeclaration.ReturnJsonSchema doc with schema derivation details
- Fix misleading AIFunctionFactoryOptions.ExcludeResultSchema summary
- Clarify AIFunctionFactoryOptions.JsonSchemaCreateOptions applies to both parameter and return type schemas

Co-authored-by: stephentoub <[email protected]>
@stephentoub stephentoub marked this pull request as ready for review March 17, 2026 12:17
@stephentoub stephentoub requested a review from a team as a code owner March 17, 2026 12:17
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Mar 17, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the XML documentation for AIFunctionFactory-created functions by documenting how JSON schemas are derived not only for parameters but also for return types (ReturnJsonSchema), and by clarifying related option semantics.

Changes:

  • Documented return-type JSON schema derivation behavior across AIFunctionFactory overloads and AIFunctionDeclaration.ReturnJsonSchema.
  • Clarified that JsonSchemaCreateOptions applies to both input-parameter and return-type schemas.
  • Corrected/clarified ExcludeResultSchema documentation to match its intent (exclude generating a return schema).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionFactoryOptions.cs Clarifies JsonSchemaCreateOptions scope and updates ExcludeResultSchema docs.
src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionFactory.cs Adds remarks documenting return schema derivation/unwrapping behavior across factory overloads.
src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionDeclaration.cs Expands JsonSchema/ReturnJsonSchema remarks to explain factory auto-derivation.

You can also share your feedback on Copilot code review. Take the survey.

@stephentoub
Copy link
Member

@copilot address the feedback

Copy link
Contributor Author

Copilot AI commented Mar 17, 2026

@copilot address the feedback

Fixed in 7e9ec23. The ExcludeResultSchema remarks now explicitly list void, Task, and ValueTask as the return types that produce no schema, rather than using the inaccurate "non-void return type" phrasing.

Copilot AI requested a review from stephentoub March 17, 2026 13:00
@stephentoub stephentoub enabled auto-merge (squash) March 17, 2026 13:14
@stephentoub stephentoub merged commit 6bfd8ca into main Mar 17, 2026
6 checks passed
@stephentoub stephentoub deleted the copilot/review-xml-comments-aifunctionfactory branch March 17, 2026 23:51
jeffhandley pushed a commit to jeffhandley/extensions that referenced this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants