Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions agentscope-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@

<!-- Jackson for JSON serialization/deserialization -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<!-- Victools JSON Schema Generator for structured output -->
Expand All @@ -78,12 +78,6 @@
<artifactId>jsonschema-module-jackson</artifactId>
</dependency>

<!-- Jackson Java 8 Date/Time support -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>

<!-- SLF4J API -->
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package io.agentscope.core.agent;

import com.fasterxml.jackson.databind.JsonNode;
import io.agentscope.core.hook.ErrorEvent;
import io.agentscope.core.hook.Hook;
import io.agentscope.core.hook.PostCallEvent;
Expand All @@ -40,6 +39,7 @@
import reactor.core.publisher.FluxSink;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
import tools.jackson.databind.JsonNode;

/**
* Abstract base class for all agents in the AgentScope framework.
Expand Down Expand Up @@ -235,7 +235,7 @@ public final Mono<Msg> call(List<Msg> msgs, Class<?> structuredOutputClass) {
* <p>Tracing data will be captured once telemetry is enabled.
*
* @param msgs Input messages
* @param schema com.fasterxml.jackson.databind.JsonNode instance defining the structure of the output
* @param schema JsonNode instance defining the structure of the output
* @return Response message with structured data in metadata
*/
@Override
Expand Down Expand Up @@ -295,7 +295,7 @@ protected Mono<Msg> doCall(List<Msg> msgs, Class<?> structuredOutputClass) {
* Default implementation throws UnsupportedOperationException.
*
* @param msgs Input messages
* @param outputSchema com.fasterxml.jackson.databind.JsonNode instance defining the structure
* @param outputSchema JsonNode instance defining the structure
* @return Response message with structured data in metadata
*/
protected Mono<Msg> doCall(List<Msg> msgs, JsonNode outputSchema) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
package io.agentscope.core.agent;

import com.fasterxml.jackson.databind.JsonNode;
import io.agentscope.core.message.Msg;
import java.util.List;
import reactor.core.publisher.Mono;
import tools.jackson.databind.JsonNode;

/**
* Interface for agents that can be called to process messages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package io.agentscope.core.agent;

import com.fasterxml.jackson.databind.JsonNode;
import io.agentscope.core.hook.Hook;
import io.agentscope.core.memory.Memory;
import io.agentscope.core.message.ContentBlock;
Expand All @@ -40,6 +39,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Mono;
import tools.jackson.databind.JsonNode;

/**
* Abstract base class for agents that support structured output generation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import io.agentscope.core.util.JsonUtils;
import java.util.List;
import tools.jackson.core.type.TypeReference;

/**
* DashScope message DTO.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.io.IOException;
import tools.jackson.core.JacksonException;
import tools.jackson.core.JsonParser;
import tools.jackson.core.JsonToken;
import tools.jackson.databind.DeserializationContext;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.ValueDeserializer;
import tools.jackson.databind.annotation.JsonDeserialize;

/**
* DashScope API response DTO.
Expand Down Expand Up @@ -128,11 +128,11 @@ public boolean isError() {
* have been decrypted by decryptResponse() before deserialization. If it's still a string at
* this point, it means decryption failed or wasn't performed, so we skip it.
*/
static class DashScopeOutputDeserializer extends JsonDeserializer<DashScopeOutput> {
static class DashScopeOutputDeserializer extends ValueDeserializer<DashScopeOutput> {

@Override
public DashScopeOutput deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException {
throws JacksonException {
JsonToken token = p.currentToken();
if (token == JsonToken.VALUE_NULL) {
return null;
Expand All @@ -147,14 +147,15 @@ public DashScopeOutput deserialize(JsonParser p, DeserializationContext ctxt)
// Object value - normal deserialization
// Use readTree and treeToValue for standard deserialization
// This handles the case where output is a decrypted JSON object
JsonNode node = p.getCodec().readTree(p);
JsonNode node = ctxt.readTree(p);
if (node == null || node.isNull() || !node.isObject()) {
return null;
}
return p.getCodec().treeToValue(node, DashScopeOutput.class);
return ctxt.readTreeAsValue(node, DashScopeOutput.class);
}

// Unexpected token type
throw new IOException(
throw new IllegalStateException(
"Cannot deserialize DashScopeOutput from token: "
+ token
+ ". Expected object or string.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import io.agentscope.core.model.ChatUsage;
import io.agentscope.core.state.State;
import io.agentscope.core.util.JsonUtils;
Expand All @@ -34,6 +33,7 @@
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;
import tools.jackson.core.type.TypeReference;

/**
* Represents a message in the AgentScope framework.
Expand Down Expand Up @@ -245,7 +245,7 @@ public boolean hasStructuredData() {
*
* <p>This method is useful when the message contains structured input from a user agent
* or structured output from an LLM. The metadata map is converted to a Java object
* using Jackson's ObjectMapper.
* using Jackson's JsonMapper.
*
* <p>Example usage:
* <pre>{@code
Expand Down Expand Up @@ -330,7 +330,7 @@ public <T> T getStructuredData(Class<T> targetClass) {
* }
* }
* """;
* JsonNode sampleJsonNode = new ObjectMapper().readTree(json);
* JsonNode sampleJsonNode = JsonMapper.shared().readTree(json);
* Msg msg = agent.call(input, sampleJsonNode).block(TEST_TIMEOUT);
* Map<String, Object> structuredData = msg.getStructuredData(false);
* }</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package io.agentscope.core.model;

import com.fasterxml.jackson.core.type.TypeReference;
import io.agentscope.core.Version;
import io.agentscope.core.formatter.dashscope.dto.DashScopeParameters;
import io.agentscope.core.formatter.dashscope.dto.DashScopePublicKeyResponse;
Expand All @@ -36,6 +35,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Flux;
import tools.jackson.core.type.TypeReference;

/**
* HTTP client for DashScope API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@

package io.agentscope.core.model.ollama;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.io.IOException;
import java.util.List;
import tools.jackson.core.JacksonException;
import tools.jackson.core.JsonGenerator;
import tools.jackson.core.JsonToken;
import tools.jackson.databind.DeserializationContext;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.ValueDeserializer;
import tools.jackson.databind.ValueSerializer;
import tools.jackson.databind.annotation.JsonDeserialize;
import tools.jackson.databind.annotation.JsonSerialize;

/**
* Defines the configuration contract for the "thinking" capability (Chain of Thought) in AgentScope's Ollama integration.
Expand Down Expand Up @@ -56,15 +55,15 @@ public sealed interface ThinkOption {
* Custom serializer implementation for {@link ThinkOption}.
* Responsible for converting the option object into the appropriate JSON primitive (boolean or string).
*/
class ThinkOptionSerializer extends JsonSerializer<ThinkOption> {
class ThinkOptionSerializer extends ValueSerializer<ThinkOption> {

@Override
public void serialize(ThinkOption value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
public void serialize(ThinkOption value, JsonGenerator gen, SerializationContext ctxt)
throws JacksonException {
if (value == null) {
gen.writeNull();
} else {
gen.writeObject(value.toJsonValue());
gen.writePOJO(value.toJsonValue());
}
}
}
Expand All @@ -73,11 +72,11 @@ public void serialize(ThinkOption value, JsonGenerator gen, SerializerProvider s
* Custom deserializer implementation for {@link ThinkOption}.
* Detects the JSON token type (boolean or string) and instantiates the corresponding {@link ThinkOption} implementation.
*/
class ThinkOptionDeserializer extends JsonDeserializer<ThinkOption> {
class ThinkOptionDeserializer extends ValueDeserializer<ThinkOption> {

@Override
public ThinkOption deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException {
public ThinkOption deserialize(tools.jackson.core.JsonParser p, DeserializationContext ctxt)
throws JacksonException {
JsonToken token = p.currentToken();
if (token == JsonToken.VALUE_TRUE) {
return ThinkBoolean.ENABLED;
Expand All @@ -88,7 +87,7 @@ public ThinkOption deserialize(JsonParser p, DeserializationContext ctxt)
} else if (token == JsonToken.VALUE_NULL) {
return null;
}
throw new IOException(
throw new IllegalStateException(
"Unable to deserialize ThinkOption. Encountered unexpected token type: "
+ token);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public Object getPayloadValue(String key) {
* Gets a specific payload value by key and converts it to the specified type.
*
* <p>This method is useful when the payload contains complex objects (like custom POJOs)
* that were serialized to Map during storage. It uses Jackson's ObjectMapper to convert
* that were serialized to Map during storage. It uses Jackson's JsonMapper to convert
* the Map back to the original type.
*
* @param <T> the target type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import io.modelcontextprotocol.client.transport.HttpClientStreamableHttpTransport;
import io.modelcontextprotocol.client.transport.ServerParameters;
import io.modelcontextprotocol.client.transport.StdioClientTransport;
import io.modelcontextprotocol.json.McpJsonMapper;
import io.modelcontextprotocol.json.jackson3.JacksonMcpJsonMapper;
import io.modelcontextprotocol.spec.McpClientTransport;
import io.modelcontextprotocol.spec.McpSchema;
import java.net.URI;
Expand All @@ -41,6 +41,7 @@
import java.util.function.Consumer;
import java.util.stream.Collectors;
import reactor.core.publisher.Mono;
import tools.jackson.databind.json.JsonMapper;

/**
* Builder for creating MCP client wrappers with fluent configuration.
Expand Down Expand Up @@ -379,7 +380,7 @@ public McpClientTransport createTransport() {
}

ServerParameters params = paramsBuilder.build();
return new StdioClientTransport(params, McpJsonMapper.getDefault());
return new StdioClientTransport(params, new JacksonMcpJsonMapper(JsonMapper.shared()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package io.agentscope.core.tool.multimodal;

import com.fasterxml.jackson.core.type.TypeReference;
import io.agentscope.core.formatter.MediaUtils;
import io.agentscope.core.message.Base64Source;
import io.agentscope.core.message.ContentBlock;
Expand All @@ -36,6 +35,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Mono;
import tools.jackson.core.type.TypeReference;

/**
* OpenAI multimodal tool.
Expand Down
Loading
Loading