Skip to content

Preserve tool schema property order in Converse API - #6705

Open
yyyCode wants to merge 1 commit into
spring-projects:mainfrom
yyyCode:fix/converse-schema-order-6696
Open

Preserve tool schema property order in Converse API#6705
yyyCode wants to merge 1 commit into
spring-projects:mainfrom
yyyCode:fix/converse-schema-order-6696

Conversation

@yyyCode

@yyyCode yyyCode commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

ConverseApiUtils#convertMapToDocument collected map entries with a plain Collectors.toMap(...), which returns a HashMap and therefore discards the insertion order of the source map (preserved by Jackson as a LinkedHashMap).

As a result, the properties of a tool's inputSchema were sent to Bedrock in an arbitrary, hashCode-driven order instead of the declared order.

This change collects into a LinkedHashMap so the declaration order is preserved, and adds a test covering both top-level and nested maps.

Fixes #6696

ConverseApiUtils#convertMapToDocument collected map entries with a
plain Collectors.toMap, which returns a HashMap and discards the
insertion order of the source map. As a result, the properties of a
tool's inputSchema were sent to Bedrock in an arbitrary order instead
of the declared order.

Collect into a LinkedHashMap to preserve the declaration order.

Fixes spring-projects#6696

Signed-off-by: yqz <2678785492@qq.com>
@yyyCode

yyyCode commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@rozza Could I get a quick approve to kick off the CI tests? Thanks!

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.

ToolConfiguration input schema loses JSON property declaration order (ConverseApiUtils#convertMapToDocument uses HashMap)

2 participants