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

question: Why use self.input_messages as instance variable in agent methods? #323

Open
kingdomad opened this issue Jan 23, 2025 · 0 comments

Comments

@kingdomad
Copy link
Contributor

I have noticed a similar issue in several places within the agent module. Before calling the model, the constructed input_messages is assigned to self.input_messages. However, it seems that self.input_messages is only used when calling self.model, and not utilized elsewhere.
Wouldn't it be simpler to create a local variable input_messages instead?
Is there a specific design consideration behind this choice?

def provide_final_answer(self, task) -> str:

    def provide_final_answer(self, task) -> str:
        """
        This method provides a final answer to the task, based on the logs of the agent's interactions.
        """
        self.input_messages = [
            {
                "role": MessageRole.SYSTEM,
                "content": "An agent tried to answer a user query but it got stuck and failed to do so. You are tasked with providing an answer instead. Here is the agent's memory:",
            }
        ]
        self.input_messages += self.write_inner_memory_from_logs()[1:]
        self.input_messages += [
            {
                "role": MessageRole.USER,
                "content": f"Based on the above, please provide an answer to the following user request:\n{task}",
            }
        ]
        try:
            return self.model(self.input_messages).content
        except Exception as e:
            return f"Error in generating final LLM output:\n{e}"
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

No branches or pull requests

1 participant