Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: bug in DictDialogAgent when use_memory = False #338

Closed
wujiren opened this issue Jul 14, 2024 · 1 comment · Fixed by #342
Closed

[Bug]: bug in DictDialogAgent when use_memory = False #338

wujiren opened this issue Jul 14, 2024 · 1 comment · Fixed by #342
Labels
bug Something isn't working

Comments

@wujiren
Copy link

wujiren commented Jul 14, 2024

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

Describe the bug
In DictDialogAgent , if you set use_memory = False, the source code in reply() method will raise error

        self.memory.add(
            Msg(self.name, self.parser.to_memory(res.parsed), "assistant"),
        )

Reason: self.memory is None

To Reproduce
Steps to reproduce the behavior:

  1. source code
import agentscope
from agentscope.agents import DictDialogAgent
from agentscope.message import Msg
from agentscope.parsers import MarkdownJsonDictParser

if __name__ == "__main__":
    agentscope.init(model_configs="yor configs", logger_level="DEBUG")
    parser = MarkdownJsonDictParser(content_hint={"reply": "your reply"})
    agent = DictDialogAgent(
        name="Agent",
        sys_prompt="you are an agent\n{content_hint}",
        model_config_name="your config name",
        use_memory=False, // this is when the error will be raised
    )
    agent.set_parser(parser)
    x = agent(Msg("user", "I'm testing you"))

Expected behavior
nothing

Error messages

Traceback (most recent call last):
  File "/Volumes/work/workspace/llm/writing/test_error.py", line 18, in <module>
    x = agent(Msg("user", "I'm testing you"))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jirenwu/anaconda3/envs/chatgpt/lib/python3.11/site-packages/agentscope/agents/agent.py", line 296, in __call__
    res = self.reply(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jirenwu/anaconda3/envs/chatgpt/lib/python3.11/site-packages/agentscope/agents/dict_dialog_agent.py", line 111, in reply
    self.memory.add(
    ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'add'

Environment (please complete the following information):

  • AgentScope Version: ['0.0.6alpha3]
  • Python Version: [3.11]
  • OS: [macoss]

Additional context
maybe you should:

    if self.memory: 
        self.memory.add(
            Msg(self.name, self.parser.to_memory(res.parsed), "assistant"),
        )
@wujiren wujiren added the bug Something isn't working label Jul 14, 2024
@wujiren wujiren changed the title [Bug]: [Bug]: bug in DictDialogAgent when use_memory = False Jul 14, 2024
@DavdGao
Copy link
Collaborator

DavdGao commented Jul 15, 2024

Thanks for your reporting, we will fix it as soon as possible.

@DavdGao DavdGao linked a pull request Jul 16, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants