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

team.invest() doesn't set action.llm.cost_manager #1086

Closed
azurewtl opened this issue Mar 23, 2024 · 2 comments
Closed

team.invest() doesn't set action.llm.cost_manager #1086

azurewtl opened this issue Mar 23, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@azurewtl
Copy link
Contributor

azurewtl commented Mar 23, 2024

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
@geekan
Copy link
Owner

geekan commented Mar 25, 2024

This was originally designed for priority of Context: Global > Env > Role > Action
But I noticed that the global Context was removed in a certain version, so there were corresponding modifications in a Commit.
I would like to raise a discussion, is it more reasonable to provide a GlobalEnv and use its Context by default?

image

@geekan geekan added the bug Something isn't working label Mar 25, 2024
@iorisa
Copy link
Collaborator

iorisa commented Mar 25, 2024

fixed by: #1035
Same as: #1031

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

No branches or pull requests

3 participants