Skip to content

fix: upgrade jsonschema-generator to 5.0.0 for Spring AI 2.0.0-M4 compatibility#1355

Open
xseruer wants to merge 12 commits into
agentscope-ai:mainfrom
xseruer:fix/jsonschema-generator-v5-compatibility
Open

fix: upgrade jsonschema-generator to 5.0.0 for Spring AI 2.0.0-M4 compatibility#1355
xseruer wants to merge 12 commits into
agentscope-ai:mainfrom
xseruer:fix/jsonschema-generator-v5-compatibility

Conversation

@xseruer

@xseruer xseruer commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Resolves the dependency conflict between AgentScope and Spring AI 2.0.0-M4 caused by incompatible versions of com.github.victools:jsonschema-generator.

Root Cause: Spring AI 2.0.0-M4 depends on jsonschema-generator:5.0.0 (which uses Jackson 3.x / tools.jackson.core), while AgentScope uses jsonschema-generator:4.38.0 (Jackson 2.x / com.fasterxml.jackson). When both coexist, Maven resolves to v5.0.0, causing NoSuchMethodError because the SchemaGenerator.generateSchema() return type changed from com.fasterxml.jackson.databind.node.ObjectNode to tools.jackson.databind.node.ObjectNode.

Fix approach:

  • Upgrade jsonschema-generator from 4.38.0 → 5.0.0
  • Add tools.jackson.core:jackson-databind:3.0.4 as a dependency
  • Bridge between Jackson 3.x (schema generator output) and Jackson 2.x (AgentScope internals) via JSON string serialization — generateSchema().toString()fromJson()
  • Update test imports to use tools.jackson.databind.JsonNode

Changes

File Change
agentscope-dependencies-bom/pom.xml Version bump 4.38.0 → 5.0.0, add Jackson 3.x dependency, remove stale exclusion
agentscope-core/pom.xml Add tools.jackson.core:jackson-databind
agentscope-distribution/agentscope-all/pom.xml Add tools.jackson.core:jackson-databind
JsonSchemaUtils.java Use .toString() + fromJson() instead of Jackson 2.x convertValue() for schema generation
ToolSchemaModuleTest.java Update import from com.fasterxml.jackson.databind.JsonNodetools.jackson.databind.JsonNode

Test Plan

  • JsonSchemaUtilsTest — all 7 tests pass
  • ToolSchemaModuleTest — all 8 tests pass
  • Full agentscope-core module compilation succeeds

Closes #1271

…patibility

Resolves the dependency conflict between AgentScope and Spring AI 2.0.0-M4
caused by incompatible versions of com.github.victools:jsonschema-generator.

Spring AI 2.0.0-M4 requires jsonschema-generator 5.0.0 which uses Jackson 3.x
(tools.jackson.core). When both libraries coexist on the classpath, Maven
resolves to v5.0.0, causing NoSuchMethodError in AgentScope's schema generation
code that was compiled against v4.38.0 (Jackson 2.x).

Changes:
- Upgrade jsonschema-generator from 4.38.0 to 5.0.0
- Add tools.jackson.core:jackson-databind dependency (Jackson 3.x)
- Adapt JsonSchemaUtils to bridge between Jackson 3.x (used by schema
  generator) and Jackson 2.x (used by the rest of AgentScope) via JSON
  string serialization
- Update ToolSchemaModuleTest to use tools.jackson.databind.JsonNode

Closes agentscope-ai#1271
@xseruer xseruer requested a review from a team May 8, 2026 04:04
@codecov

codecov Bot commented May 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@AgentScopeJavaBot AgentScopeJavaBot added bug Something isn't working area/build Build, CI, BOM, distribution area/core/tool Tool, skill, RAG abstractions labels May 28, 2026

@AgentScopeJavaBot AgentScopeJavaBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

This PR cleanly resolves the Jackson 3 / jsonschema-generator 5.0.0 transition required for Spring AI 2.0.0-M4 coexistence. The bridge approach in JsonSchemaUtils (serialize Jackson 3 JsonNode.toString() then re-parse via Jackson 2 codec) is a pragmatic choice that keeps Jackson 2 dominant in the codebase while only exposing Jackson 3 inside the schema generator boundary. The BOM cleanup (removing the now-irrelevant jackson-core exclusion) is correct, and the dependency additions are explicit/defensive. One concern: the PR also bumps com.networknt:json-schema-validator from 2.0.0 → 3.0.0 (itself a Jackson 3 migration, per its 3.0.0 release notes) but this is not mentioned in the title or description; reviewers/users will want this called out since ToolValidator exercises that library at runtime and the new test plan only covers schema generation. Otherwise the change is well-scoped, the test import update is correct, and there are no behavioral red flags.

<nacos-client.version>3.2.1-2026.03.30</nacos-client.version>
<json-schema-validator.version>2.0.0</json-schema-validator.version>
<jsonschema-generator.version>4.38.0</jsonschema-generator.version>
<json-schema-validator.version>3.0.0</json-schema-validator.version>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] This PR also bumps com.networknt:json-schema-validator 2.0.0 → 3.0.0, which is a separate library from victools jsonschema-generator and itself a major release that internally moves to Jackson 3 (per its 3.0.0 release notes). The PR title and description only mention jsonschema-generator, so this bundled upgrade is easy to miss. ToolValidator (the only consumer) is not modified and its class names (SchemaRegistry, Schema, Error, InputFormat) appear unchanged, but please either (a) document the validator upgrade in the PR description with a brief note that the existing schema-validation tests still pass, or (b) split it into a separate commit/PR — this aids future bisecting if a validator-side regression surfaces.

import java.util.List;
import java.util.stream.StreamSupport;
import org.junit.jupiter.api.Test;
import tools.jackson.databind.JsonNode;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] While migrating this test to the Jackson 3 JsonNode, the existing .asText() calls in requiredList(...) and the assertEquals(... .asText()) assertions remain. In Jackson 3.x asText() is @Deprecated (delegates to asString()). Compilation still works, but consider switching to asString() in this file as part of the same migration to silence deprecation warnings and align with the Jackson 3 idiom. Not blocking.

public static Map<String, Object> generateSchemaFromClass(Class<?> clazz) {
try {
JsonNode schemaNode = schemaGenerator.generateSchema(clazz);
String schemaJson = schemaGenerator.generateSchema(clazz).toString();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Minor observation (not blocking): schemaGenerator.generateSchema(clazz).toString() + fromJson(...) round-trips the entire schema through a JSON string. For one-shot schema generation per Class/Type (called from ToolSchemaGenerator and StructuredOutputCapableAgent) this overhead is negligible, and the chosen approach is the cleanest way to keep Jackson 2 dominant elsewhere — so this is fine as-is. The alternative would be a dedicated Jackson 3 ObjectMapper doing convertValue(node, Map.class) directly, but that would couple JsonSchemaUtils to Jackson 3 internals, which is arguably worse. Recommended to keep the current bridge but add a brief inline comment explaining the rationale so future maintainers don't try to 'optimize' it back.

@LearningGp LearningGp requested a review from chickenlj June 4, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Build, CI, BOM, distribution area/core/tool Tool, skill, RAG abstractions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Dependency conflict with org.springframework.ai 2.0.0-M4 due to com.github.victools version mismatch

2 participants