Skip to content

Conversation

JM-Lab
Copy link
Contributor

@JM-Lab JM-Lab commented May 18, 2025

Unlike UserMessage and SystemMessage, AssistantMessage and ToolResponseMessage did not support the builder pattern. This PR applies the builder pattern to these classes for consistent and flexible object creation.
Additionally, the properties field in AssistantMessage has been renamed to metadata for consistency with other message types.

  • Refactor affected usages after AssistantMessage and ToolResponseMessage update
  • Added builder pattern to AssistantMessage and ToolResponseMessage.
  • Renamed the properties field to metadata in AssistantMessage for improved semantic clarity and consistency.

@JM-Lab JM-Lab changed the title Add missing meAdded builder pattern to AssistantMessage and ToolResponseMessage for clarity and flexibilityssage builder Added builder pattern to AssistantMessage and ToolResponseMessage for clarity and flexibility. May 19, 2025
@JM-Lab JM-Lab changed the title Added builder pattern to AssistantMessage and ToolResponseMessage for clarity and flexibility. Added builder pattern to AssistantMessage and ToolResponseMessage May 20, 2025
@JM-Lab JM-Lab changed the title Added builder pattern to AssistantMessage and ToolResponseMessage Add builder pattern to AssistantMessage and ToolResponseMessage May 20, 2025
@ericbottard
Copy link
Member

Hi, thanks for taking the time to contribute to spring-ai!

Please see #4457

AssistantMessage already supports builders on main.
Could you please re-work this PR to address ToolResponseMessage only (or feel free to close and open a new PR).

The agreed upon approach we use / aim for for the Builder pattern is:

  • builder is final with private properties
  • if there is a class hierarchy, the BBuilder doesn't extend from ABuilder

@ericbottard ericbottard self-assigned this Oct 3, 2025
ericbottard added a commit to ericbottard/spring-ai that referenced this pull request Oct 8, 2025
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.

3 participants