Skip to content

Conversation

@chiangzeon
Copy link
Contributor

AgentScope-Java Version

[The version of AgentScope-Java you are working on, e.g. 1.0.3, check your pom.xml dependency version or run mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)]

Description

Support dynamic structured data definition.

Summary

1.io.agentscope.core.agent.Agent#call(io.agentscope.core.message.Msg, java.lang.Class) The reason for passing POJO is because it is called io.agentscope.core.ReActAgent#doCall(java.util.List, java.lang.Class) We need to register a tool to summarize the output.

  1. Need to overload getStructuredData method, as the dynamic type return can only be KV data and metadata already contains the original response. For concurrency security, the input parameter provides a Boolean type for the caller to choose whether it can be modified.

  2. The core call is in io.agentscope. core. tracking. Tracer # callModel. Based on the protocols of different providers, the override io. agentscope. core. model. ChatModelBase # doStream method is required.

If there is any mistake, please point it out promptly. Thank you

https://github.com/agentscope-ai/agentscope-java/issues/208

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@chiangzeon chiangzeon requested a review from a team December 25, 2025 07:42
Comment on lines 91 to 104
this.content =
Objects.nonNull(content) && content.stream().allMatch(Objects::nonNull)
? List.copyOf(content)
: List.of();
this.metadata =
Objects.nonNull(metadata)
&& metadata.entrySet().stream()
.allMatch(
entry ->
Objects.nonNull(entry.getKey())
&& Objects.nonNull(
entry.getValue()))
? Map.copyOf(metadata)
: Map.of();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why change this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please submit a new PR to fix it


if (targetClass != null && responseData != null) {
try {
OBJECT_MAPPER.convertValue(responseData, targetClass);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will fail here

Comment on lines 297 to 299
if (Objects.nonNull(targetClass)) {
OBJECT_MAPPER.convertValue(responseData, targetClass);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we validate the schemaDesc here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is technically feasible. However, I would generally advise against it because a dynamically generated validation mechanism cannot comprehensively cover all business rules. Implementing this feature would incur significant development and maintenance overhead. Therefore, I propose that the responsibility for parameter validation should lie with the calling client. Do you agree with this perspective?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that current Large Language Models (LLMs) still exhibit limitations in generating complex structures, it is essential to implement data format validation within the Agent. This facilitates timely prompting of the model for error correction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given that current Large Language Models (LLMs) still exhibit limitations in generating complex structures, it is essential to implement data format validation within the Agent. This facilitates timely prompting of the model for error correction.

Done

Comment on lines 91 to 104
this.content =
Objects.nonNull(content) && content.stream().allMatch(Objects::nonNull)
? List.copyOf(content)
: List.of();
this.metadata =
Objects.nonNull(metadata)
&& metadata.entrySet().stream()
.allMatch(
entry ->
Objects.nonNull(entry.getKey())
&& Objects.nonNull(
entry.getValue()))
? Map.copyOf(metadata)
: Map.of();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please submit a new PR to fix it

@AlbumenJ AlbumenJ merged commit 0672b14 into agentscope-ai:main Dec 30, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants