feat(memory): route memory compaction output to user channel (#1773)#2141
Open
aquamarine-bot wants to merge 3 commits intoagentscope-ai:mainfrom
Open
feat(memory): route memory compaction output to user channel (#1773)#2141aquamarine-bot wants to merge 3 commits intoagentscope-ai:mainfrom
aquamarine-bot wants to merge 3 commits intoagentscope-ai:mainfrom
Conversation
When memory compaction is triggered, notify the user not only via the streaming pipeline (web UI) but also through their native channel (e.g. Telegram, Discord) so external platform users see the summary. - Add channel_manager to CoPawAgent and pass it from AgentRunner - Wire channel_manager in create_channel_service - Send status via ChannelManager.send_text in _print_status_message Fixes: agentscope-ai/discussions/1773
Contributor
Author
UpdateMerge conflicts with latest cc @cuiyuebing |
Contributor
Author
UpdateRebased onto latest cc @cuiyuebing |
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.
Motivation
When memory compaction is triggered, the summarizer output (e.g., "Compacting memory: 32 messages summarized into ...") is currently sent only via
agent.print(), which routes through the streaming pipeline to the web console. Users on external channels (Telegram, Discord, Feishu, etc.) do not see these status messages — they only appear in the server logs.Changes
src/copaw/app/runner/runner.py_channel_managerattribute toAgentRunnerwithset_channel_manager()setter (mirrors the existingset_chat_manager()pattern)channel_manager=self._channel_managerwhen instantiatingCoPawAgentsrc/copaw/app/workspace/service_factories.pyrunner.set_channel_manager(cm)after creating theChannelManager, so the runner holds a reference to itsrc/copaw/agents/react_agent.pyCoPawAgent.__init__now accepts an optionalchannel_managerparameter and stores it asself._channel_managersrc/copaw/agents/hooks/memory_compaction.py_print_status_message, after the existingawait agent.print(msg)call, check if the agent has a_channel_managerand_request_contextchannel_manager.send_text()to push the status message to the user's native channel (Telegram, Discord, etc.)try/exceptso channel send failures are non-fatal and do not interrupt the reasoning loopBehavior
agent.print)channel_manageris not configured (e.g., console-only deployment)Testing
pytest tests/unit/workspace/test_agent_creation.py— 4 passed)pre-commit runpasses on changed files (black, flake8, pylint, mypy all green)Related: /discussions/1773 — Task #9 (P0, Memory)