Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0d4bbd6
fix(core): fix list hash stability for equivalent messages
Weilong-Qin May 9, 2026
774b4cd
Move ListHashUtil hash test to core
Weilong-Qin May 9, 2026
a0f5e43
Merge branch 'agentscope-ai:main' into fix/unstable-computehash
Weilong-Qin May 11, 2026
0392f38
refactor(core): add value-based equals and hashCode methods to the Ms…
Weilong-Qin May 12, 2026
004b226
Merge remote-tracking branch 'origin/fix/unstable-computehash' into f…
Weilong-Qin May 12, 2026
cd4e0fe
test(core): add test
Weilong-Qin May 13, 2026
a94bbb0
test(core): add Msg test
Weilong-Qin May 13, 2026
32c03f1
fix(core): stabilize ToolUseBlock hashCode for Gemini thoughtSignature
Weilong-Qin May 26, 2026
bec4729
Merge branch 'main' into fix/unstable-computehash
Weilong-Qin Jun 4, 2026
765e942
Merge branch 'main' into fix/unstable-computehash
Weilong-Qin Jun 4, 2026
628b3a0
fix: variable name updated
Weilong-Qin Jun 4, 2026
d1ebe31
Merge branch 'main' into fix/unstable-computehash
Weilong-Qin Jun 5, 2026
b766ddf
Merge branch 'main' into fix/unstable-computehash
Weilong-Qin Jun 10, 2026
731c3a0
Merge branch 'main' into fix/unstable-computehash
Weilong-Qin Jun 12, 2026
166c697
Merge branch 'main' into fix/unstable-computehash
Weilong-Qin Jun 16, 2026
95c6798
Merge branch 'main' into fix/unstable-computehash
Weilong-Qin Jun 25, 2026
0ea3d44
fix(test): move OpenAIReasoningDetail hash test to extensions module
Weilong-Qin Jun 25, 2026
93cd966
style: apply spotless formatting
Weilong-Qin Jun 25, 2026
a4d90f0
fix(test): add missing ChatUsage import in OpenAIChatModelTest
Weilong-Qin Jun 25, 2026
a26d1e3
Merge branch 'main' into fix/unstable-computehash
Weilong-Qin Jun 26, 2026
913f598
Merge branch 'main' into fix/unstable-computehash
Weilong-Qin Jun 26, 2026
a050a84
Merge remote-tracking branch 'origin/main' into fix/unstable-computehash
Weilong-Qin Jun 26, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects;

/**
* OpenAI Reasoning Detail DTO (OpenRouter specific for Gemini).
Expand Down Expand Up @@ -90,4 +91,26 @@ public Integer getIndex() {
public void setIndex(Integer index) {
this.index = index;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof OpenAIReasoningDetail)) {
return false;
}
OpenAIReasoningDetail that = (OpenAIReasoningDetail) o;
return Objects.equals(this.id, that.id)
&& Objects.equals(this.type, that.type)
&& Objects.equals(this.data, that.data)
&& Objects.equals(this.text, that.text)
&& Objects.equals(this.format, that.format)
&& Objects.equals(this.index, that.index);
}

@Override
public int hashCode() {
return Objects.hash(this.id, this.type, this.data, this.text, this.format, this.index);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ public Source getSource() {
return source;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof AudioBlock)) {
return false;
}
AudioBlock that = (AudioBlock) o;
return Objects.equals(this.source, that.source);
}

@Override
public int hashCode() {
return Objects.hash(this.source);
}

/**
* Creates a new builder for constructing AudioBlock instances.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ public String getData() {
return data;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Base64Source)) {
return false;
}
Base64Source that = (Base64Source) o;
return Objects.equals(this.mediaType, that.mediaType)
&& Objects.equals(this.data, that.data);
}

@Override
public int hashCode() {
return Objects.hash(this.mediaType, this.data);
}

/**
* Creates a new builder for constructing Base64Source instances.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,25 @@ public Integer getMaxPixels() {
return maxPixels;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ImageBlock)) {
return false;
}
ImageBlock that = (ImageBlock) o;
return Objects.equals(this.source, that.source)
&& Objects.equals(this.minPixels, that.minPixels)
&& Objects.equals(this.maxPixels, that.maxPixels);
}

@Override
public int hashCode() {
return Objects.hash(this.source, this.minPixels, this.maxPixels);
}

/**
* Creates a new builder for constructing ImageBlock instances.
*
Expand Down
23 changes: 23 additions & 0 deletions agentscope-core/src/main/java/io/agentscope/core/message/Msg.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,29 @@ private Msg(
this.timestamp = timestamp;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (!(o instanceof Msg)) {
return false;
} else {
Msg that = (Msg) o;
return Objects.equals(this.id, that.id)
&& Objects.equals(this.name, that.name)
&& this.role == that.role
&& Objects.equals(this.content, that.content)
&& Objects.equals(this.metadata, that.metadata)
&& Objects.equals(this.timestamp, that.timestamp);
}
}

@Override
public int hashCode() {
return Objects.hash(
this.id, this.name, this.role, this.content, this.metadata, this.timestamp);
}

/**
* Creates a new message builder with a randomly generated ID.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects;

/**
* Represents plain text content in a message.
Expand Down Expand Up @@ -56,6 +57,23 @@ public String toString() {
return text;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (!(o instanceof TextBlock)) {
return false;
} else {
TextBlock that = (TextBlock) o;
return Objects.equals(this.text, that.text);
}
}

@Override
public int hashCode() {
return Objects.hash(this.text);
}

/**
* Creates a new builder for constructing TextBlock instances.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
* Represents reasoning or thinking content in a message.
Expand Down Expand Up @@ -81,6 +82,24 @@ public Map<String, Object> getMetadata() {
return metadata;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ThinkingBlock)) {
return false;
}
ThinkingBlock that = (ThinkingBlock) o;
return Objects.equals(this.thinking, that.thinking)
&& Objects.equals(this.metadata, that.metadata);
}

@Override
public int hashCode() {
return Objects.hash(this.thinking, this.metadata);
}

/**
* Creates a new builder for constructing ThinkingBlock instances.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.beans.Transient;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
* Represents the result of a tool execution.
Expand Down Expand Up @@ -289,6 +290,26 @@ public ToolResultBlock withIdAndName(String id, String name) {
return new ToolResultBlock(id, name, this.output, this.metadata);
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ToolResultBlock)) {
return false;
}
ToolResultBlock that = (ToolResultBlock) o;
return Objects.equals(this.id, that.id)
&& Objects.equals(this.name, that.name)
&& Objects.equals(this.output, that.output)
&& Objects.equals(this.metadata, that.metadata);
}

@Override
public int hashCode() {
return Objects.hash(this.id, this.name, this.output, this.metadata);
}

/**
* Creates a new builder for constructing ToolResultBlock instances.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
* Represents a tool use request within a message.
Expand Down Expand Up @@ -144,6 +145,27 @@ public Map<String, Object> getMetadata() {
return metadata;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ToolUseBlock)) {
return false;
}
ToolUseBlock that = (ToolUseBlock) o;
return Objects.equals(this.id, that.id)
&& Objects.equals(this.name, that.name)
&& Objects.equals(this.input, that.input)
&& Objects.equals(this.content, that.content)
&& Objects.equals(this.metadata, that.metadata);
}

@Override
public int hashCode() {
return Objects.hash(this.id, this.name, this.input, this.content, this.metadata);
}

/**
* Creates a new builder for constructing a ToolUseBlock.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ public String getUrl() {
return url;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof URLSource)) {
return false;
}
URLSource that = (URLSource) o;
return Objects.equals(this.url, that.url);
}

@Override
public int hashCode() {
return Objects.hash(this.url);
}

/**
* Creates a new builder for constructing URLSource instances.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects;

/**
* Represents video content in a message.
Expand Down Expand Up @@ -135,6 +136,34 @@ public Integer getTotalPixels() {
return totalPixels;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof VideoBlock)) {
return false;
}
VideoBlock that = (VideoBlock) o;
return Objects.equals(this.source, that.source)
&& Objects.equals(this.fps, that.fps)
&& Objects.equals(this.maxFrames, that.maxFrames)
&& Objects.equals(this.minPixels, that.minPixels)
&& Objects.equals(this.maxPixels, that.maxPixels)
&& Objects.equals(this.totalPixels, that.totalPixels);
}

@Override
public int hashCode() {
return Objects.hash(
this.source,
this.fps,
this.maxFrames,
this.minPixels,
this.maxPixels,
this.totalPixels);
}

/**
* Creates a new builder for constructing VideoBlock instances.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package io.agentscope.core.model;

import java.util.Objects;

/**
* Represents token usage information for chat completion responses.
*
Expand Down Expand Up @@ -76,6 +78,25 @@ public double getTime() {
return time;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ChatUsage)) {
return false;
}
ChatUsage that = (ChatUsage) o;
return this.inputTokens == that.inputTokens
&& this.outputTokens == that.outputTokens
&& Double.compare(this.time, that.time) == 0;
}

@Override
public int hashCode() {
return Objects.hash(this.inputTokens, this.outputTokens, this.time);
}

/**
* Creates a new builder for ChatUsage.
*
Expand Down
Loading
Loading