feat: support agent.stream for structuredModel#161
Merged
AlbumenJ merged 2 commits intoagentscope-ai:mainfrom Dec 10, 2025
Merged
feat: support agent.stream for structuredModel#161AlbumenJ merged 2 commits intoagentscope-ai:mainfrom
AlbumenJ merged 2 commits intoagentscope-ai:mainfrom
Conversation
AlbumenJ
approved these changes
Dec 9, 2025
Collaborator
|
pls fix ci |
AlbumenJ
approved these changes
Dec 10, 2025
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
qingTang0305
pushed a commit
to qingTang0305/agentscope-java
that referenced
this pull request
Dec 10, 2025
JGoP-L
pushed a commit
to JGoP-L/agentscope-java
that referenced
this pull request
Dec 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
1.0.2-SNAPSHOT
Description
Background
This PR extends the AgentScope-Java framework to support structured output generation in streaming mode. Previously, the
stream()methods only supported basic message streaming without structured output capabilities, limiting the flexibility for applications that need both real-time streaming and structured data extraction.Purpose
Enable agents to generate structured output while streaming execution events, providing developers with the ability to:
Changes Made
1. Core Interface Extensions (
Agent.java)stream(Msg msg, StreamOptions options, Class<?> structuredModel)methodstream(List<Msg> msgs, StreamOptions options, Class<?> structuredModel)methodstream(Class<?> structuredModel)for continuation with structured output2. Base Implementation (
AgentBase.java)stream()methods with structured model support in the abstract base classcall(List<Msg> msgs, Class<?> structuredOutputClass)method with proper hook integrationdoCall(List<Msg> msgs, Class<?> structuredOutputClass)abstract method for subclass implementation3. Example Enhancement (
StructuredOutputExample.java)runStreamProductAnalysisExample()method demonstrating structured streaming usageagent.stream(msg, StreamOptions.defaults(), ProductRequirements.class)event.getMessage().getStructuredData()How to Test This PR
Prerequisites:
Test Steps:
Run the enhanced example:
Verify streaming with structured output:
Integration testing:
API compatibility:
stream()methods continue to workChecklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)Summary: This PR adds structured output support to the streaming API, enabling developers to combine real-time event streaming with type-safe structured data extraction. The implementation maintains full backward compatibility while extending the framework's capabilities for advanced use cases.