Skip to content

fix(extensions): resolve AutoContextMemory API role compliance#998

Closed
jujn wants to merge 4 commits into
agentscope-ai:mainfrom
jujn:fix_997
Closed

fix(extensions): resolve AutoContextMemory API role compliance#998
jujn wants to merge 4 commits into
agentscope-ai:mainfrom
jujn:fix_997

Conversation

@jujn

@jujn jujn commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Description

Close #997

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

@jujn jujn requested review from a team and Copilot March 20, 2026 04:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes AutoContextMemory’s “current round” compression output to comply with chat API role requirements by ensuring the generated compressed summary message is treated as a USER message (not an ASSISTANT message).

Changes:

  • Update current-round compressed summary message construction to use MsgRole.USER and name="user".
  • Add a regression test asserting the compressed current-round summary message role/name are USER/user.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
agentscope-extensions/agentscope-extensions-autocontext-memory/src/main/java/io/agentscope/core/memory/autocontext/AutoContextMemory.java Changes the current-round compressed summary message role/name to USER/user for API compliance.
agentscope-extensions/agentscope-extensions-autocontext-memory/src/test/java/io/agentscope/core/memory/autocontext/AutoContextMemoryTest.java Adds a test that verifies the compressed current-round summary message is emitted with USER role and name="user".

@codecov

codecov Bot commented Mar 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@LearningGp

Copy link
Copy Markdown
Member

@shiyiyue1102 PTAL

@LearningGp

Copy link
Copy Markdown
Member
image

@jujn

jujn commented Mar 26, 2026

Copy link
Copy Markdown
Contributor Author
image

resolved

@LearningGp

Copy link
Copy Markdown
Member

@shiyiyue1102 PTAL

@LearningGp LearningGp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think simply defaulting to the user role is the best approach here. This information shouldn't all be categorized as user input. We should probably construct valid message pairs based on the actual context after compression.

@shiyiyue1102 PTAL

@jujn

jujn commented Apr 12, 2026

Copy link
Copy Markdown
Contributor Author

I don't think simply defaulting to the user role is the best approach here. This information shouldn't all be categorized as user input. We should probably construct valid message pairs based on the actual context after compression.

@shiyiyue1102 PTAL

Thanks for your review! I'm sorry I didn't seriously consider it before. You are completely correct. I noticed that PR #1027 seems to have implemented your suggestion. If you think PR1027 can solve the current problem, please close this PR directly. Thanks.

@LearningGp LearningGp closed this May 15, 2026
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.

[Bug]:策略6 压缩完最后一条输出消息是assistant,不符合发送规范导致错误,应该是role=user

3 participants