fix(examples): prevent duplicate message output by specifying streamOptions#487
Merged
AlbumenJ merged 1 commit intoagentscope-ai:mainfrom Jan 9, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ffe06d9 to
8012fd0
Compare
AlbumenJ
approved these changes
Jan 9, 2026
yaohuitc
pushed a commit
to yaohuitc/agentscope-java
that referenced
this pull request
Jan 10, 2026
…ptions (agentscope-ai#487) ## AgentScope-Java Version 1.0.7-SNAPSHOT ## Description Previously, `ExampleUtils` invoked the Agent `stream` method without specifying `StreamOptions` and`EventType`, which caused all event types to be emitted by default. This resulted in duplicate message outputs in certain examples, such as `ToolCallingExample`. For example: ```text === Chat Started === Type 'exit' to quit You> 今天是几号 Agent> Text: 我将使用search函数来获取今天的日期,但是请注意,这个功能可能不会直接返回当前的日期。通常我们通过其他方式如系统时间等来获取当天的日期。这里我会尝试搜索 "今天的日期" 以演示如何使用search工具。搜索 "今天的日期" 得到的结果并没有直接提供今天的具体日期,这是因为搜索工具返回的是模拟的搜索结果列表,并不包含实际的日期信息。为了获取当前确切的日期,通常我们会查看设备上的日历或时钟,或者使用能够访问系统时间的功能。 如果您需要知道具体的日期,您可以查看所在设备右下角(或设置区域)显示的日期,或者告诉我您所在的时区,我可以尝试通过其他方式帮助您获取正确的日期。您想要继续吗?如果需要,也请告知您的时区。搜索 "今天的日期" 得到的结果并没有直接提供今天的具体日期,这是因为搜索工具返回的是模拟的搜索结果列表,并不包含实际的日期信息。为了获取当前确切的日期,通常我们会查看设备上的日历或时钟,或者使用能够访问系统时间的功能。 如果您需要知道具体的日期,您可以查看所在设备右下角(或设置区域)显示的日期,或者告诉我您所在的时区,我可以尝试通过其他方式帮助您获取正确的日期。您想要继续吗?如果需要,也请告知您的时区。搜索 "今天的日期" 得到的结果并没有直接提供今天的具体日期,这是因为搜索工具返回的是模拟的搜索结果列表,并不包含实际的日期信息。为了获取当前确切的日期,通常我们会查看设备上的日历或时钟,或者使用能够访问系统时间的功能。 如果您需要知道具体的日期,您可以查看所在设备右下角(或设置区域)显示的日期,或者告诉我您所在的时区,我可以尝试通过其他方式帮助您获取正确的日期。您想要继续吗?如果需要,也请告知您的时区。 ``` This PR adds explicit `StreamOptions` configuration to the `stream` call in `ExampleUtils` and restricts the emitted `EventType`s, preventing duplicate message output. ## Checklist Please check the following items before code is ready to be reviewed. - [x] Code has been formatted with `mvn spotless:apply` - [x] All tests are passing (`mvn test`) - [x] Javadoc comments are complete and follow project conventions - [x] Related documentation has been updated (e.g. links, examples, etc.) - [x] Code is ready for review
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.7-SNAPSHOT
Description
Previously,
ExampleUtilsinvoked the Agentstreammethod without specifyingStreamOptionsandEventType, which caused all event types to be emitted by default.This resulted in duplicate message outputs in certain examples, such as
ToolCallingExample.For example:
This PR adds explicit
StreamOptionsconfiguration to thestreamcall inExampleUtilsand restricts the emittedEventTypes, preventing duplicate message output.Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)