Skip to content

feat(AutoContextMemory): optimize current round msg compress#182

Merged
AlbumenJ merged 1 commit intoagentscope-ai:mainfrom
shiyiyue1102:main222-optimize-autocontext
Dec 11, 2025
Merged

feat(AutoContextMemory): optimize current round msg compress#182
AlbumenJ merged 1 commit intoagentscope-ai:mainfrom
shiyiyue1102:main222-optimize-autocontext

Conversation

@shiyiyue1102
Copy link
Contributor

This pull request introduces several enhancements and improvements to the auto-context memory system and file tool capabilities. The most significant changes include adding a new directory listing tool, expanding message classification utilities for tool-related messages, refining prompt templates for message compression, and improving session management and persistence in the advanced example. Additionally, minor test code updates ensure consistency with refactored method names.

File Tool Enhancements

  • Added a new list_directory tool to ReadFileTool that lists all files and directories in a specified path, with robust error handling and formatted output. [1] [2]

Auto-Context Memory Utilities

  • Introduced utility methods in MsgUtils to classify messages as tool-related, tool use, tool result, and final assistant responses, improving message handling and compression logic.

Prompt and Compression Improvements

  • Refined prompt templates in Prompts to support more granular and context-aware message compression for both current round tool messages and large messages, including new format strings and hints for offloaded content. [1] [2]

Session Management and Persistence

  • Enhanced the advanced example (AutoMemoryExample.java) to use a persistent session manager with JSON-based session storage, ensuring session state is saved and restored across runs. Also updated auto-context configuration for improved token management. [1] [2] [3] [4] [5]

Test Code Consistency

  • Updated test methods to use the new getOriginalMemoryMsgs() method name for accessing original message storage, reflecting recent refactoring. [1] [2] [3] [4] [5]此提交为 AutoContextMemory 添加了新的消息分类方法,并优化了压缩提示文本的格式。新添加的方法用于判断消息是否与工具调用相关,以及是否是最终响应给用户的助手消息。同时更新了压缩提示文本的格式,使其更加详细和易于理解。

Change-Id: I035493bc5ee0322c1584f32dd54ecf3bc9a25ab1
Co-developed-by: Aone Copilot noreply@alibaba-inc.com

AgentScope-Java Version

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

Description

[Please describe the background, purpose, changes made, and how to test this PR]

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

此提交为 `AutoContextMemory` 添加了新的消息分类方法,并优化了压缩提示文本的格式。新添加的方法用于判断消息是否与工具调用相关,以及是否是最终响应给用户的助手消息。同时更新了压缩提示文本的格式,使其更加详细和易于理解。

Change-Id: I035493bc5ee0322c1584f32dd54ecf3bc9a25ab1
Co-developed-by: Aone Copilot <noreply@alibaba-inc.com>
@shiyiyue1102 shiyiyue1102 requested a review from a team December 11, 2025 09:06
@codecov
Copy link

codecov bot commented Dec 11, 2025

@AlbumenJ AlbumenJ merged commit 62d0be0 into agentscope-ai:main Dec 11, 2025
4 checks passed
JGoP-L pushed a commit to JGoP-L/agentscope-java that referenced this pull request Dec 29, 2025
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