From 7735c946587e31821cf183e2dee10cc25402a365 Mon Sep 17 00:00:00 2001 From: jujn <2087687391@qq.com> Date: Sun, 9 Aug 2026 21:00:35 +0800 Subject: [PATCH] fix(agui): configure Spring Boot 4 example to decode AG-UI requests with Jackson 2 --- agentscope-examples/agui/pom.xml | 4 +++ .../agui/config/Jackson2Configuration.java | 34 +++++++++++++++++++ .../agui/src/main/resources/application.yml | 4 +++ 3 files changed, 42 insertions(+) create mode 100644 agentscope-examples/agui/src/main/java/io/agentscope/examples/agui/config/Jackson2Configuration.java diff --git a/agentscope-examples/agui/pom.xml b/agentscope-examples/agui/pom.xml index 356433737e..a03bd8cae7 100644 --- a/agentscope-examples/agui/pom.xml +++ b/agentscope-examples/agui/pom.xml @@ -64,6 +64,10 @@ io.agentscope agentscope-agui-spring-boot-starter + + com.fasterxml.jackson.core + jackson-databind + org.springframework.boot spring-boot-starter-webflux diff --git a/agentscope-examples/agui/src/main/java/io/agentscope/examples/agui/config/Jackson2Configuration.java b/agentscope-examples/agui/src/main/java/io/agentscope/examples/agui/config/Jackson2Configuration.java new file mode 100644 index 0000000000..f415347466 --- /dev/null +++ b/agentscope-examples/agui/src/main/java/io/agentscope/examples/agui/config/Jackson2Configuration.java @@ -0,0 +1,34 @@ +/* + * Copyright 2024-2026 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.agentscope.examples.agui.config; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class Jackson2Configuration { + + @Bean + @ConditionalOnMissingBean(ObjectMapper.class) + public ObjectMapper jackson2ObjectMapper() { + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + return mapper; + } +} diff --git a/agentscope-examples/agui/src/main/resources/application.yml b/agentscope-examples/agui/src/main/resources/application.yml index 2d55e3ac89..44aecd9c62 100644 --- a/agentscope-examples/agui/src/main/resources/application.yml +++ b/agentscope-examples/agui/src/main/resources/application.yml @@ -20,6 +20,10 @@ server: spring: main: banner-mode: off + http: + codecs: + # AG-UI models use Jackson 2 annotations and custom serializers. + preferred-json-mapper: jackson2 web: resources: cache: