Skip to content

feat: Implement array and collection items schema generation in ToolSchemaGenerator and add a corresponding test.#205

Merged
AlbumenJ merged 9 commits intoagentscope-ai:mainfrom
Aias00:fix/fix_197
Dec 16, 2025
Merged

feat: Implement array and collection items schema generation in ToolSchemaGenerator and add a corresponding test.#205
AlbumenJ merged 9 commits intoagentscope-ai:mainfrom
Aias00:fix/fix_197

Conversation

@Aias00
Copy link
Contributor

@Aias00 Aias00 commented Dec 15, 2025

AgentScope-Java Version

[The version of AgentScope-Java you are working on, e.g. 1.0.2, check your pom.xml dependency version or run mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)]

Description

[Please describe the background, purpose, changes made, and how to test this PR]
fixes: #197

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

…lSchemaGenerator and add a corresponding test.
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 implements automatic generation of the items property for array and collection type parameters in JSON schemas, fixing issue #197. Previously, array parameters lacked the required items schema property, which is essential for OpenAI's function calling API to understand the element types.

  • Added logic to detect array and Collection types and automatically generate the items schema with the appropriate element type
  • Implemented support for both Java arrays (e.g., String[]) and parameterized Collections (e.g., List<String>)
  • Added test coverage to verify that array parameters correctly include the items property with the expected element type

Reviewed changes

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

File Description
agentscope-core/src/main/java/io/agentscope/core/tool/ToolSchemaGenerator.java Implements array/collection items schema generation by detecting array types and extracting component types through reflection, with a fallback to "string" type when component type cannot be determined
agentscope-core/src/test/java/io/agentscope/core/tool/ToolSchemaGeneratorTest.java Adds test to verify that array parameters generate schemas with the correct items property containing the element type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

❌ Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../java/io/agentscope/core/util/JsonSchemaUtils.java 50.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

…ct` types for collection parameters and remove ToolSchemaGeneratorTest.
@AlbumenJ AlbumenJ merged commit 319b26d into agentscope-ai:main Dec 16, 2025
4 checks passed
JGoP-L pushed a commit to JGoP-L/agentscope-java that referenced this pull request Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Array Schema Missing Items in ToolSchemaGenerator When Using GPT Models

2 participants