Repository navigation
feat: support @Schema on FunctionTool object properties - #1694
Open
YuqiGuo105 wants to merge 1 commit into
Open
YuqiGuo105 wants to merge 1 commit into
YuqiGuo105 wants to merge 1 commit into
Conversation
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.
Link to Issue or Description of Change
Closes #611.
Problem:
POJO properties used by
FunctionToolrely on Jackson annotations for their model-facing names and required flags. Applications cannot independently describe tool properties with ADK's@Schemaannotation without changing their ordinary business JSON representation. Renaming only the generated schema would also leave tool argument deserialization using the old names.Solution:
Annotations.Schemaon fields and record components, in addition to methods and parameters.ObjectMapperwith a schema-aware annotation introspector. Non-empty@Schema.nametakes precedence over Jackson's name;@Schema.optionaloverrides the schema's required marker. Without an ADK annotation, existing Jackson behavior remains in effect.For example, a property annotated with
@JsonProperty("business_id")and@Schema(name = "customer_id", description = "Customer identifier")remainsbusiness_idin ordinary business JSON, while the tool schema and tool argument binding usecustomer_id.Testing Plan
Unit Tests:
@JsonIgnore, unannotated POJOs, custom naming strategies, mapper isolation, and return-value/schema consistency../mvnw -o -B -pl core -Dtest=FunctionToolSchemaTest testpasses../mvnw -B -Prelease -pl core -am clean packagepasses on OpenJDK 25.0.3 (Java release target 17), including source/Javadoc jars. Both full-core executions (default-testandbasic) run 2,904 tests with 0 failures, 0 errors, and 30 skipped; the additional environment-specific executions also pass.git diff --check upstream/main...HEADpasses.Manual End-to-End (E2E) Tests:
Not run against a live model. Regression tests exercise local
FunctionTooldeclaration generation and invocation; no model credentials or external services are required.Checklist
CONTRIBUTING.md.Additional context
The
optionalflag controls the generated tool schema'srequiredlist; this change does not introduce a separate business-validation framework. This is the Java/Jackson implementation of the requested ADK annotation semantics, rather than a new model-provider protocol.