feat: Implement array and collection items schema generation in ToolSchemaGenerator and add a corresponding test.#205
Merged
AlbumenJ merged 9 commits intoagentscope-ai:mainfrom Dec 16, 2025
Conversation
…lSchemaGenerator and add a corresponding test.
Contributor
There was a problem hiding this comment.
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
itemsschema 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
itemsproperty 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.
agentscope-core/src/test/java/io/agentscope/core/tool/ToolSchemaGeneratorTest.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/tool/ToolSchemaGenerator.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/test/java/io/agentscope/core/tool/ToolSchemaGeneratorTest.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/test/java/io/agentscope/core/tool/ToolSchemaGeneratorTest.java
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ct` types for collection parameters and remove ToolSchemaGeneratorTest.
AlbumenJ
requested changes
Dec 15, 2025
agentscope-core/src/main/java/io/agentscope/core/tool/ToolSchemaGenerator.java
Outdated
Show resolved
Hide resolved
AlbumenJ
requested changes
Dec 16, 2025
agentscope-core/src/main/java/io/agentscope/core/util/JsonSchemaUtils.java
Outdated
Show resolved
Hide resolved
…h generic list and map types.
…ding imports for `TypeReference` and `Type`.
AlbumenJ
approved these changes
Dec 16, 2025
JGoP-L
pushed a commit
to JGoP-L/agentscope-java
that referenced
this pull request
Dec 29, 2025
…lSchemaGenerator and add a corresponding test. (agentscope-ai#205)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
mvn spotless:applymvn test)