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

fix: AttributeError: 'NoneType' object has no attribute 'profile' #1759

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Einstellung
Copy link

Features

  • Fix AttributeError in build_customized_multi_agents.py: 'NoneType' object has no attribute 'profile'
  • Add TeamLeader role to the multi-agent team to ensure proper message handling in the environment

Feature Docs

N/A

Influence

This fix ensures that the build_customized_multi_agents.py example can run properly without errors. The TeamLeader role is essential for the MetaGPT environment to correctly process and publish messages between agents. Without this role, the environment attempts to access attributes of a None object, causing the application to crash.

Result

Before the fix:
Traceback (most recent call last):
File "/Users/einstellung/project/AI/learn/MetaGPT/examples/build_customized_multi_agents.py", line 144, in
fire.Fire(main)
File "/Users/einstellung/Library/Caches/pypoetry/virtualenvs/metagpt-43zsxD3O-py3.9/lib/python3.9/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/Users/einstellung/Library/Caches/pypoetry/virtualenvs/metagpt-43zsxD3O-py3.9/lib/python3.9/site-packages/fire/core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/Users/einstellung/Library/Caches/pypoetry/virtualenvs/metagpt-43zsxD3O-py3.9/lib/python3.9/site-packages/fire/core.py", line 679, in _CallAndUpdateTrace
component = loop.run_until_complete(fn(*varargs, **kwargs))
File "/Users/einstellung/.pyenv/versions/3.9.15/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/Users/einstellung/project/AI/learn/MetaGPT/examples/build_customized_multi_agents.py", line 139, in main
team.run_project(idea)
File "/Users/einstellung/project/AI/learn/MetaGPT/metagpt/team.py", line 107, in run_project
self.env.publish_message(Message(content=idea))
File "/Users/einstellung/project/AI/learn/MetaGPT/metagpt/environment/mgx/mgx_env.py", line 48, in publish_message
elif publicer == tl.profile:
AttributeError: 'NoneType' object has no attribute 'profile'

After the fix:
The script runs successfully and completes the multi-agent interaction as expected.

Other

This fix highlights the importance of the TeamLeader role in the MetaGPT architecture. The TeamLeader is a core component for coordinating the work of other agents in a multi-agent system. Documentation or examples that create multi-agent teams should emphasize the necessity of including a TeamLeader role.

@xukaizhao
Copy link

成功了,希望能把教程以及对应的python文件也改一下,谢谢!!

@lin-xii
Copy link

lin-xii commented Mar 17, 2025

thanks

@xuty06
Copy link

xuty06 commented Mar 21, 2025

Hello, when I added TeamLeader to the debate.py file under examples, the program did not debate between the two agents as expected. How should I deal with it to implement the debate function?

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.

4 participants