Skip to content

[Bug]: Agent compress memory: summary_template can not handle summary without 'next_steps' #1388

@ceshihao

Description

@ceshihao

AgentScope is an open-source project. To involve a broader community, we recommend asking your questions in English.

Describe the bug

  File "/home/admin/.local/lib/python3.11/site-packages/agentscope/pipeline/_functional.py", line 192, in stream_printing_messages
    raise exception from None
  File "/home/admin/.local/lib/python3.11/site-packages/agentscope/agent/_agent_base.py", line 455, in __call__
    reply_msg = await self.reply(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/admin/.local/lib/python3.11/site-packages/agentscope/agent/_agent_meta.py", line 120, in async_wrapper
    current_output = await original_func(
                     ^^^^^^^^^^^^^^^^^^^^
  File "/home/admin/.local/lib/python3.11/site-packages/agentscope/tracing/_trace.py", line 431, in wrapper
    raise e from None
  File "/home/admin/.local/lib/python3.11/site-packages/agentscope/tracing/_trace.py", line 422, in wrapper
    res = await func(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/admin/.local/lib/python3.11/site-packages/agentscope/agent/_react_agent.py", line 434, in reply
    await self._compress_memory_if_needed()
  File "/home/admin/.local/lib/python3.11/site-packages/agentscope/agent/_react_agent.py", line 1111, in _compress_memory_if_needed
    self.compression_config.summary_template.format(
KeyError: 'next_steps'

To Reproduce
Steps to reproduce the behavior:

The issue only happens sometimes when compressed model does not contain 'next_steps'.

agentscope==1.0.16

my code simple react agent

        agent = ReActAgent(
            name="xxx",
            model=DashScopeChatModel(
                model_name="qwen3.5-plus",
                enable_thinking=False,
                multimodality=True,
                stream=True
            ),
            sys_prompt=sys_prompt,
            toolkit=toolkit,
            memory=RedisMemory(),
            formatter=DashScopeChatFormatter(),
            plan_notebook=plan_notebook,
            max_iters=20,
            compression_config=ReActAgent.CompressionConfig(
                enable=True,
                agent_token_counter=CharTokenCounter(),
                trigger_threshold=50000,
                keep_recent=3,
            ),
        )

Expected behavior
A clear and concise description of what you expected to happen.

Error messages
Detailed error messages.

Environment (please complete the following information):

  • AgentScope Version: 1.0.16
  • Python Version: 3.11
  • OS: Linux

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions