Skip to content

Add service method annotations#48544

Open
kaylieee wants to merge 1 commit intomainfrom
kaylieee/feature/add-annotations
Open

Add service method annotations#48544
kaylieee wants to merge 1 commit intomainfrom
kaylieee/feature/add-annotations

Conversation

@kaylieee
Copy link
Member

This pull request improves the Azure AI Agents SDK by enhancing the documentation and API clarity for both synchronous and asynchronous response creation methods. The main change is the addition of @ServiceMethod annotations specifying the return type, which helps with code generation, documentation, and user understanding.

API annotation improvements:

  • Added @ServiceMethod(returns = ReturnType.SINGLE) to createAzureResponse and createStreamingAzureResponse methods in both ResponsesClient and ResponsesAsyncClient, clarifying their return types and improving SDK usability. [1] [2] [3] [4]

Dependency and import updates:

  • Imported ServiceMethod and ReturnType annotations in both ResponsesClient.java and ResponsesAsyncClient.java to support the new method annotations. [1] [2]

Copilot AI review requested due to automatic review settings March 24, 2026 00:30
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 Azure AI Agents SDK API documentation/codegen clarity by adding @ServiceMethod annotations that declare each method’s return type.

Changes:

  • Added @ServiceMethod(returns = ReturnType.SINGLE) to sync and async response creation methods.
  • Added ServiceMethod / ReturnType imports to support the new annotations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesClient.java Adds @ServiceMethod return-type annotations to sync response methods.
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesAsyncClient.java Adds @ServiceMethod return-type annotations to async response methods.

* @param params The parameters to create the response.
* @return An IterableStream of ResponseStreamEvent.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

createStreamingAzureResponse returns multiple events via IterableStream<ResponseStreamEvent>, but it’s annotated as ReturnType.SINGLE. This can mislead documentation and tooling that relies on @ServiceMethod. Please change this to the appropriate multi-item return type (typically ReturnType.COLLECTION for IterableStream).

Suggested change
@ServiceMethod(returns = ReturnType.SINGLE)
@ServiceMethod(returns = ReturnType.COLLECTION)

Copilot uses AI. Check for mistakes.
* @param params The parameters to create the response.
* @return A {@link Flux} stream of {@link ResponseStreamEvent} items.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

createStreamingAzureResponse returns a stream of events via Flux<ResponseStreamEvent>, but it’s annotated as ReturnType.SINGLE. This is inconsistent with the method behavior and may cause incorrect docs/codegen metadata. Please use the appropriate multi-item return type (commonly ReturnType.COLLECTION for reactive streams emitting multiple items).

Suggested change
@ServiceMethod(returns = ReturnType.SINGLE)
@ServiceMethod(returns = ReturnType.COLLECTION)

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

API Change Check

APIView identified API level changes in this PR and created the following API reviews

com.azure:azure-ai-agents

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants