MetaGPT
MetaGPT copied to clipboard
`team.invest()` doesn't set action.llm.cost_manager
Bug description
team = Team(context=ctx)
team.invest(investment=args.cost)
team.hire(
[
Manager(),
Searcher(),
Researcher(),
Editor(),
Reviewer(),
Human(is_human=True),
]
)
team.invest()
doesn't set action.llm.cost_manager,
Bug solved method
I think ContextMixin should be implemented as a singleton?
When instanciate new Action, it subclass ContextMixin
. And I think the problem might be in this property. line = 78-83
@property
def context(self) -> Context:
"""Role context: role context > context"""
if self.private_context:
return self.private_context
return Context()
It returns a new context regardless of what cost_manager
you set from team.invest()
, because when we get llm from action instance, it use self.context
line 94-95
if not self.private_llm:
self.private_llm = self.context.llm_with_cost_manager_from_llm_config(self.config.llm)
Environment information
- LLM type and model name:
- System version: metagpt 0.7.6
- Python version: python 3.10